babylon.module.d.ts 4.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318
  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/Animations/runtimeAnimation" {
  6777. import { Animation } from "babylonjs/Animations/animation";
  6778. import { Animatable } from "babylonjs/Animations/animatable";
  6779. import { Scene } from "babylonjs/scene";
  6780. /**
  6781. * Defines a runtime animation
  6782. */
  6783. export class RuntimeAnimation {
  6784. private _events;
  6785. /**
  6786. * The current frame of the runtime animation
  6787. */
  6788. private _currentFrame;
  6789. /**
  6790. * The animation used by the runtime animation
  6791. */
  6792. private _animation;
  6793. /**
  6794. * The target of the runtime animation
  6795. */
  6796. private _target;
  6797. /**
  6798. * The initiating animatable
  6799. */
  6800. private _host;
  6801. /**
  6802. * The original value of the runtime animation
  6803. */
  6804. private _originalValue;
  6805. /**
  6806. * The original blend value of the runtime animation
  6807. */
  6808. private _originalBlendValue;
  6809. /**
  6810. * The offsets cache of the runtime animation
  6811. */
  6812. private _offsetsCache;
  6813. /**
  6814. * The high limits cache of the runtime animation
  6815. */
  6816. private _highLimitsCache;
  6817. /**
  6818. * Specifies if the runtime animation has been stopped
  6819. */
  6820. private _stopped;
  6821. /**
  6822. * The blending factor of the runtime animation
  6823. */
  6824. private _blendingFactor;
  6825. /**
  6826. * The BabylonJS scene
  6827. */
  6828. private _scene;
  6829. /**
  6830. * The current value of the runtime animation
  6831. */
  6832. private _currentValue;
  6833. /** @hidden */
  6834. _workValue: any;
  6835. /**
  6836. * The active target of the runtime animation
  6837. */
  6838. private _activeTarget;
  6839. /**
  6840. * The target path of the runtime animation
  6841. */
  6842. private _targetPath;
  6843. /**
  6844. * The weight of the runtime animation
  6845. */
  6846. private _weight;
  6847. /**
  6848. * The ratio offset of the runtime animation
  6849. */
  6850. private _ratioOffset;
  6851. /**
  6852. * The previous delay of the runtime animation
  6853. */
  6854. private _previousDelay;
  6855. /**
  6856. * The previous ratio of the runtime animation
  6857. */
  6858. private _previousRatio;
  6859. /**
  6860. * Gets the current frame of the runtime animation
  6861. */
  6862. readonly currentFrame: number;
  6863. /**
  6864. * Gets the weight of the runtime animation
  6865. */
  6866. readonly weight: number;
  6867. /**
  6868. * Gets the current value of the runtime animation
  6869. */
  6870. readonly currentValue: any;
  6871. /**
  6872. * Gets the target path of the runtime animation
  6873. */
  6874. readonly targetPath: string;
  6875. /**
  6876. * Gets the actual target of the runtime animation
  6877. */
  6878. readonly target: any;
  6879. /**
  6880. * Create a new RuntimeAnimation object
  6881. * @param target defines the target of the animation
  6882. * @param animation defines the source animation object
  6883. * @param scene defines the hosting scene
  6884. * @param host defines the initiating Animatable
  6885. */
  6886. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  6887. /**
  6888. * Gets the animation from the runtime animation
  6889. */
  6890. readonly animation: Animation;
  6891. /**
  6892. * Resets the runtime animation to the beginning
  6893. * @param restoreOriginal defines whether to restore the target property to the original value
  6894. */
  6895. reset(restoreOriginal?: boolean): void;
  6896. /**
  6897. * Specifies if the runtime animation is stopped
  6898. * @returns Boolean specifying if the runtime animation is stopped
  6899. */
  6900. isStopped(): boolean;
  6901. /**
  6902. * Disposes of the runtime animation
  6903. */
  6904. dispose(): void;
  6905. /**
  6906. * Interpolates the animation from the current frame
  6907. * @param currentFrame The frame to interpolate the animation to
  6908. * @param repeatCount The number of times that the animation should loop
  6909. * @param loopMode The type of looping mode to use
  6910. * @param offsetValue Animation offset value
  6911. * @param highLimitValue The high limit value
  6912. * @returns The interpolated value
  6913. */
  6914. private _interpolate;
  6915. /**
  6916. * Apply the interpolated value to the target
  6917. * @param currentValue defines the value computed by the animation
  6918. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  6919. */
  6920. setValue(currentValue: any, weight?: number): void;
  6921. private _setValue;
  6922. /**
  6923. * Gets the loop pmode of the runtime animation
  6924. * @returns Loop Mode
  6925. */
  6926. private _getCorrectLoopMode;
  6927. /**
  6928. * Move the current animation to a given frame
  6929. * @param frame defines the frame to move to
  6930. */
  6931. goToFrame(frame: number): void;
  6932. /**
  6933. * @hidden Internal use only
  6934. */
  6935. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  6936. /**
  6937. * Execute the current animation
  6938. * @param delay defines the delay to add to the current frame
  6939. * @param from defines the lower bound of the animation range
  6940. * @param to defines the upper bound of the animation range
  6941. * @param loop defines if the current animation must loop
  6942. * @param speedRatio defines the current speed ratio
  6943. * @param weight defines the weight of the animation (default is -1 so no weight)
  6944. * @param onLoop optional callback called when animation loops
  6945. * @returns a boolean indicating if the animation is running
  6946. */
  6947. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  6948. }
  6949. }
  6950. declare module "babylonjs/Collisions/intersectionInfo" {
  6951. import { Nullable } from "babylonjs/types";
  6952. /**
  6953. * @hidden
  6954. */
  6955. export class IntersectionInfo {
  6956. bu: Nullable<number>;
  6957. bv: Nullable<number>;
  6958. distance: number;
  6959. faceId: number;
  6960. subMeshId: number;
  6961. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6962. }
  6963. }
  6964. declare module "babylonjs/Culling/boundingSphere" {
  6965. import { DeepImmutable } from "babylonjs/types";
  6966. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6967. /**
  6968. * Class used to store bounding sphere information
  6969. */
  6970. export class BoundingSphere {
  6971. /**
  6972. * Gets the center of the bounding sphere in local space
  6973. */
  6974. readonly center: Vector3;
  6975. /**
  6976. * Radius of the bounding sphere in local space
  6977. */
  6978. radius: number;
  6979. /**
  6980. * Gets the center of the bounding sphere in world space
  6981. */
  6982. readonly centerWorld: Vector3;
  6983. /**
  6984. * Radius of the bounding sphere in world space
  6985. */
  6986. radiusWorld: number;
  6987. /**
  6988. * Gets the minimum vector in local space
  6989. */
  6990. readonly minimum: Vector3;
  6991. /**
  6992. * Gets the maximum vector in local space
  6993. */
  6994. readonly maximum: Vector3;
  6995. private _worldMatrix;
  6996. private static readonly TmpVector3;
  6997. /**
  6998. * Creates a new bounding sphere
  6999. * @param min defines the minimum vector (in local space)
  7000. * @param max defines the maximum vector (in local space)
  7001. * @param worldMatrix defines the new world matrix
  7002. */
  7003. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7004. /**
  7005. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7006. * @param min defines the new minimum vector (in local space)
  7007. * @param max defines the new maximum vector (in local space)
  7008. * @param worldMatrix defines the new world matrix
  7009. */
  7010. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7011. /**
  7012. * Scale the current bounding sphere by applying a scale factor
  7013. * @param factor defines the scale factor to apply
  7014. * @returns the current bounding box
  7015. */
  7016. scale(factor: number): BoundingSphere;
  7017. /**
  7018. * Gets the world matrix of the bounding box
  7019. * @returns a matrix
  7020. */
  7021. getWorldMatrix(): DeepImmutable<Matrix>;
  7022. /** @hidden */
  7023. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7024. /**
  7025. * Tests if the bounding sphere is intersecting the frustum planes
  7026. * @param frustumPlanes defines the frustum planes to test
  7027. * @returns true if there is an intersection
  7028. */
  7029. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7030. /**
  7031. * Tests if the bounding sphere center is in between the frustum planes.
  7032. * Used for optimistic fast inclusion.
  7033. * @param frustumPlanes defines the frustum planes to test
  7034. * @returns true if the sphere center is in between the frustum planes
  7035. */
  7036. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7037. /**
  7038. * Tests if a point is inside the bounding sphere
  7039. * @param point defines the point to test
  7040. * @returns true if the point is inside the bounding sphere
  7041. */
  7042. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7043. /**
  7044. * Checks if two sphere intersct
  7045. * @param sphere0 sphere 0
  7046. * @param sphere1 sphere 1
  7047. * @returns true if the speres intersect
  7048. */
  7049. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7050. }
  7051. }
  7052. declare module "babylonjs/Culling/boundingBox" {
  7053. import { DeepImmutable } from "babylonjs/types";
  7054. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7055. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7056. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7057. /**
  7058. * Class used to store bounding box information
  7059. */
  7060. export class BoundingBox implements ICullable {
  7061. /**
  7062. * Gets the 8 vectors representing the bounding box in local space
  7063. */
  7064. readonly vectors: Vector3[];
  7065. /**
  7066. * Gets the center of the bounding box in local space
  7067. */
  7068. readonly center: Vector3;
  7069. /**
  7070. * Gets the center of the bounding box in world space
  7071. */
  7072. readonly centerWorld: Vector3;
  7073. /**
  7074. * Gets the extend size in local space
  7075. */
  7076. readonly extendSize: Vector3;
  7077. /**
  7078. * Gets the extend size in world space
  7079. */
  7080. readonly extendSizeWorld: Vector3;
  7081. /**
  7082. * Gets the OBB (object bounding box) directions
  7083. */
  7084. readonly directions: Vector3[];
  7085. /**
  7086. * Gets the 8 vectors representing the bounding box in world space
  7087. */
  7088. readonly vectorsWorld: Vector3[];
  7089. /**
  7090. * Gets the minimum vector in world space
  7091. */
  7092. readonly minimumWorld: Vector3;
  7093. /**
  7094. * Gets the maximum vector in world space
  7095. */
  7096. readonly maximumWorld: Vector3;
  7097. /**
  7098. * Gets the minimum vector in local space
  7099. */
  7100. readonly minimum: Vector3;
  7101. /**
  7102. * Gets the maximum vector in local space
  7103. */
  7104. readonly maximum: Vector3;
  7105. private _worldMatrix;
  7106. private static readonly TmpVector3;
  7107. /**
  7108. * @hidden
  7109. */
  7110. _tag: number;
  7111. /**
  7112. * Creates a new bounding box
  7113. * @param min defines the minimum vector (in local space)
  7114. * @param max defines the maximum vector (in local space)
  7115. * @param worldMatrix defines the new world matrix
  7116. */
  7117. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7118. /**
  7119. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7120. * @param min defines the new minimum vector (in local space)
  7121. * @param max defines the new maximum vector (in local space)
  7122. * @param worldMatrix defines the new world matrix
  7123. */
  7124. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7125. /**
  7126. * Scale the current bounding box by applying a scale factor
  7127. * @param factor defines the scale factor to apply
  7128. * @returns the current bounding box
  7129. */
  7130. scale(factor: number): BoundingBox;
  7131. /**
  7132. * Gets the world matrix of the bounding box
  7133. * @returns a matrix
  7134. */
  7135. getWorldMatrix(): DeepImmutable<Matrix>;
  7136. /** @hidden */
  7137. _update(world: DeepImmutable<Matrix>): void;
  7138. /**
  7139. * Tests if the bounding box is intersecting the frustum planes
  7140. * @param frustumPlanes defines the frustum planes to test
  7141. * @returns true if there is an intersection
  7142. */
  7143. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7144. /**
  7145. * Tests if the bounding box is entirely inside the frustum planes
  7146. * @param frustumPlanes defines the frustum planes to test
  7147. * @returns true if there is an inclusion
  7148. */
  7149. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7150. /**
  7151. * Tests if a point is inside the bounding box
  7152. * @param point defines the point to test
  7153. * @returns true if the point is inside the bounding box
  7154. */
  7155. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7156. /**
  7157. * Tests if the bounding box intersects with a bounding sphere
  7158. * @param sphere defines the sphere to test
  7159. * @returns true if there is an intersection
  7160. */
  7161. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7162. /**
  7163. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7164. * @param min defines the min vector to use
  7165. * @param max defines the max vector to use
  7166. * @returns true if there is an intersection
  7167. */
  7168. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7169. /**
  7170. * Tests if two bounding boxes are intersections
  7171. * @param box0 defines the first box to test
  7172. * @param box1 defines the second box to test
  7173. * @returns true if there is an intersection
  7174. */
  7175. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7176. /**
  7177. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7178. * @param minPoint defines the minimum vector of the bounding box
  7179. * @param maxPoint defines the maximum vector of the bounding box
  7180. * @param sphereCenter defines the sphere center
  7181. * @param sphereRadius defines the sphere radius
  7182. * @returns true if there is an intersection
  7183. */
  7184. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7185. /**
  7186. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7187. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7188. * @param frustumPlanes defines the frustum planes to test
  7189. * @return true if there is an inclusion
  7190. */
  7191. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7192. /**
  7193. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7194. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7195. * @param frustumPlanes defines the frustum planes to test
  7196. * @return true if there is an intersection
  7197. */
  7198. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7199. }
  7200. }
  7201. declare module "babylonjs/Collisions/collider" {
  7202. import { Nullable, IndicesArray } from "babylonjs/types";
  7203. import { Vector3, Plane } from "babylonjs/Maths/math";
  7204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7205. /** @hidden */
  7206. export class Collider {
  7207. /** Define if a collision was found */
  7208. collisionFound: boolean;
  7209. /**
  7210. * Define last intersection point in local space
  7211. */
  7212. intersectionPoint: Vector3;
  7213. /**
  7214. * Define last collided mesh
  7215. */
  7216. collidedMesh: Nullable<AbstractMesh>;
  7217. private _collisionPoint;
  7218. private _planeIntersectionPoint;
  7219. private _tempVector;
  7220. private _tempVector2;
  7221. private _tempVector3;
  7222. private _tempVector4;
  7223. private _edge;
  7224. private _baseToVertex;
  7225. private _destinationPoint;
  7226. private _slidePlaneNormal;
  7227. private _displacementVector;
  7228. /** @hidden */
  7229. _radius: Vector3;
  7230. /** @hidden */
  7231. _retry: number;
  7232. private _velocity;
  7233. private _basePoint;
  7234. private _epsilon;
  7235. /** @hidden */
  7236. _velocityWorldLength: number;
  7237. /** @hidden */
  7238. _basePointWorld: Vector3;
  7239. private _velocityWorld;
  7240. private _normalizedVelocity;
  7241. /** @hidden */
  7242. _initialVelocity: Vector3;
  7243. /** @hidden */
  7244. _initialPosition: Vector3;
  7245. private _nearestDistance;
  7246. private _collisionMask;
  7247. collisionMask: number;
  7248. /**
  7249. * Gets the plane normal used to compute the sliding response (in local space)
  7250. */
  7251. readonly slidePlaneNormal: Vector3;
  7252. /** @hidden */
  7253. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7254. /** @hidden */
  7255. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7256. /** @hidden */
  7257. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7258. /** @hidden */
  7259. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7260. /** @hidden */
  7261. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7262. /** @hidden */
  7263. _getResponse(pos: Vector3, vel: Vector3): void;
  7264. }
  7265. }
  7266. declare module "babylonjs/Culling/boundingInfo" {
  7267. import { DeepImmutable } from "babylonjs/types";
  7268. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7269. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7270. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7271. import { Collider } from "babylonjs/Collisions/collider";
  7272. /**
  7273. * Interface for cullable objects
  7274. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7275. */
  7276. export interface ICullable {
  7277. /**
  7278. * Checks if the object or part of the object is in the frustum
  7279. * @param frustumPlanes Camera near/planes
  7280. * @returns true if the object is in frustum otherwise false
  7281. */
  7282. isInFrustum(frustumPlanes: Plane[]): boolean;
  7283. /**
  7284. * Checks if a cullable object (mesh...) is in the camera frustum
  7285. * Unlike isInFrustum this cheks the full bounding box
  7286. * @param frustumPlanes Camera near/planes
  7287. * @returns true if the object is in frustum otherwise false
  7288. */
  7289. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7290. }
  7291. /**
  7292. * Info for a bounding data of a mesh
  7293. */
  7294. export class BoundingInfo implements ICullable {
  7295. /**
  7296. * Bounding box for the mesh
  7297. */
  7298. readonly boundingBox: BoundingBox;
  7299. /**
  7300. * Bounding sphere for the mesh
  7301. */
  7302. readonly boundingSphere: BoundingSphere;
  7303. private _isLocked;
  7304. private static readonly TmpVector3;
  7305. /**
  7306. * Constructs bounding info
  7307. * @param minimum min vector of the bounding box/sphere
  7308. * @param maximum max vector of the bounding box/sphere
  7309. * @param worldMatrix defines the new world matrix
  7310. */
  7311. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7312. /**
  7313. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7314. * @param min defines the new minimum vector (in local space)
  7315. * @param max defines the new maximum vector (in local space)
  7316. * @param worldMatrix defines the new world matrix
  7317. */
  7318. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7319. /**
  7320. * min vector of the bounding box/sphere
  7321. */
  7322. readonly minimum: Vector3;
  7323. /**
  7324. * max vector of the bounding box/sphere
  7325. */
  7326. readonly maximum: Vector3;
  7327. /**
  7328. * If the info is locked and won't be updated to avoid perf overhead
  7329. */
  7330. isLocked: boolean;
  7331. /**
  7332. * Updates the bounding sphere and box
  7333. * @param world world matrix to be used to update
  7334. */
  7335. update(world: DeepImmutable<Matrix>): void;
  7336. /**
  7337. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7338. * @param center New center of the bounding info
  7339. * @param extend New extend of the bounding info
  7340. * @returns the current bounding info
  7341. */
  7342. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7343. /**
  7344. * Scale the current bounding info by applying a scale factor
  7345. * @param factor defines the scale factor to apply
  7346. * @returns the current bounding info
  7347. */
  7348. scale(factor: number): BoundingInfo;
  7349. /**
  7350. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7351. * @param frustumPlanes defines the frustum to test
  7352. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7353. * @returns true if the bounding info is in the frustum planes
  7354. */
  7355. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7356. /**
  7357. * Gets the world distance between the min and max points of the bounding box
  7358. */
  7359. readonly diagonalLength: number;
  7360. /**
  7361. * Checks if a cullable object (mesh...) is in the camera frustum
  7362. * Unlike isInFrustum this cheks the full bounding box
  7363. * @param frustumPlanes Camera near/planes
  7364. * @returns true if the object is in frustum otherwise false
  7365. */
  7366. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7367. /** @hidden */
  7368. _checkCollision(collider: Collider): boolean;
  7369. /**
  7370. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7371. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7372. * @param point the point to check intersection with
  7373. * @returns if the point intersects
  7374. */
  7375. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7376. /**
  7377. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7378. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7379. * @param boundingInfo the bounding info to check intersection with
  7380. * @param precise if the intersection should be done using OBB
  7381. * @returns if the bounding info intersects
  7382. */
  7383. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7384. }
  7385. }
  7386. declare module "babylonjs/Misc/smartArray" {
  7387. /**
  7388. * Defines an array and its length.
  7389. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7390. */
  7391. export interface ISmartArrayLike<T> {
  7392. /**
  7393. * The data of the array.
  7394. */
  7395. data: Array<T>;
  7396. /**
  7397. * The active length of the array.
  7398. */
  7399. length: number;
  7400. }
  7401. /**
  7402. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7403. */
  7404. export class SmartArray<T> implements ISmartArrayLike<T> {
  7405. /**
  7406. * The full set of data from the array.
  7407. */
  7408. data: Array<T>;
  7409. /**
  7410. * The active length of the array.
  7411. */
  7412. length: number;
  7413. protected _id: number;
  7414. /**
  7415. * Instantiates a Smart Array.
  7416. * @param capacity defines the default capacity of the array.
  7417. */
  7418. constructor(capacity: number);
  7419. /**
  7420. * Pushes a value at the end of the active data.
  7421. * @param value defines the object to push in the array.
  7422. */
  7423. push(value: T): void;
  7424. /**
  7425. * Iterates over the active data and apply the lambda to them.
  7426. * @param func defines the action to apply on each value.
  7427. */
  7428. forEach(func: (content: T) => void): void;
  7429. /**
  7430. * Sorts the full sets of data.
  7431. * @param compareFn defines the comparison function to apply.
  7432. */
  7433. sort(compareFn: (a: T, b: T) => number): void;
  7434. /**
  7435. * Resets the active data to an empty array.
  7436. */
  7437. reset(): void;
  7438. /**
  7439. * Releases all the data from the array as well as the array.
  7440. */
  7441. dispose(): void;
  7442. /**
  7443. * Concats the active data with a given array.
  7444. * @param array defines the data to concatenate with.
  7445. */
  7446. concat(array: any): void;
  7447. /**
  7448. * Returns the position of a value in the active data.
  7449. * @param value defines the value to find the index for
  7450. * @returns the index if found in the active data otherwise -1
  7451. */
  7452. indexOf(value: T): number;
  7453. /**
  7454. * Returns whether an element is part of the active data.
  7455. * @param value defines the value to look for
  7456. * @returns true if found in the active data otherwise false
  7457. */
  7458. contains(value: T): boolean;
  7459. private static _GlobalId;
  7460. }
  7461. /**
  7462. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7463. * The data in this array can only be present once
  7464. */
  7465. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7466. private _duplicateId;
  7467. /**
  7468. * Pushes a value at the end of the active data.
  7469. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7470. * @param value defines the object to push in the array.
  7471. */
  7472. push(value: T): void;
  7473. /**
  7474. * Pushes a value at the end of the active data.
  7475. * If the data is already present, it won t be added again
  7476. * @param value defines the object to push in the array.
  7477. * @returns true if added false if it was already present
  7478. */
  7479. pushNoDuplicate(value: T): boolean;
  7480. /**
  7481. * Resets the active data to an empty array.
  7482. */
  7483. reset(): void;
  7484. /**
  7485. * Concats the active data with a given array.
  7486. * This ensures no dupplicate will be present in the result.
  7487. * @param array defines the data to concatenate with.
  7488. */
  7489. concatWithNoDuplicate(array: any): void;
  7490. }
  7491. }
  7492. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7493. /**
  7494. * Class used to represent data loading progression
  7495. */
  7496. export class SceneLoaderFlags {
  7497. private static _ForceFullSceneLoadingForIncremental;
  7498. private static _ShowLoadingScreen;
  7499. private static _CleanBoneMatrixWeights;
  7500. private static _loggingLevel;
  7501. /**
  7502. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7503. */
  7504. static ForceFullSceneLoadingForIncremental: boolean;
  7505. /**
  7506. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7507. */
  7508. static ShowLoadingScreen: boolean;
  7509. /**
  7510. * Defines the current logging level (while loading the scene)
  7511. * @ignorenaming
  7512. */
  7513. static loggingLevel: number;
  7514. /**
  7515. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7516. */
  7517. static CleanBoneMatrixWeights: boolean;
  7518. }
  7519. }
  7520. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7521. /**
  7522. * Class used to override all child animations of a given target
  7523. */
  7524. export class AnimationPropertiesOverride {
  7525. /**
  7526. * Gets or sets a value indicating if animation blending must be used
  7527. */
  7528. enableBlending: boolean;
  7529. /**
  7530. * Gets or sets the blending speed to use when enableBlending is true
  7531. */
  7532. blendingSpeed: number;
  7533. /**
  7534. * Gets or sets the default loop mode to use
  7535. */
  7536. loopMode: number;
  7537. }
  7538. }
  7539. declare module "babylonjs/Morph/morphTarget" {
  7540. import { IAnimatable } from "babylonjs/Misc/tools";
  7541. import { Observable } from "babylonjs/Misc/observable";
  7542. import { Nullable, FloatArray } from "babylonjs/types";
  7543. import { Scene } from "babylonjs/scene";
  7544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7545. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7546. /**
  7547. * Defines a target to use with MorphTargetManager
  7548. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  7549. */
  7550. export class MorphTarget implements IAnimatable {
  7551. /** defines the name of the target */
  7552. name: string;
  7553. /**
  7554. * Gets or sets the list of animations
  7555. */
  7556. animations: import("babylonjs/Animations/animation").Animation[];
  7557. private _scene;
  7558. private _positions;
  7559. private _normals;
  7560. private _tangents;
  7561. private _influence;
  7562. /**
  7563. * Observable raised when the influence changes
  7564. */
  7565. onInfluenceChanged: Observable<boolean>;
  7566. /** @hidden */
  7567. _onDataLayoutChanged: Observable<void>;
  7568. /**
  7569. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  7570. */
  7571. influence: number;
  7572. /**
  7573. * Gets or sets the id of the morph Target
  7574. */
  7575. id: string;
  7576. private _animationPropertiesOverride;
  7577. /**
  7578. * Gets or sets the animation properties override
  7579. */
  7580. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  7581. /**
  7582. * Creates a new MorphTarget
  7583. * @param name defines the name of the target
  7584. * @param influence defines the influence to use
  7585. * @param scene defines the scene the morphtarget belongs to
  7586. */
  7587. constructor(
  7588. /** defines the name of the target */
  7589. name: string, influence?: number, scene?: Nullable<Scene>);
  7590. /**
  7591. * Gets a boolean defining if the target contains position data
  7592. */
  7593. readonly hasPositions: boolean;
  7594. /**
  7595. * Gets a boolean defining if the target contains normal data
  7596. */
  7597. readonly hasNormals: boolean;
  7598. /**
  7599. * Gets a boolean defining if the target contains tangent data
  7600. */
  7601. readonly hasTangents: boolean;
  7602. /**
  7603. * Affects position data to this target
  7604. * @param data defines the position data to use
  7605. */
  7606. setPositions(data: Nullable<FloatArray>): void;
  7607. /**
  7608. * Gets the position data stored in this target
  7609. * @returns a FloatArray containing the position data (or null if not present)
  7610. */
  7611. getPositions(): Nullable<FloatArray>;
  7612. /**
  7613. * Affects normal data to this target
  7614. * @param data defines the normal data to use
  7615. */
  7616. setNormals(data: Nullable<FloatArray>): void;
  7617. /**
  7618. * Gets the normal data stored in this target
  7619. * @returns a FloatArray containing the normal data (or null if not present)
  7620. */
  7621. getNormals(): Nullable<FloatArray>;
  7622. /**
  7623. * Affects tangent data to this target
  7624. * @param data defines the tangent data to use
  7625. */
  7626. setTangents(data: Nullable<FloatArray>): void;
  7627. /**
  7628. * Gets the tangent data stored in this target
  7629. * @returns a FloatArray containing the tangent data (or null if not present)
  7630. */
  7631. getTangents(): Nullable<FloatArray>;
  7632. /**
  7633. * Serializes the current target into a Serialization object
  7634. * @returns the serialized object
  7635. */
  7636. serialize(): any;
  7637. /**
  7638. * Returns the string "MorphTarget"
  7639. * @returns "MorphTarget"
  7640. */
  7641. getClassName(): string;
  7642. /**
  7643. * Creates a new target from serialized data
  7644. * @param serializationObject defines the serialized data to use
  7645. * @returns a new MorphTarget
  7646. */
  7647. static Parse(serializationObject: any): MorphTarget;
  7648. /**
  7649. * Creates a MorphTarget from mesh data
  7650. * @param mesh defines the source mesh
  7651. * @param name defines the name to use for the new target
  7652. * @param influence defines the influence to attach to the target
  7653. * @returns a new MorphTarget
  7654. */
  7655. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  7656. }
  7657. }
  7658. declare module "babylonjs/Morph/morphTargetManager" {
  7659. import { Nullable } from "babylonjs/types";
  7660. import { Scene } from "babylonjs/scene";
  7661. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  7662. /**
  7663. * This class is used to deform meshes using morphing between different targets
  7664. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  7665. */
  7666. export class MorphTargetManager {
  7667. private _targets;
  7668. private _targetInfluenceChangedObservers;
  7669. private _targetDataLayoutChangedObservers;
  7670. private _activeTargets;
  7671. private _scene;
  7672. private _influences;
  7673. private _supportsNormals;
  7674. private _supportsTangents;
  7675. private _vertexCount;
  7676. private _uniqueId;
  7677. private _tempInfluences;
  7678. /**
  7679. * Creates a new MorphTargetManager
  7680. * @param scene defines the current scene
  7681. */
  7682. constructor(scene?: Nullable<Scene>);
  7683. /**
  7684. * Gets the unique ID of this manager
  7685. */
  7686. readonly uniqueId: number;
  7687. /**
  7688. * Gets the number of vertices handled by this manager
  7689. */
  7690. readonly vertexCount: number;
  7691. /**
  7692. * Gets a boolean indicating if this manager supports morphing of normals
  7693. */
  7694. readonly supportsNormals: boolean;
  7695. /**
  7696. * Gets a boolean indicating if this manager supports morphing of tangents
  7697. */
  7698. readonly supportsTangents: boolean;
  7699. /**
  7700. * Gets the number of targets stored in this manager
  7701. */
  7702. readonly numTargets: number;
  7703. /**
  7704. * Gets the number of influencers (ie. the number of targets with influences > 0)
  7705. */
  7706. readonly numInfluencers: number;
  7707. /**
  7708. * Gets the list of influences (one per target)
  7709. */
  7710. readonly influences: Float32Array;
  7711. /**
  7712. * Gets the active target at specified index. An active target is a target with an influence > 0
  7713. * @param index defines the index to check
  7714. * @returns the requested target
  7715. */
  7716. getActiveTarget(index: number): MorphTarget;
  7717. /**
  7718. * Gets the target at specified index
  7719. * @param index defines the index to check
  7720. * @returns the requested target
  7721. */
  7722. getTarget(index: number): MorphTarget;
  7723. /**
  7724. * Add a new target to this manager
  7725. * @param target defines the target to add
  7726. */
  7727. addTarget(target: MorphTarget): void;
  7728. /**
  7729. * Removes a target from the manager
  7730. * @param target defines the target to remove
  7731. */
  7732. removeTarget(target: MorphTarget): void;
  7733. /**
  7734. * Serializes the current manager into a Serialization object
  7735. * @returns the serialized object
  7736. */
  7737. serialize(): any;
  7738. private _syncActiveTargets;
  7739. /**
  7740. * Syncrhonize the targets with all the meshes using this morph target manager
  7741. */
  7742. synchronize(): void;
  7743. /**
  7744. * Creates a new MorphTargetManager from serialized data
  7745. * @param serializationObject defines the serialized data
  7746. * @param scene defines the hosting scene
  7747. * @returns the new MorphTargetManager
  7748. */
  7749. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  7750. }
  7751. }
  7752. declare module "babylonjs/Meshes/instancedMesh" {
  7753. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  7754. import { Vector3 } from "babylonjs/Maths/math";
  7755. import { Camera } from "babylonjs/Cameras/camera";
  7756. import { Node } from "babylonjs/node";
  7757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7758. import { Mesh } from "babylonjs/Meshes/mesh";
  7759. import { Material } from "babylonjs/Materials/material";
  7760. import { Skeleton } from "babylonjs/Bones/skeleton";
  7761. /**
  7762. * Creates an instance based on a source mesh.
  7763. */
  7764. export class InstancedMesh extends AbstractMesh {
  7765. private _sourceMesh;
  7766. private _currentLOD;
  7767. /** @hidden */
  7768. _indexInSourceMeshInstanceArray: number;
  7769. constructor(name: string, source: Mesh);
  7770. /**
  7771. * Returns the string "InstancedMesh".
  7772. */
  7773. getClassName(): string;
  7774. /**
  7775. * If the source mesh receives shadows
  7776. */
  7777. readonly receiveShadows: boolean;
  7778. /**
  7779. * The material of the source mesh
  7780. */
  7781. readonly material: Nullable<Material>;
  7782. /**
  7783. * Visibility of the source mesh
  7784. */
  7785. readonly visibility: number;
  7786. /**
  7787. * Skeleton of the source mesh
  7788. */
  7789. readonly skeleton: Nullable<Skeleton>;
  7790. /**
  7791. * Rendering ground id of the source mesh
  7792. */
  7793. renderingGroupId: number;
  7794. /**
  7795. * Returns the total number of vertices (integer).
  7796. */
  7797. getTotalVertices(): number;
  7798. /**
  7799. * Returns a positive integer : the total number of indices in this mesh geometry.
  7800. * @returns the numner of indices or zero if the mesh has no geometry.
  7801. */
  7802. getTotalIndices(): number;
  7803. /**
  7804. * The source mesh of the instance
  7805. */
  7806. readonly sourceMesh: Mesh;
  7807. /**
  7808. * Is this node ready to be used/rendered
  7809. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  7810. * @return {boolean} is it ready
  7811. */
  7812. isReady(completeCheck?: boolean): boolean;
  7813. /**
  7814. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  7815. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  7816. * @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.
  7817. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  7818. */
  7819. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  7820. /**
  7821. * Sets the vertex data of the mesh geometry for the requested `kind`.
  7822. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  7823. * The `data` are either a numeric array either a Float32Array.
  7824. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  7825. * 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).
  7826. * Note that a new underlying VertexBuffer object is created each call.
  7827. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  7828. *
  7829. * Possible `kind` values :
  7830. * - VertexBuffer.PositionKind
  7831. * - VertexBuffer.UVKind
  7832. * - VertexBuffer.UV2Kind
  7833. * - VertexBuffer.UV3Kind
  7834. * - VertexBuffer.UV4Kind
  7835. * - VertexBuffer.UV5Kind
  7836. * - VertexBuffer.UV6Kind
  7837. * - VertexBuffer.ColorKind
  7838. * - VertexBuffer.MatricesIndicesKind
  7839. * - VertexBuffer.MatricesIndicesExtraKind
  7840. * - VertexBuffer.MatricesWeightsKind
  7841. * - VertexBuffer.MatricesWeightsExtraKind
  7842. *
  7843. * Returns the Mesh.
  7844. */
  7845. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  7846. /**
  7847. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  7848. * If the mesh has no geometry, it is simply returned as it is.
  7849. * The `data` are either a numeric array either a Float32Array.
  7850. * No new underlying VertexBuffer object is created.
  7851. * 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.
  7852. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  7853. *
  7854. * Possible `kind` values :
  7855. * - VertexBuffer.PositionKind
  7856. * - VertexBuffer.UVKind
  7857. * - VertexBuffer.UV2Kind
  7858. * - VertexBuffer.UV3Kind
  7859. * - VertexBuffer.UV4Kind
  7860. * - VertexBuffer.UV5Kind
  7861. * - VertexBuffer.UV6Kind
  7862. * - VertexBuffer.ColorKind
  7863. * - VertexBuffer.MatricesIndicesKind
  7864. * - VertexBuffer.MatricesIndicesExtraKind
  7865. * - VertexBuffer.MatricesWeightsKind
  7866. * - VertexBuffer.MatricesWeightsExtraKind
  7867. *
  7868. * Returns the Mesh.
  7869. */
  7870. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  7871. /**
  7872. * Sets the mesh indices.
  7873. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  7874. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  7875. * This method creates a new index buffer each call.
  7876. * Returns the Mesh.
  7877. */
  7878. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  7879. /**
  7880. * Boolean : True if the mesh owns the requested kind of data.
  7881. */
  7882. isVerticesDataPresent(kind: string): boolean;
  7883. /**
  7884. * Returns an array of indices (IndicesArray).
  7885. */
  7886. getIndices(): Nullable<IndicesArray>;
  7887. readonly _positions: Nullable<Vector3[]>;
  7888. /**
  7889. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  7890. * This means the mesh underlying bounding box and sphere are recomputed.
  7891. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  7892. * @returns the current mesh
  7893. */
  7894. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  7895. /** @hidden */
  7896. _preActivate(): InstancedMesh;
  7897. /** @hidden */
  7898. _activate(renderId: number): InstancedMesh;
  7899. /**
  7900. * Returns the current associated LOD AbstractMesh.
  7901. */
  7902. getLOD(camera: Camera): AbstractMesh;
  7903. /** @hidden */
  7904. _syncSubMeshes(): InstancedMesh;
  7905. /** @hidden */
  7906. _generatePointsArray(): boolean;
  7907. /**
  7908. * Creates a new InstancedMesh from the current mesh.
  7909. * - name (string) : the cloned mesh name
  7910. * - newParent (optional Node) : the optional Node to parent the clone to.
  7911. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  7912. *
  7913. * Returns the clone.
  7914. */
  7915. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  7916. /**
  7917. * Disposes the InstancedMesh.
  7918. * Returns nothing.
  7919. */
  7920. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7921. }
  7922. }
  7923. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7924. import { Nullable } from "babylonjs/types";
  7925. import { Scene } from "babylonjs/scene";
  7926. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  7927. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7928. /**
  7929. * Class for creating a cube texture
  7930. */
  7931. export class CubeTexture extends BaseTexture {
  7932. private _delayedOnLoad;
  7933. /**
  7934. * The url of the texture
  7935. */
  7936. url: string;
  7937. /**
  7938. * Gets or sets the center of the bounding box associated with the cube texture.
  7939. * It must define where the camera used to render the texture was set
  7940. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7941. */
  7942. boundingBoxPosition: Vector3;
  7943. private _boundingBoxSize;
  7944. /**
  7945. * Gets or sets the size of the bounding box associated with the cube texture
  7946. * When defined, the cubemap will switch to local mode
  7947. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7948. * @example https://www.babylonjs-playground.com/#RNASML
  7949. */
  7950. /**
  7951. * Returns the bounding box size
  7952. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7953. */
  7954. boundingBoxSize: Vector3;
  7955. protected _rotationY: number;
  7956. /**
  7957. * Sets texture matrix rotation angle around Y axis in radians.
  7958. */
  7959. /**
  7960. * Gets texture matrix rotation angle around Y axis radians.
  7961. */
  7962. rotationY: number;
  7963. /**
  7964. * Are mip maps generated for this texture or not.
  7965. */
  7966. readonly noMipmap: boolean;
  7967. private _noMipmap;
  7968. private _files;
  7969. private _extensions;
  7970. private _textureMatrix;
  7971. private _format;
  7972. private _createPolynomials;
  7973. /** @hidden */
  7974. _prefiltered: boolean;
  7975. /**
  7976. * Creates a cube texture from an array of image urls
  7977. * @param files defines an array of image urls
  7978. * @param scene defines the hosting scene
  7979. * @param noMipmap specifies if mip maps are not used
  7980. * @returns a cube texture
  7981. */
  7982. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7983. /**
  7984. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7985. * @param url defines the url of the prefiltered texture
  7986. * @param scene defines the scene the texture is attached to
  7987. * @param forcedExtension defines the extension of the file if different from the url
  7988. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7989. * @return the prefiltered texture
  7990. */
  7991. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7992. /**
  7993. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7994. * as prefiltered data.
  7995. * @param rootUrl defines the url of the texture or the root name of the six images
  7996. * @param scene defines the scene the texture is attached to
  7997. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7998. * @param noMipmap defines if mipmaps should be created or not
  7999. * @param files defines the six files to load for the different faces
  8000. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8001. * @param onError defines a callback triggered in case of error during load
  8002. * @param format defines the internal format to use for the texture once loaded
  8003. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8004. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8005. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8006. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8007. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8008. * @return the cube texture
  8009. */
  8010. 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);
  8011. /**
  8012. * Get the current class name of the texture useful for serialization or dynamic coding.
  8013. * @returns "CubeTexture"
  8014. */
  8015. getClassName(): string;
  8016. /**
  8017. * Update the url (and optional buffer) of this texture if url was null during construction.
  8018. * @param url the url of the texture
  8019. * @param forcedExtension defines the extension to use
  8020. * @param onLoad callback called when the texture is loaded (defaults to null)
  8021. */
  8022. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8023. /**
  8024. * Delays loading of the cube texture
  8025. * @param forcedExtension defines the extension to use
  8026. */
  8027. delayLoad(forcedExtension?: string): void;
  8028. /**
  8029. * Returns the reflection texture matrix
  8030. * @returns the reflection texture matrix
  8031. */
  8032. getReflectionTextureMatrix(): Matrix;
  8033. /**
  8034. * Sets the reflection texture matrix
  8035. * @param value Reflection texture matrix
  8036. */
  8037. setReflectionTextureMatrix(value: Matrix): void;
  8038. /**
  8039. * Parses text to create a cube texture
  8040. * @param parsedTexture define the serialized text to read from
  8041. * @param scene defines the hosting scene
  8042. * @param rootUrl defines the root url of the cube texture
  8043. * @returns a cube texture
  8044. */
  8045. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8046. /**
  8047. * Makes a clone, or deep copy, of the cube texture
  8048. * @returns a new cube texture
  8049. */
  8050. clone(): CubeTexture;
  8051. }
  8052. }
  8053. declare module "babylonjs/Shaders/postprocess.vertex" {
  8054. /** @hidden */
  8055. export var postprocessVertexShader: {
  8056. name: string;
  8057. shader: string;
  8058. };
  8059. }
  8060. declare module "babylonjs/Cameras/targetCamera" {
  8061. import { Nullable } from "babylonjs/types";
  8062. import { Camera } from "babylonjs/Cameras/camera";
  8063. import { Scene } from "babylonjs/scene";
  8064. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8065. /**
  8066. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8067. * This is the base of the follow, arc rotate cameras and Free camera
  8068. * @see http://doc.babylonjs.com/features/cameras
  8069. */
  8070. export class TargetCamera extends Camera {
  8071. private static _RigCamTransformMatrix;
  8072. private static _TargetTransformMatrix;
  8073. private static _TargetFocalPoint;
  8074. /**
  8075. * Define the current direction the camera is moving to
  8076. */
  8077. cameraDirection: Vector3;
  8078. /**
  8079. * Define the current rotation the camera is rotating to
  8080. */
  8081. cameraRotation: Vector2;
  8082. /**
  8083. * When set, the up vector of the camera will be updated by the rotation of the camera
  8084. */
  8085. updateUpVectorFromRotation: boolean;
  8086. private _tmpQuaternion;
  8087. /**
  8088. * Define the current rotation of the camera
  8089. */
  8090. rotation: Vector3;
  8091. /**
  8092. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8093. */
  8094. rotationQuaternion: Quaternion;
  8095. /**
  8096. * Define the current speed of the camera
  8097. */
  8098. speed: number;
  8099. /**
  8100. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8101. * around all axis.
  8102. */
  8103. noRotationConstraint: boolean;
  8104. /**
  8105. * Define the current target of the camera as an object or a position.
  8106. */
  8107. lockedTarget: any;
  8108. /** @hidden */
  8109. _currentTarget: Vector3;
  8110. /** @hidden */
  8111. _initialFocalDistance: number;
  8112. /** @hidden */
  8113. _viewMatrix: Matrix;
  8114. /** @hidden */
  8115. _camMatrix: Matrix;
  8116. /** @hidden */
  8117. _cameraTransformMatrix: Matrix;
  8118. /** @hidden */
  8119. _cameraRotationMatrix: Matrix;
  8120. /** @hidden */
  8121. _referencePoint: Vector3;
  8122. /** @hidden */
  8123. _transformedReferencePoint: Vector3;
  8124. protected _globalCurrentTarget: Vector3;
  8125. protected _globalCurrentUpVector: Vector3;
  8126. /** @hidden */
  8127. _reset: () => void;
  8128. private _defaultUp;
  8129. /**
  8130. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8131. * This is the base of the follow, arc rotate cameras and Free camera
  8132. * @see http://doc.babylonjs.com/features/cameras
  8133. * @param name Defines the name of the camera in the scene
  8134. * @param position Defines the start position of the camera in the scene
  8135. * @param scene Defines the scene the camera belongs to
  8136. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8137. */
  8138. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8139. /**
  8140. * Gets the position in front of the camera at a given distance.
  8141. * @param distance The distance from the camera we want the position to be
  8142. * @returns the position
  8143. */
  8144. getFrontPosition(distance: number): Vector3;
  8145. /** @hidden */
  8146. _getLockedTargetPosition(): Nullable<Vector3>;
  8147. private _storedPosition;
  8148. private _storedRotation;
  8149. private _storedRotationQuaternion;
  8150. /**
  8151. * Store current camera state of the camera (fov, position, rotation, etc..)
  8152. * @returns the camera
  8153. */
  8154. storeState(): Camera;
  8155. /**
  8156. * Restored camera state. You must call storeState() first
  8157. * @returns whether it was successful or not
  8158. * @hidden
  8159. */
  8160. _restoreStateValues(): boolean;
  8161. /** @hidden */
  8162. _initCache(): void;
  8163. /** @hidden */
  8164. _updateCache(ignoreParentClass?: boolean): void;
  8165. /** @hidden */
  8166. _isSynchronizedViewMatrix(): boolean;
  8167. /** @hidden */
  8168. _computeLocalCameraSpeed(): number;
  8169. /** @hidden */
  8170. setTarget(target: Vector3): void;
  8171. /**
  8172. * Return the current target position of the camera. This value is expressed in local space.
  8173. * @returns the target position
  8174. */
  8175. getTarget(): Vector3;
  8176. /** @hidden */
  8177. _decideIfNeedsToMove(): boolean;
  8178. /** @hidden */
  8179. _updatePosition(): void;
  8180. /** @hidden */
  8181. _checkInputs(): void;
  8182. protected _updateCameraRotationMatrix(): void;
  8183. /**
  8184. * 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)
  8185. * @returns the current camera
  8186. */
  8187. private _rotateUpVectorWithCameraRotationMatrix;
  8188. private _cachedRotationZ;
  8189. private _cachedQuaternionRotationZ;
  8190. /** @hidden */
  8191. _getViewMatrix(): Matrix;
  8192. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8193. /**
  8194. * @hidden
  8195. */
  8196. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8197. /**
  8198. * @hidden
  8199. */
  8200. _updateRigCameras(): void;
  8201. private _getRigCamPositionAndTarget;
  8202. /**
  8203. * Gets the current object class name.
  8204. * @return the class name
  8205. */
  8206. getClassName(): string;
  8207. }
  8208. }
  8209. declare module "babylonjs/Cameras/cameraInputsManager" {
  8210. import { Nullable } from "babylonjs/types";
  8211. import { Camera } from "babylonjs/Cameras/camera";
  8212. /**
  8213. * @ignore
  8214. * This is a list of all the different input types that are available in the application.
  8215. * Fo instance: ArcRotateCameraGamepadInput...
  8216. */
  8217. export var CameraInputTypes: {};
  8218. /**
  8219. * This is the contract to implement in order to create a new input class.
  8220. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8221. */
  8222. export interface ICameraInput<TCamera extends Camera> {
  8223. /**
  8224. * Defines the camera the input is attached to.
  8225. */
  8226. camera: Nullable<TCamera>;
  8227. /**
  8228. * Gets the class name of the current intput.
  8229. * @returns the class name
  8230. */
  8231. getClassName(): string;
  8232. /**
  8233. * Get the friendly name associated with the input class.
  8234. * @returns the input friendly name
  8235. */
  8236. getSimpleName(): string;
  8237. /**
  8238. * Attach the input controls to a specific dom element to get the input from.
  8239. * @param element Defines the element the controls should be listened from
  8240. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8241. */
  8242. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8243. /**
  8244. * Detach the current controls from the specified dom element.
  8245. * @param element Defines the element to stop listening the inputs from
  8246. */
  8247. detachControl(element: Nullable<HTMLElement>): void;
  8248. /**
  8249. * Update the current camera state depending on the inputs that have been used this frame.
  8250. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8251. */
  8252. checkInputs?: () => void;
  8253. }
  8254. /**
  8255. * Represents a map of input types to input instance or input index to input instance.
  8256. */
  8257. export interface CameraInputsMap<TCamera extends Camera> {
  8258. /**
  8259. * Accessor to the input by input type.
  8260. */
  8261. [name: string]: ICameraInput<TCamera>;
  8262. /**
  8263. * Accessor to the input by input index.
  8264. */
  8265. [idx: number]: ICameraInput<TCamera>;
  8266. }
  8267. /**
  8268. * This represents the input manager used within a camera.
  8269. * It helps dealing with all the different kind of input attached to a camera.
  8270. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8271. */
  8272. export class CameraInputsManager<TCamera extends Camera> {
  8273. /**
  8274. * Defines the list of inputs attahed to the camera.
  8275. */
  8276. attached: CameraInputsMap<TCamera>;
  8277. /**
  8278. * Defines the dom element the camera is collecting inputs from.
  8279. * This is null if the controls have not been attached.
  8280. */
  8281. attachedElement: Nullable<HTMLElement>;
  8282. /**
  8283. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8284. */
  8285. noPreventDefault: boolean;
  8286. /**
  8287. * Defined the camera the input manager belongs to.
  8288. */
  8289. camera: TCamera;
  8290. /**
  8291. * Update the current camera state depending on the inputs that have been used this frame.
  8292. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8293. */
  8294. checkInputs: () => void;
  8295. /**
  8296. * Instantiate a new Camera Input Manager.
  8297. * @param camera Defines the camera the input manager blongs to
  8298. */
  8299. constructor(camera: TCamera);
  8300. /**
  8301. * Add an input method to a camera
  8302. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8303. * @param input camera input method
  8304. */
  8305. add(input: ICameraInput<TCamera>): void;
  8306. /**
  8307. * Remove a specific input method from a camera
  8308. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8309. * @param inputToRemove camera input method
  8310. */
  8311. remove(inputToRemove: ICameraInput<TCamera>): void;
  8312. /**
  8313. * Remove a specific input type from a camera
  8314. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8315. * @param inputType the type of the input to remove
  8316. */
  8317. removeByType(inputType: string): void;
  8318. private _addCheckInputs;
  8319. /**
  8320. * Attach the input controls to the currently attached dom element to listen the events from.
  8321. * @param input Defines the input to attach
  8322. */
  8323. attachInput(input: ICameraInput<TCamera>): void;
  8324. /**
  8325. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8326. * @param element Defines the dom element to collect the events from
  8327. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8328. */
  8329. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8330. /**
  8331. * Detach the current manager inputs controls from a specific dom element.
  8332. * @param element Defines the dom element to collect the events from
  8333. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8334. */
  8335. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8336. /**
  8337. * Rebuild the dynamic inputCheck function from the current list of
  8338. * defined inputs in the manager.
  8339. */
  8340. rebuildInputCheck(): void;
  8341. /**
  8342. * Remove all attached input methods from a camera
  8343. */
  8344. clear(): void;
  8345. /**
  8346. * Serialize the current input manager attached to a camera.
  8347. * This ensures than once parsed,
  8348. * the input associated to the camera will be identical to the current ones
  8349. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8350. */
  8351. serialize(serializedCamera: any): void;
  8352. /**
  8353. * Parses an input manager serialized JSON to restore the previous list of inputs
  8354. * and states associated to a camera.
  8355. * @param parsedCamera Defines the JSON to parse
  8356. */
  8357. parse(parsedCamera: any): void;
  8358. }
  8359. }
  8360. declare module "babylonjs/Events/keyboardEvents" {
  8361. /**
  8362. * Gather the list of keyboard event types as constants.
  8363. */
  8364. export class KeyboardEventTypes {
  8365. /**
  8366. * The keydown event is fired when a key becomes active (pressed).
  8367. */
  8368. static readonly KEYDOWN: number;
  8369. /**
  8370. * The keyup event is fired when a key has been released.
  8371. */
  8372. static readonly KEYUP: number;
  8373. }
  8374. /**
  8375. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8376. */
  8377. export class KeyboardInfo {
  8378. /**
  8379. * Defines the type of event (KeyboardEventTypes)
  8380. */
  8381. type: number;
  8382. /**
  8383. * Defines the related dom event
  8384. */
  8385. event: KeyboardEvent;
  8386. /**
  8387. * Instantiates a new keyboard info.
  8388. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8389. * @param type Defines the type of event (KeyboardEventTypes)
  8390. * @param event Defines the related dom event
  8391. */
  8392. constructor(
  8393. /**
  8394. * Defines the type of event (KeyboardEventTypes)
  8395. */
  8396. type: number,
  8397. /**
  8398. * Defines the related dom event
  8399. */
  8400. event: KeyboardEvent);
  8401. }
  8402. /**
  8403. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8404. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8405. */
  8406. export class KeyboardInfoPre extends KeyboardInfo {
  8407. /**
  8408. * Defines the type of event (KeyboardEventTypes)
  8409. */
  8410. type: number;
  8411. /**
  8412. * Defines the related dom event
  8413. */
  8414. event: KeyboardEvent;
  8415. /**
  8416. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8417. */
  8418. skipOnPointerObservable: boolean;
  8419. /**
  8420. * Instantiates a new keyboard pre info.
  8421. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8422. * @param type Defines the type of event (KeyboardEventTypes)
  8423. * @param event Defines the related dom event
  8424. */
  8425. constructor(
  8426. /**
  8427. * Defines the type of event (KeyboardEventTypes)
  8428. */
  8429. type: number,
  8430. /**
  8431. * Defines the related dom event
  8432. */
  8433. event: KeyboardEvent);
  8434. }
  8435. }
  8436. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8437. import { Nullable } from "babylonjs/types";
  8438. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8439. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8440. /**
  8441. * Manage the keyboard inputs to control the movement of a free camera.
  8442. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8443. */
  8444. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8445. /**
  8446. * Defines the camera the input is attached to.
  8447. */
  8448. camera: FreeCamera;
  8449. /**
  8450. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8451. */
  8452. keysUp: number[];
  8453. /**
  8454. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8455. */
  8456. keysDown: number[];
  8457. /**
  8458. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8459. */
  8460. keysLeft: number[];
  8461. /**
  8462. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8463. */
  8464. keysRight: number[];
  8465. private _keys;
  8466. private _onCanvasBlurObserver;
  8467. private _onKeyboardObserver;
  8468. private _engine;
  8469. private _scene;
  8470. /**
  8471. * Attach the input controls to a specific dom element to get the input from.
  8472. * @param element Defines the element the controls should be listened from
  8473. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8474. */
  8475. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8476. /**
  8477. * Detach the current controls from the specified dom element.
  8478. * @param element Defines the element to stop listening the inputs from
  8479. */
  8480. detachControl(element: Nullable<HTMLElement>): void;
  8481. /**
  8482. * Update the current camera state depending on the inputs that have been used this frame.
  8483. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8484. */
  8485. checkInputs(): void;
  8486. /**
  8487. * Gets the class name of the current intput.
  8488. * @returns the class name
  8489. */
  8490. getClassName(): string;
  8491. /** @hidden */
  8492. _onLostFocus(): void;
  8493. /**
  8494. * Get the friendly name associated with the input class.
  8495. * @returns the input friendly name
  8496. */
  8497. getSimpleName(): string;
  8498. }
  8499. }
  8500. declare module "babylonjs/Actions/actionEvent" {
  8501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8502. import { Nullable } from "babylonjs/types";
  8503. import { Sprite } from "babylonjs/Sprites/sprite";
  8504. import { Scene } from "babylonjs/scene";
  8505. import { Vector2 } from "babylonjs/Maths/math";
  8506. /**
  8507. * Interface used to define ActionEvent
  8508. */
  8509. export interface IActionEvent {
  8510. /** The mesh or sprite that triggered the action */
  8511. source: any;
  8512. /** The X mouse cursor position at the time of the event */
  8513. pointerX: number;
  8514. /** The Y mouse cursor position at the time of the event */
  8515. pointerY: number;
  8516. /** The mesh that is currently pointed at (can be null) */
  8517. meshUnderPointer: Nullable<AbstractMesh>;
  8518. /** the original (browser) event that triggered the ActionEvent */
  8519. sourceEvent?: any;
  8520. /** additional data for the event */
  8521. additionalData?: any;
  8522. }
  8523. /**
  8524. * ActionEvent is the event being sent when an action is triggered.
  8525. */
  8526. export class ActionEvent implements IActionEvent {
  8527. /** The mesh or sprite that triggered the action */
  8528. source: any;
  8529. /** The X mouse cursor position at the time of the event */
  8530. pointerX: number;
  8531. /** The Y mouse cursor position at the time of the event */
  8532. pointerY: number;
  8533. /** The mesh that is currently pointed at (can be null) */
  8534. meshUnderPointer: Nullable<AbstractMesh>;
  8535. /** the original (browser) event that triggered the ActionEvent */
  8536. sourceEvent?: any;
  8537. /** additional data for the event */
  8538. additionalData?: any;
  8539. /**
  8540. * Creates a new ActionEvent
  8541. * @param source The mesh or sprite that triggered the action
  8542. * @param pointerX The X mouse cursor position at the time of the event
  8543. * @param pointerY The Y mouse cursor position at the time of the event
  8544. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  8545. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  8546. * @param additionalData additional data for the event
  8547. */
  8548. constructor(
  8549. /** The mesh or sprite that triggered the action */
  8550. source: any,
  8551. /** The X mouse cursor position at the time of the event */
  8552. pointerX: number,
  8553. /** The Y mouse cursor position at the time of the event */
  8554. pointerY: number,
  8555. /** The mesh that is currently pointed at (can be null) */
  8556. meshUnderPointer: Nullable<AbstractMesh>,
  8557. /** the original (browser) event that triggered the ActionEvent */
  8558. sourceEvent?: any,
  8559. /** additional data for the event */
  8560. additionalData?: any);
  8561. /**
  8562. * Helper function to auto-create an ActionEvent from a source mesh.
  8563. * @param source The source mesh that triggered the event
  8564. * @param evt The original (browser) event
  8565. * @param additionalData additional data for the event
  8566. * @returns the new ActionEvent
  8567. */
  8568. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  8569. /**
  8570. * Helper function to auto-create an ActionEvent from a source sprite
  8571. * @param source The source sprite that triggered the event
  8572. * @param scene Scene associated with the sprite
  8573. * @param evt The original (browser) event
  8574. * @param additionalData additional data for the event
  8575. * @returns the new ActionEvent
  8576. */
  8577. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  8578. /**
  8579. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  8580. * @param scene the scene where the event occurred
  8581. * @param evt The original (browser) event
  8582. * @returns the new ActionEvent
  8583. */
  8584. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  8585. /**
  8586. * Helper function to auto-create an ActionEvent from a primitive
  8587. * @param prim defines the target primitive
  8588. * @param pointerPos defines the pointer position
  8589. * @param evt The original (browser) event
  8590. * @param additionalData additional data for the event
  8591. * @returns the new ActionEvent
  8592. */
  8593. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  8594. }
  8595. }
  8596. declare module "babylonjs/Lights/shadowLight" {
  8597. import { Camera } from "babylonjs/Cameras/camera";
  8598. import { Scene } from "babylonjs/scene";
  8599. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8601. import { Light } from "babylonjs/Lights/light";
  8602. /**
  8603. * Interface describing all the common properties and methods a shadow light needs to implement.
  8604. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8605. * as well as binding the different shadow properties to the effects.
  8606. */
  8607. export interface IShadowLight extends Light {
  8608. /**
  8609. * The light id in the scene (used in scene.findLighById for instance)
  8610. */
  8611. id: string;
  8612. /**
  8613. * The position the shdow will be casted from.
  8614. */
  8615. position: Vector3;
  8616. /**
  8617. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8618. */
  8619. direction: Vector3;
  8620. /**
  8621. * The transformed position. Position of the light in world space taking parenting in account.
  8622. */
  8623. transformedPosition: Vector3;
  8624. /**
  8625. * The transformed direction. Direction of the light in world space taking parenting in account.
  8626. */
  8627. transformedDirection: Vector3;
  8628. /**
  8629. * The friendly name of the light in the scene.
  8630. */
  8631. name: string;
  8632. /**
  8633. * Defines the shadow projection clipping minimum z value.
  8634. */
  8635. shadowMinZ: number;
  8636. /**
  8637. * Defines the shadow projection clipping maximum z value.
  8638. */
  8639. shadowMaxZ: number;
  8640. /**
  8641. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8642. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8643. */
  8644. computeTransformedInformation(): boolean;
  8645. /**
  8646. * Gets the scene the light belongs to.
  8647. * @returns The scene
  8648. */
  8649. getScene(): Scene;
  8650. /**
  8651. * Callback defining a custom Projection Matrix Builder.
  8652. * This can be used to override the default projection matrix computation.
  8653. */
  8654. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8655. /**
  8656. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8657. * @param matrix The materix to updated with the projection information
  8658. * @param viewMatrix The transform matrix of the light
  8659. * @param renderList The list of mesh to render in the map
  8660. * @returns The current light
  8661. */
  8662. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8663. /**
  8664. * Gets the current depth scale used in ESM.
  8665. * @returns The scale
  8666. */
  8667. getDepthScale(): number;
  8668. /**
  8669. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8670. * @returns true if a cube texture needs to be use
  8671. */
  8672. needCube(): boolean;
  8673. /**
  8674. * Detects if the projection matrix requires to be recomputed this frame.
  8675. * @returns true if it requires to be recomputed otherwise, false.
  8676. */
  8677. needProjectionMatrixCompute(): boolean;
  8678. /**
  8679. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8680. */
  8681. forceProjectionMatrixCompute(): void;
  8682. /**
  8683. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8684. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8685. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8686. */
  8687. getShadowDirection(faceIndex?: number): Vector3;
  8688. /**
  8689. * Gets the minZ used for shadow according to both the scene and the light.
  8690. * @param activeCamera The camera we are returning the min for
  8691. * @returns the depth min z
  8692. */
  8693. getDepthMinZ(activeCamera: Camera): number;
  8694. /**
  8695. * Gets the maxZ used for shadow according to both the scene and the light.
  8696. * @param activeCamera The camera we are returning the max for
  8697. * @returns the depth max z
  8698. */
  8699. getDepthMaxZ(activeCamera: Camera): number;
  8700. }
  8701. /**
  8702. * Base implementation IShadowLight
  8703. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8704. */
  8705. export abstract class ShadowLight extends Light implements IShadowLight {
  8706. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8707. protected _position: Vector3;
  8708. protected _setPosition(value: Vector3): void;
  8709. /**
  8710. * Sets the position the shadow will be casted from. Also use as the light position for both
  8711. * point and spot lights.
  8712. */
  8713. /**
  8714. * Sets the position the shadow will be casted from. Also use as the light position for both
  8715. * point and spot lights.
  8716. */
  8717. position: Vector3;
  8718. protected _direction: Vector3;
  8719. protected _setDirection(value: Vector3): void;
  8720. /**
  8721. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8722. * Also use as the light direction on spot and directional lights.
  8723. */
  8724. /**
  8725. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8726. * Also use as the light direction on spot and directional lights.
  8727. */
  8728. direction: Vector3;
  8729. private _shadowMinZ;
  8730. /**
  8731. * Gets the shadow projection clipping minimum z value.
  8732. */
  8733. /**
  8734. * Sets the shadow projection clipping minimum z value.
  8735. */
  8736. shadowMinZ: number;
  8737. private _shadowMaxZ;
  8738. /**
  8739. * Sets the shadow projection clipping maximum z value.
  8740. */
  8741. /**
  8742. * Gets the shadow projection clipping maximum z value.
  8743. */
  8744. shadowMaxZ: number;
  8745. /**
  8746. * Callback defining a custom Projection Matrix Builder.
  8747. * This can be used to override the default projection matrix computation.
  8748. */
  8749. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8750. /**
  8751. * The transformed position. Position of the light in world space taking parenting in account.
  8752. */
  8753. transformedPosition: Vector3;
  8754. /**
  8755. * The transformed direction. Direction of the light in world space taking parenting in account.
  8756. */
  8757. transformedDirection: Vector3;
  8758. private _needProjectionMatrixCompute;
  8759. /**
  8760. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8761. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8762. */
  8763. computeTransformedInformation(): boolean;
  8764. /**
  8765. * Return the depth scale used for the shadow map.
  8766. * @returns the depth scale.
  8767. */
  8768. getDepthScale(): number;
  8769. /**
  8770. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8771. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8772. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8773. */
  8774. getShadowDirection(faceIndex?: number): Vector3;
  8775. /**
  8776. * Returns the ShadowLight absolute position in the World.
  8777. * @returns the position vector in world space
  8778. */
  8779. getAbsolutePosition(): Vector3;
  8780. /**
  8781. * Sets the ShadowLight direction toward the passed target.
  8782. * @param target The point tot target in local space
  8783. * @returns the updated ShadowLight direction
  8784. */
  8785. setDirectionToTarget(target: Vector3): Vector3;
  8786. /**
  8787. * Returns the light rotation in euler definition.
  8788. * @returns the x y z rotation in local space.
  8789. */
  8790. getRotation(): Vector3;
  8791. /**
  8792. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8793. * @returns true if a cube texture needs to be use
  8794. */
  8795. needCube(): boolean;
  8796. /**
  8797. * Detects if the projection matrix requires to be recomputed this frame.
  8798. * @returns true if it requires to be recomputed otherwise, false.
  8799. */
  8800. needProjectionMatrixCompute(): boolean;
  8801. /**
  8802. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8803. */
  8804. forceProjectionMatrixCompute(): void;
  8805. /** @hidden */
  8806. _initCache(): void;
  8807. /** @hidden */
  8808. _isSynchronized(): boolean;
  8809. /**
  8810. * Computes the world matrix of the node
  8811. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8812. * @returns the world matrix
  8813. */
  8814. computeWorldMatrix(force?: boolean): Matrix;
  8815. /**
  8816. * Gets the minZ used for shadow according to both the scene and the light.
  8817. * @param activeCamera The camera we are returning the min for
  8818. * @returns the depth min z
  8819. */
  8820. getDepthMinZ(activeCamera: Camera): number;
  8821. /**
  8822. * Gets the maxZ used for shadow according to both the scene and the light.
  8823. * @param activeCamera The camera we are returning the max for
  8824. * @returns the depth max z
  8825. */
  8826. getDepthMaxZ(activeCamera: Camera): number;
  8827. /**
  8828. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8829. * @param matrix The materix to updated with the projection information
  8830. * @param viewMatrix The transform matrix of the light
  8831. * @param renderList The list of mesh to render in the map
  8832. * @returns The current light
  8833. */
  8834. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8835. }
  8836. }
  8837. declare module "babylonjs/Materials/materialHelper" {
  8838. import { Nullable } from "babylonjs/types";
  8839. import { Scene } from "babylonjs/scene";
  8840. import { Engine } from "babylonjs/Engines/engine";
  8841. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8842. import { Light } from "babylonjs/Lights/light";
  8843. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8844. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8845. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8846. /**
  8847. * "Static Class" containing the most commonly used helper while dealing with material for
  8848. * rendering purpose.
  8849. *
  8850. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8851. *
  8852. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8853. */
  8854. export class MaterialHelper {
  8855. /**
  8856. * Bind the current view position to an effect.
  8857. * @param effect The effect to be bound
  8858. * @param scene The scene the eyes position is used from
  8859. */
  8860. static BindEyePosition(effect: Effect, scene: Scene): void;
  8861. /**
  8862. * Helps preparing the defines values about the UVs in used in the effect.
  8863. * UVs are shared as much as we can accross channels in the shaders.
  8864. * @param texture The texture we are preparing the UVs for
  8865. * @param defines The defines to update
  8866. * @param key The channel key "diffuse", "specular"... used in the shader
  8867. */
  8868. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8869. /**
  8870. * Binds a texture matrix value to its corrsponding uniform
  8871. * @param texture The texture to bind the matrix for
  8872. * @param uniformBuffer The uniform buffer receivin the data
  8873. * @param key The channel key "diffuse", "specular"... used in the shader
  8874. */
  8875. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8876. /**
  8877. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8878. * @param mesh defines the current mesh
  8879. * @param scene defines the current scene
  8880. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8881. * @param pointsCloud defines if point cloud rendering has to be turned on
  8882. * @param fogEnabled defines if fog has to be turned on
  8883. * @param alphaTest defines if alpha testing has to be turned on
  8884. * @param defines defines the current list of defines
  8885. */
  8886. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8887. /**
  8888. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8889. * @param scene defines the current scene
  8890. * @param engine defines the current engine
  8891. * @param defines specifies the list of active defines
  8892. * @param useInstances defines if instances have to be turned on
  8893. * @param useClipPlane defines if clip plane have to be turned on
  8894. */
  8895. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8896. /**
  8897. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8898. * @param mesh The mesh containing the geometry data we will draw
  8899. * @param defines The defines to update
  8900. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8901. * @param useBones Precise whether bones should be used or not (override mesh info)
  8902. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8903. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8904. * @returns false if defines are considered not dirty and have not been checked
  8905. */
  8906. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8907. /**
  8908. * Prepares the defines related to the light information passed in parameter
  8909. * @param scene The scene we are intending to draw
  8910. * @param mesh The mesh the effect is compiling for
  8911. * @param defines The defines to update
  8912. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8913. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8914. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8915. * @returns true if normals will be required for the rest of the effect
  8916. */
  8917. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8918. /**
  8919. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  8920. * that won t be acctive due to defines being turned off.
  8921. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8922. * @param samplersList The samplers list
  8923. * @param defines The defines helping in the list generation
  8924. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8925. */
  8926. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8927. /**
  8928. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8929. * @param defines The defines to update while falling back
  8930. * @param fallbacks The authorized effect fallbacks
  8931. * @param maxSimultaneousLights The maximum number of lights allowed
  8932. * @param rank the current rank of the Effect
  8933. * @returns The newly affected rank
  8934. */
  8935. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8936. /**
  8937. * Prepares the list of attributes required for morph targets according to the effect defines.
  8938. * @param attribs The current list of supported attribs
  8939. * @param mesh The mesh to prepare the morph targets attributes for
  8940. * @param defines The current Defines of the effect
  8941. */
  8942. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8943. /**
  8944. * Prepares the list of attributes required for bones according to the effect defines.
  8945. * @param attribs The current list of supported attribs
  8946. * @param mesh The mesh to prepare the bones attributes for
  8947. * @param defines The current Defines of the effect
  8948. * @param fallbacks The current efffect fallback strategy
  8949. */
  8950. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8951. /**
  8952. * Prepares the list of attributes required for instances according to the effect defines.
  8953. * @param attribs The current list of supported attribs
  8954. * @param defines The current Defines of the effect
  8955. */
  8956. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  8957. /**
  8958. * Binds the light shadow information to the effect for the given mesh.
  8959. * @param light The light containing the generator
  8960. * @param scene The scene the lights belongs to
  8961. * @param mesh The mesh we are binding the information to render
  8962. * @param lightIndex The light index in the effect used to render the mesh
  8963. * @param effect The effect we are binding the data to
  8964. */
  8965. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8966. /**
  8967. * Binds the light information to the effect.
  8968. * @param light The light containing the generator
  8969. * @param effect The effect we are binding the data to
  8970. * @param lightIndex The light index in the effect used to render
  8971. */
  8972. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8973. /**
  8974. * Binds the lights information from the scene to the effect for the given mesh.
  8975. * @param scene The scene the lights belongs to
  8976. * @param mesh The mesh we are binding the information to render
  8977. * @param effect The effect we are binding the data to
  8978. * @param defines The generated defines for the effect
  8979. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8980. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8981. */
  8982. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  8983. private static _tempFogColor;
  8984. /**
  8985. * Binds the fog information from the scene to the effect for the given mesh.
  8986. * @param scene The scene the lights belongs to
  8987. * @param mesh The mesh we are binding the information to render
  8988. * @param effect The effect we are binding the data to
  8989. * @param linearSpace Defines if the fog effect is applied in linear space
  8990. */
  8991. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8992. /**
  8993. * Binds the bones information from the mesh to the effect.
  8994. * @param mesh The mesh we are binding the information to render
  8995. * @param effect The effect we are binding the data to
  8996. */
  8997. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8998. /**
  8999. * Binds the morph targets information from the mesh to the effect.
  9000. * @param abstractMesh The mesh we are binding the information to render
  9001. * @param effect The effect we are binding the data to
  9002. */
  9003. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9004. /**
  9005. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9006. * @param defines The generated defines used in the effect
  9007. * @param effect The effect we are binding the data to
  9008. * @param scene The scene we are willing to render with logarithmic scale for
  9009. */
  9010. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9011. /**
  9012. * Binds the clip plane information from the scene to the effect.
  9013. * @param scene The scene the clip plane information are extracted from
  9014. * @param effect The effect we are binding the data to
  9015. */
  9016. static BindClipPlane(effect: Effect, scene: Scene): void;
  9017. }
  9018. }
  9019. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9020. /** @hidden */
  9021. export var kernelBlurVaryingDeclaration: {
  9022. name: string;
  9023. shader: string;
  9024. };
  9025. }
  9026. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9027. /** @hidden */
  9028. export var kernelBlurFragment: {
  9029. name: string;
  9030. shader: string;
  9031. };
  9032. }
  9033. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9034. /** @hidden */
  9035. export var kernelBlurFragment2: {
  9036. name: string;
  9037. shader: string;
  9038. };
  9039. }
  9040. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9041. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9042. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9043. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9044. /** @hidden */
  9045. export var kernelBlurPixelShader: {
  9046. name: string;
  9047. shader: string;
  9048. };
  9049. }
  9050. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9051. /** @hidden */
  9052. export var kernelBlurVertex: {
  9053. name: string;
  9054. shader: string;
  9055. };
  9056. }
  9057. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9058. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9059. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9060. /** @hidden */
  9061. export var kernelBlurVertexShader: {
  9062. name: string;
  9063. shader: string;
  9064. };
  9065. }
  9066. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9067. import { Vector2 } from "babylonjs/Maths/math";
  9068. import { Nullable } from "babylonjs/types";
  9069. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9070. import { Camera } from "babylonjs/Cameras/camera";
  9071. import { Effect } from "babylonjs/Materials/effect";
  9072. import { Engine } from "babylonjs/Engines/engine";
  9073. import "babylonjs/Shaders/kernelBlur.fragment";
  9074. import "babylonjs/Shaders/kernelBlur.vertex";
  9075. /**
  9076. * The Blur Post Process which blurs an image based on a kernel and direction.
  9077. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9078. */
  9079. export class BlurPostProcess extends PostProcess {
  9080. /** The direction in which to blur the image. */
  9081. direction: Vector2;
  9082. private blockCompilation;
  9083. protected _kernel: number;
  9084. protected _idealKernel: number;
  9085. protected _packedFloat: boolean;
  9086. private _staticDefines;
  9087. /**
  9088. * Sets the length in pixels of the blur sample region
  9089. */
  9090. /**
  9091. * Gets the length in pixels of the blur sample region
  9092. */
  9093. kernel: number;
  9094. /**
  9095. * Sets wether or not the blur needs to unpack/repack floats
  9096. */
  9097. /**
  9098. * Gets wether or not the blur is unpacking/repacking floats
  9099. */
  9100. packedFloat: boolean;
  9101. /**
  9102. * Creates a new instance BlurPostProcess
  9103. * @param name The name of the effect.
  9104. * @param direction The direction in which to blur the image.
  9105. * @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.
  9106. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9107. * @param camera The camera to apply the render pass to.
  9108. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9109. * @param engine The engine which the post process will be applied. (default: current engine)
  9110. * @param reusable If the post process can be reused on the same frame. (default: false)
  9111. * @param textureType Type of textures used when performing the post process. (default: 0)
  9112. * @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)
  9113. */
  9114. constructor(name: string,
  9115. /** The direction in which to blur the image. */
  9116. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9117. /**
  9118. * Updates the effect with the current post process compile time values and recompiles the shader.
  9119. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9120. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9121. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9122. * @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
  9123. * @param onCompiled Called when the shader has been compiled.
  9124. * @param onError Called if there is an error when compiling a shader.
  9125. */
  9126. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9127. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9128. /**
  9129. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9130. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9131. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9132. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9133. * The gaps between physical kernels are compensated for in the weighting of the samples
  9134. * @param idealKernel Ideal blur kernel.
  9135. * @return Nearest best kernel.
  9136. */
  9137. protected _nearestBestKernel(idealKernel: number): number;
  9138. /**
  9139. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9140. * @param x The point on the Gaussian distribution to sample.
  9141. * @return the value of the Gaussian function at x.
  9142. */
  9143. protected _gaussianWeight(x: number): number;
  9144. /**
  9145. * Generates a string that can be used as a floating point number in GLSL.
  9146. * @param x Value to print.
  9147. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9148. * @return GLSL float string.
  9149. */
  9150. protected _glslFloat(x: number, decimalFigures?: number): string;
  9151. }
  9152. }
  9153. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9154. /** @hidden */
  9155. export var shadowMapPixelShader: {
  9156. name: string;
  9157. shader: string;
  9158. };
  9159. }
  9160. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9161. /** @hidden */
  9162. export var bonesDeclaration: {
  9163. name: string;
  9164. shader: string;
  9165. };
  9166. }
  9167. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9168. /** @hidden */
  9169. export var morphTargetsVertexGlobalDeclaration: {
  9170. name: string;
  9171. shader: string;
  9172. };
  9173. }
  9174. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9175. /** @hidden */
  9176. export var morphTargetsVertexDeclaration: {
  9177. name: string;
  9178. shader: string;
  9179. };
  9180. }
  9181. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9182. /** @hidden */
  9183. export var instancesDeclaration: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9189. /** @hidden */
  9190. export var helperFunctions: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9196. /** @hidden */
  9197. export var morphTargetsVertex: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9203. /** @hidden */
  9204. export var instancesVertex: {
  9205. name: string;
  9206. shader: string;
  9207. };
  9208. }
  9209. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9210. /** @hidden */
  9211. export var bonesVertex: {
  9212. name: string;
  9213. shader: string;
  9214. };
  9215. }
  9216. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9217. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9218. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9219. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9220. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9221. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9222. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9223. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9224. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9225. /** @hidden */
  9226. export var shadowMapVertexShader: {
  9227. name: string;
  9228. shader: string;
  9229. };
  9230. }
  9231. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9232. /** @hidden */
  9233. export var depthBoxBlurPixelShader: {
  9234. name: string;
  9235. shader: string;
  9236. };
  9237. }
  9238. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9239. import { Nullable } from "babylonjs/types";
  9240. import { Scene } from "babylonjs/scene";
  9241. import { Matrix } from "babylonjs/Maths/math";
  9242. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9244. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9245. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9246. import { Effect } from "babylonjs/Materials/effect";
  9247. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9248. import "babylonjs/Shaders/shadowMap.fragment";
  9249. import "babylonjs/Shaders/shadowMap.vertex";
  9250. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9251. import { Observable } from "babylonjs/Misc/observable";
  9252. /**
  9253. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9254. */
  9255. export interface ICustomShaderOptions {
  9256. /**
  9257. * Gets or sets the custom shader name to use
  9258. */
  9259. shaderName: string;
  9260. /**
  9261. * The list of attribute names used in the shader
  9262. */
  9263. attributes?: string[];
  9264. /**
  9265. * The list of unifrom names used in the shader
  9266. */
  9267. uniforms?: string[];
  9268. /**
  9269. * The list of sampler names used in the shader
  9270. */
  9271. samplers?: string[];
  9272. /**
  9273. * The list of defines used in the shader
  9274. */
  9275. defines?: string[];
  9276. }
  9277. /**
  9278. * Interface to implement to create a shadow generator compatible with BJS.
  9279. */
  9280. export interface IShadowGenerator {
  9281. /**
  9282. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9283. * @returns The render target texture if present otherwise, null
  9284. */
  9285. getShadowMap(): Nullable<RenderTargetTexture>;
  9286. /**
  9287. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9288. * @returns The render target texture if the shadow map is present otherwise, null
  9289. */
  9290. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9291. /**
  9292. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9293. * @param subMesh The submesh we want to render in the shadow map
  9294. * @param useInstances Defines wether will draw in the map using instances
  9295. * @returns true if ready otherwise, false
  9296. */
  9297. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9298. /**
  9299. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9300. * @param defines Defines of the material we want to update
  9301. * @param lightIndex Index of the light in the enabled light list of the material
  9302. */
  9303. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9304. /**
  9305. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9306. * defined in the generator but impacting the effect).
  9307. * It implies the unifroms available on the materials are the standard BJS ones.
  9308. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9309. * @param effect The effect we are binfing the information for
  9310. */
  9311. bindShadowLight(lightIndex: string, effect: Effect): void;
  9312. /**
  9313. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9314. * (eq to shadow prjection matrix * light transform matrix)
  9315. * @returns The transform matrix used to create the shadow map
  9316. */
  9317. getTransformMatrix(): Matrix;
  9318. /**
  9319. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9320. * Cube and 2D textures for instance.
  9321. */
  9322. recreateShadowMap(): void;
  9323. /**
  9324. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9325. * @param onCompiled Callback triggered at the and of the effects compilation
  9326. * @param options Sets of optional options forcing the compilation with different modes
  9327. */
  9328. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9329. useInstances: boolean;
  9330. }>): void;
  9331. /**
  9332. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9333. * @param options Sets of optional options forcing the compilation with different modes
  9334. * @returns A promise that resolves when the compilation completes
  9335. */
  9336. forceCompilationAsync(options?: Partial<{
  9337. useInstances: boolean;
  9338. }>): Promise<void>;
  9339. /**
  9340. * Serializes the shadow generator setup to a json object.
  9341. * @returns The serialized JSON object
  9342. */
  9343. serialize(): any;
  9344. /**
  9345. * Disposes the Shadow map and related Textures and effects.
  9346. */
  9347. dispose(): void;
  9348. }
  9349. /**
  9350. * Default implementation IShadowGenerator.
  9351. * This is the main object responsible of generating shadows in the framework.
  9352. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9353. */
  9354. export class ShadowGenerator implements IShadowGenerator {
  9355. /**
  9356. * Shadow generator mode None: no filtering applied.
  9357. */
  9358. static readonly FILTER_NONE: number;
  9359. /**
  9360. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9361. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9362. */
  9363. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9364. /**
  9365. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9366. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9367. */
  9368. static readonly FILTER_POISSONSAMPLING: number;
  9369. /**
  9370. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9371. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9372. */
  9373. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9374. /**
  9375. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9376. * edge artifacts on steep falloff.
  9377. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9378. */
  9379. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9380. /**
  9381. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9382. * edge artifacts on steep falloff.
  9383. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9384. */
  9385. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9386. /**
  9387. * Shadow generator mode PCF: Percentage Closer Filtering
  9388. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9389. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9390. */
  9391. static readonly FILTER_PCF: number;
  9392. /**
  9393. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9394. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9395. * Contact Hardening
  9396. */
  9397. static readonly FILTER_PCSS: number;
  9398. /**
  9399. * Reserved for PCF and PCSS
  9400. * Highest Quality.
  9401. *
  9402. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9403. *
  9404. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9405. */
  9406. static readonly QUALITY_HIGH: number;
  9407. /**
  9408. * Reserved for PCF and PCSS
  9409. * Good tradeoff for quality/perf cross devices
  9410. *
  9411. * Execute PCF on a 3*3 kernel.
  9412. *
  9413. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9414. */
  9415. static readonly QUALITY_MEDIUM: number;
  9416. /**
  9417. * Reserved for PCF and PCSS
  9418. * The lowest quality but the fastest.
  9419. *
  9420. * Execute PCF on a 1*1 kernel.
  9421. *
  9422. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9423. */
  9424. static readonly QUALITY_LOW: number;
  9425. /** Gets or sets the custom shader name to use */
  9426. customShaderOptions: ICustomShaderOptions;
  9427. /**
  9428. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9429. */
  9430. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9431. private _bias;
  9432. /**
  9433. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9434. */
  9435. /**
  9436. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9437. */
  9438. bias: number;
  9439. private _normalBias;
  9440. /**
  9441. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9442. */
  9443. /**
  9444. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9445. */
  9446. normalBias: number;
  9447. private _blurBoxOffset;
  9448. /**
  9449. * Gets the blur box offset: offset applied during the blur pass.
  9450. * Only useful if useKernelBlur = false
  9451. */
  9452. /**
  9453. * Sets the blur box offset: offset applied during the blur pass.
  9454. * Only useful if useKernelBlur = false
  9455. */
  9456. blurBoxOffset: number;
  9457. private _blurScale;
  9458. /**
  9459. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9460. * 2 means half of the size.
  9461. */
  9462. /**
  9463. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9464. * 2 means half of the size.
  9465. */
  9466. blurScale: number;
  9467. private _blurKernel;
  9468. /**
  9469. * Gets the blur kernel: kernel size of the blur pass.
  9470. * Only useful if useKernelBlur = true
  9471. */
  9472. /**
  9473. * Sets the blur kernel: kernel size of the blur pass.
  9474. * Only useful if useKernelBlur = true
  9475. */
  9476. blurKernel: number;
  9477. private _useKernelBlur;
  9478. /**
  9479. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9480. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9481. */
  9482. /**
  9483. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9484. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9485. */
  9486. useKernelBlur: boolean;
  9487. private _depthScale;
  9488. /**
  9489. * Gets the depth scale used in ESM mode.
  9490. */
  9491. /**
  9492. * Sets the depth scale used in ESM mode.
  9493. * This can override the scale stored on the light.
  9494. */
  9495. depthScale: number;
  9496. private _filter;
  9497. /**
  9498. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9499. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9500. */
  9501. /**
  9502. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9503. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9504. */
  9505. filter: number;
  9506. /**
  9507. * Gets if the current filter is set to Poisson Sampling.
  9508. */
  9509. /**
  9510. * Sets the current filter to Poisson Sampling.
  9511. */
  9512. usePoissonSampling: boolean;
  9513. /**
  9514. * Gets if the current filter is set to ESM.
  9515. */
  9516. /**
  9517. * Sets the current filter is to ESM.
  9518. */
  9519. useExponentialShadowMap: boolean;
  9520. /**
  9521. * Gets if the current filter is set to filtered ESM.
  9522. */
  9523. /**
  9524. * Gets if the current filter is set to filtered ESM.
  9525. */
  9526. useBlurExponentialShadowMap: boolean;
  9527. /**
  9528. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9529. * exponential to prevent steep falloff artifacts).
  9530. */
  9531. /**
  9532. * Sets the current filter to "close ESM" (using the inverse of the
  9533. * exponential to prevent steep falloff artifacts).
  9534. */
  9535. useCloseExponentialShadowMap: boolean;
  9536. /**
  9537. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9538. * exponential to prevent steep falloff artifacts).
  9539. */
  9540. /**
  9541. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9542. * exponential to prevent steep falloff artifacts).
  9543. */
  9544. useBlurCloseExponentialShadowMap: boolean;
  9545. /**
  9546. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9547. */
  9548. /**
  9549. * Sets the current filter to "PCF" (percentage closer filtering).
  9550. */
  9551. usePercentageCloserFiltering: boolean;
  9552. private _filteringQuality;
  9553. /**
  9554. * Gets the PCF or PCSS Quality.
  9555. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9556. */
  9557. /**
  9558. * Sets the PCF or PCSS Quality.
  9559. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9560. */
  9561. filteringQuality: number;
  9562. /**
  9563. * Gets if the current filter is set to "PCSS" (contact hardening).
  9564. */
  9565. /**
  9566. * Sets the current filter to "PCSS" (contact hardening).
  9567. */
  9568. useContactHardeningShadow: boolean;
  9569. private _contactHardeningLightSizeUVRatio;
  9570. /**
  9571. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9572. * Using a ratio helps keeping shape stability independently of the map size.
  9573. *
  9574. * It does not account for the light projection as it was having too much
  9575. * instability during the light setup or during light position changes.
  9576. *
  9577. * Only valid if useContactHardeningShadow is true.
  9578. */
  9579. /**
  9580. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9581. * Using a ratio helps keeping shape stability independently of the map size.
  9582. *
  9583. * It does not account for the light projection as it was having too much
  9584. * instability during the light setup or during light position changes.
  9585. *
  9586. * Only valid if useContactHardeningShadow is true.
  9587. */
  9588. contactHardeningLightSizeUVRatio: number;
  9589. private _darkness;
  9590. /**
  9591. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9592. * 0 means strongest and 1 would means no shadow.
  9593. * @returns the darkness.
  9594. */
  9595. getDarkness(): number;
  9596. /**
  9597. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9598. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9599. * @returns the shadow generator allowing fluent coding.
  9600. */
  9601. setDarkness(darkness: number): ShadowGenerator;
  9602. private _transparencyShadow;
  9603. /**
  9604. * Sets the ability to have transparent shadow (boolean).
  9605. * @param transparent True if transparent else False
  9606. * @returns the shadow generator allowing fluent coding
  9607. */
  9608. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9609. private _shadowMap;
  9610. private _shadowMap2;
  9611. /**
  9612. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9613. * @returns The render target texture if present otherwise, null
  9614. */
  9615. getShadowMap(): Nullable<RenderTargetTexture>;
  9616. /**
  9617. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9618. * @returns The render target texture if the shadow map is present otherwise, null
  9619. */
  9620. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9621. /**
  9622. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9623. * @param mesh Mesh to add
  9624. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9625. * @returns the Shadow Generator itself
  9626. */
  9627. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9628. /**
  9629. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9630. * @param mesh Mesh to remove
  9631. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9632. * @returns the Shadow Generator itself
  9633. */
  9634. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9635. /**
  9636. * Controls the extent to which the shadows fade out at the edge of the frustum
  9637. * Used only by directionals and spots
  9638. */
  9639. frustumEdgeFalloff: number;
  9640. private _light;
  9641. /**
  9642. * Returns the associated light object.
  9643. * @returns the light generating the shadow
  9644. */
  9645. getLight(): IShadowLight;
  9646. /**
  9647. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9648. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9649. * It might on the other hand introduce peter panning.
  9650. */
  9651. forceBackFacesOnly: boolean;
  9652. private _scene;
  9653. private _lightDirection;
  9654. private _effect;
  9655. private _viewMatrix;
  9656. private _projectionMatrix;
  9657. private _transformMatrix;
  9658. private _cachedPosition;
  9659. private _cachedDirection;
  9660. private _cachedDefines;
  9661. private _currentRenderID;
  9662. private _boxBlurPostprocess;
  9663. private _kernelBlurXPostprocess;
  9664. private _kernelBlurYPostprocess;
  9665. private _blurPostProcesses;
  9666. private _mapSize;
  9667. private _currentFaceIndex;
  9668. private _currentFaceIndexCache;
  9669. private _textureType;
  9670. private _defaultTextureMatrix;
  9671. /** @hidden */
  9672. static _SceneComponentInitialization: (scene: Scene) => void;
  9673. /**
  9674. * Creates a ShadowGenerator object.
  9675. * A ShadowGenerator is the required tool to use the shadows.
  9676. * Each light casting shadows needs to use its own ShadowGenerator.
  9677. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9678. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9679. * @param light The light object generating the shadows.
  9680. * @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.
  9681. */
  9682. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9683. private _initializeGenerator;
  9684. private _initializeShadowMap;
  9685. private _initializeBlurRTTAndPostProcesses;
  9686. private _renderForShadowMap;
  9687. private _renderSubMeshForShadowMap;
  9688. private _applyFilterValues;
  9689. /**
  9690. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9691. * @param onCompiled Callback triggered at the and of the effects compilation
  9692. * @param options Sets of optional options forcing the compilation with different modes
  9693. */
  9694. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9695. useInstances: boolean;
  9696. }>): void;
  9697. /**
  9698. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9699. * @param options Sets of optional options forcing the compilation with different modes
  9700. * @returns A promise that resolves when the compilation completes
  9701. */
  9702. forceCompilationAsync(options?: Partial<{
  9703. useInstances: boolean;
  9704. }>): Promise<void>;
  9705. /**
  9706. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9707. * @param subMesh The submesh we want to render in the shadow map
  9708. * @param useInstances Defines wether will draw in the map using instances
  9709. * @returns true if ready otherwise, false
  9710. */
  9711. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9712. /**
  9713. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9714. * @param defines Defines of the material we want to update
  9715. * @param lightIndex Index of the light in the enabled light list of the material
  9716. */
  9717. prepareDefines(defines: any, lightIndex: number): void;
  9718. /**
  9719. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9720. * defined in the generator but impacting the effect).
  9721. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9722. * @param effect The effect we are binfing the information for
  9723. */
  9724. bindShadowLight(lightIndex: string, effect: Effect): void;
  9725. /**
  9726. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9727. * (eq to shadow prjection matrix * light transform matrix)
  9728. * @returns The transform matrix used to create the shadow map
  9729. */
  9730. getTransformMatrix(): Matrix;
  9731. /**
  9732. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9733. * Cube and 2D textures for instance.
  9734. */
  9735. recreateShadowMap(): void;
  9736. private _disposeBlurPostProcesses;
  9737. private _disposeRTTandPostProcesses;
  9738. /**
  9739. * Disposes the ShadowGenerator.
  9740. * Returns nothing.
  9741. */
  9742. dispose(): void;
  9743. /**
  9744. * Serializes the shadow generator setup to a json object.
  9745. * @returns The serialized JSON object
  9746. */
  9747. serialize(): any;
  9748. /**
  9749. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9750. * @param parsedShadowGenerator The JSON object to parse
  9751. * @param scene The scene to create the shadow map for
  9752. * @returns The parsed shadow generator
  9753. */
  9754. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9755. }
  9756. }
  9757. declare module "babylonjs/Lights/light" {
  9758. import { Nullable } from "babylonjs/types";
  9759. import { Scene } from "babylonjs/scene";
  9760. import { Vector3, Color3 } from "babylonjs/Maths/math";
  9761. import { Node } from "babylonjs/node";
  9762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9763. import { Effect } from "babylonjs/Materials/effect";
  9764. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9765. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9766. /**
  9767. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9768. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9769. * 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.
  9770. */
  9771. export abstract class Light extends Node {
  9772. /**
  9773. * Falloff Default: light is falling off following the material specification:
  9774. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9775. */
  9776. static readonly FALLOFF_DEFAULT: number;
  9777. /**
  9778. * Falloff Physical: light is falling off following the inverse squared distance law.
  9779. */
  9780. static readonly FALLOFF_PHYSICAL: number;
  9781. /**
  9782. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9783. * to enhance interoperability with other engines.
  9784. */
  9785. static readonly FALLOFF_GLTF: number;
  9786. /**
  9787. * Falloff Standard: light is falling off like in the standard material
  9788. * to enhance interoperability with other materials.
  9789. */
  9790. static readonly FALLOFF_STANDARD: number;
  9791. /**
  9792. * If every light affecting the material is in this lightmapMode,
  9793. * material.lightmapTexture adds or multiplies
  9794. * (depends on material.useLightmapAsShadowmap)
  9795. * after every other light calculations.
  9796. */
  9797. static readonly LIGHTMAP_DEFAULT: number;
  9798. /**
  9799. * material.lightmapTexture as only diffuse lighting from this light
  9800. * adds only specular lighting from this light
  9801. * adds dynamic shadows
  9802. */
  9803. static readonly LIGHTMAP_SPECULAR: number;
  9804. /**
  9805. * material.lightmapTexture as only lighting
  9806. * no light calculation from this light
  9807. * only adds dynamic shadows from this light
  9808. */
  9809. static readonly LIGHTMAP_SHADOWSONLY: number;
  9810. /**
  9811. * Each light type uses the default quantity according to its type:
  9812. * point/spot lights use luminous intensity
  9813. * directional lights use illuminance
  9814. */
  9815. static readonly INTENSITYMODE_AUTOMATIC: number;
  9816. /**
  9817. * lumen (lm)
  9818. */
  9819. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9820. /**
  9821. * candela (lm/sr)
  9822. */
  9823. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9824. /**
  9825. * lux (lm/m^2)
  9826. */
  9827. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9828. /**
  9829. * nit (cd/m^2)
  9830. */
  9831. static readonly INTENSITYMODE_LUMINANCE: number;
  9832. /**
  9833. * Light type const id of the point light.
  9834. */
  9835. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9836. /**
  9837. * Light type const id of the directional light.
  9838. */
  9839. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9840. /**
  9841. * Light type const id of the spot light.
  9842. */
  9843. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9844. /**
  9845. * Light type const id of the hemispheric light.
  9846. */
  9847. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9848. /**
  9849. * Diffuse gives the basic color to an object.
  9850. */
  9851. diffuse: Color3;
  9852. /**
  9853. * Specular produces a highlight color on an object.
  9854. * Note: This is note affecting PBR materials.
  9855. */
  9856. specular: Color3;
  9857. /**
  9858. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9859. * falling off base on range or angle.
  9860. * This can be set to any values in Light.FALLOFF_x.
  9861. *
  9862. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9863. * other types of materials.
  9864. */
  9865. falloffType: number;
  9866. /**
  9867. * Strength of the light.
  9868. * Note: By default it is define in the framework own unit.
  9869. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9870. */
  9871. intensity: number;
  9872. private _range;
  9873. protected _inverseSquaredRange: number;
  9874. /**
  9875. * Defines how far from the source the light is impacting in scene units.
  9876. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9877. */
  9878. /**
  9879. * Defines how far from the source the light is impacting in scene units.
  9880. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9881. */
  9882. range: number;
  9883. /**
  9884. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9885. * of light.
  9886. */
  9887. private _photometricScale;
  9888. private _intensityMode;
  9889. /**
  9890. * Gets the photometric scale used to interpret the intensity.
  9891. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9892. */
  9893. /**
  9894. * Sets the photometric scale used to interpret the intensity.
  9895. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9896. */
  9897. intensityMode: number;
  9898. private _radius;
  9899. /**
  9900. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9901. */
  9902. /**
  9903. * sets the light radius used by PBR Materials to simulate soft area lights.
  9904. */
  9905. radius: number;
  9906. private _renderPriority;
  9907. /**
  9908. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9909. * exceeding the number allowed of the materials.
  9910. */
  9911. renderPriority: number;
  9912. private _shadowEnabled;
  9913. /**
  9914. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9915. * the current shadow generator.
  9916. */
  9917. /**
  9918. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9919. * the current shadow generator.
  9920. */
  9921. shadowEnabled: boolean;
  9922. private _includedOnlyMeshes;
  9923. /**
  9924. * Gets the only meshes impacted by this light.
  9925. */
  9926. /**
  9927. * Sets the only meshes impacted by this light.
  9928. */
  9929. includedOnlyMeshes: AbstractMesh[];
  9930. private _excludedMeshes;
  9931. /**
  9932. * Gets the meshes not impacted by this light.
  9933. */
  9934. /**
  9935. * Sets the meshes not impacted by this light.
  9936. */
  9937. excludedMeshes: AbstractMesh[];
  9938. private _excludeWithLayerMask;
  9939. /**
  9940. * Gets the layer id use to find what meshes are not impacted by the light.
  9941. * Inactive if 0
  9942. */
  9943. /**
  9944. * Sets the layer id use to find what meshes are not impacted by the light.
  9945. * Inactive if 0
  9946. */
  9947. excludeWithLayerMask: number;
  9948. private _includeOnlyWithLayerMask;
  9949. /**
  9950. * Gets the layer id use to find what meshes are impacted by the light.
  9951. * Inactive if 0
  9952. */
  9953. /**
  9954. * Sets the layer id use to find what meshes are impacted by the light.
  9955. * Inactive if 0
  9956. */
  9957. includeOnlyWithLayerMask: number;
  9958. private _lightmapMode;
  9959. /**
  9960. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9961. */
  9962. /**
  9963. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9964. */
  9965. lightmapMode: number;
  9966. /**
  9967. * Shadow generator associted to the light.
  9968. * @hidden Internal use only.
  9969. */
  9970. _shadowGenerator: Nullable<IShadowGenerator>;
  9971. /**
  9972. * @hidden Internal use only.
  9973. */
  9974. _excludedMeshesIds: string[];
  9975. /**
  9976. * @hidden Internal use only.
  9977. */
  9978. _includedOnlyMeshesIds: string[];
  9979. /**
  9980. * The current light unifom buffer.
  9981. * @hidden Internal use only.
  9982. */
  9983. _uniformBuffer: UniformBuffer;
  9984. /**
  9985. * Creates a Light object in the scene.
  9986. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9987. * @param name The firendly name of the light
  9988. * @param scene The scene the light belongs too
  9989. */
  9990. constructor(name: string, scene: Scene);
  9991. protected abstract _buildUniformLayout(): void;
  9992. /**
  9993. * Sets the passed Effect "effect" with the Light information.
  9994. * @param effect The effect to update
  9995. * @param lightIndex The index of the light in the effect to update
  9996. * @returns The light
  9997. */
  9998. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9999. /**
  10000. * Returns the string "Light".
  10001. * @returns the class name
  10002. */
  10003. getClassName(): string;
  10004. /** @hidden */
  10005. readonly _isLight: boolean;
  10006. /**
  10007. * Converts the light information to a readable string for debug purpose.
  10008. * @param fullDetails Supports for multiple levels of logging within scene loading
  10009. * @returns the human readable light info
  10010. */
  10011. toString(fullDetails?: boolean): string;
  10012. /** @hidden */
  10013. protected _syncParentEnabledState(): void;
  10014. /**
  10015. * Set the enabled state of this node.
  10016. * @param value - the new enabled state
  10017. */
  10018. setEnabled(value: boolean): void;
  10019. /**
  10020. * Returns the Light associated shadow generator if any.
  10021. * @return the associated shadow generator.
  10022. */
  10023. getShadowGenerator(): Nullable<IShadowGenerator>;
  10024. /**
  10025. * Returns a Vector3, the absolute light position in the World.
  10026. * @returns the world space position of the light
  10027. */
  10028. getAbsolutePosition(): Vector3;
  10029. /**
  10030. * Specifies if the light will affect the passed mesh.
  10031. * @param mesh The mesh to test against the light
  10032. * @return true the mesh is affected otherwise, false.
  10033. */
  10034. canAffectMesh(mesh: AbstractMesh): boolean;
  10035. /**
  10036. * Sort function to order lights for rendering.
  10037. * @param a First Light object to compare to second.
  10038. * @param b Second Light object to compare first.
  10039. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10040. */
  10041. static CompareLightsPriority(a: Light, b: Light): number;
  10042. /**
  10043. * Releases resources associated with this node.
  10044. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10045. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10046. */
  10047. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10048. /**
  10049. * Returns the light type ID (integer).
  10050. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10051. */
  10052. getTypeID(): number;
  10053. /**
  10054. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10055. * @returns the scaled intensity in intensity mode unit
  10056. */
  10057. getScaledIntensity(): number;
  10058. /**
  10059. * Returns a new Light object, named "name", from the current one.
  10060. * @param name The name of the cloned light
  10061. * @returns the new created light
  10062. */
  10063. clone(name: string): Nullable<Light>;
  10064. /**
  10065. * Serializes the current light into a Serialization object.
  10066. * @returns the serialized object.
  10067. */
  10068. serialize(): any;
  10069. /**
  10070. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10071. * This new light is named "name" and added to the passed scene.
  10072. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10073. * @param name The friendly name of the light
  10074. * @param scene The scene the new light will belong to
  10075. * @returns the constructor function
  10076. */
  10077. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10078. /**
  10079. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10080. * @param parsedLight The JSON representation of the light
  10081. * @param scene The scene to create the parsed light in
  10082. * @returns the created light after parsing
  10083. */
  10084. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10085. private _hookArrayForExcluded;
  10086. private _hookArrayForIncludedOnly;
  10087. private _resyncMeshes;
  10088. /**
  10089. * Forces the meshes to update their light related information in their rendering used effects
  10090. * @hidden Internal Use Only
  10091. */
  10092. _markMeshesAsLightDirty(): void;
  10093. /**
  10094. * Recomputes the cached photometric scale if needed.
  10095. */
  10096. private _computePhotometricScale;
  10097. /**
  10098. * Returns the Photometric Scale according to the light type and intensity mode.
  10099. */
  10100. private _getPhotometricScale;
  10101. /**
  10102. * Reorder the light in the scene according to their defined priority.
  10103. * @hidden Internal Use Only
  10104. */
  10105. _reorderLightsInScene(): void;
  10106. /**
  10107. * Prepares the list of defines specific to the light type.
  10108. * @param defines the list of defines
  10109. * @param lightIndex defines the index of the light for the effect
  10110. */
  10111. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10112. }
  10113. }
  10114. declare module "babylonjs/Actions/action" {
  10115. import { Observable } from "babylonjs/Misc/observable";
  10116. import { Condition } from "babylonjs/Actions/condition";
  10117. import { ActionManager } from "babylonjs/Actions/actionManager";
  10118. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10119. /**
  10120. * Interface used to define Action
  10121. */
  10122. export interface IAction {
  10123. /**
  10124. * Trigger for the action
  10125. */
  10126. trigger: number;
  10127. /** the trigger, with or without parameters, for the action */
  10128. triggerOptions: any;
  10129. /**
  10130. * Gets the trigger parameters
  10131. * @returns the trigger parameters
  10132. */
  10133. getTriggerParameter(): any;
  10134. /**
  10135. * Internal only - executes current action event
  10136. * @hidden
  10137. */
  10138. _executeCurrent(evt?: ActionEvent): void;
  10139. /**
  10140. * Serialize placeholder for child classes
  10141. * @param parent of child
  10142. * @returns the serialized object
  10143. */
  10144. serialize(parent: any): any;
  10145. }
  10146. /**
  10147. * The action to be carried out following a trigger
  10148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10149. */
  10150. export class Action implements IAction {
  10151. /** the trigger, with or without parameters, for the action */
  10152. triggerOptions: any;
  10153. /**
  10154. * Trigger for the action
  10155. */
  10156. trigger: number;
  10157. /**
  10158. * Internal only - manager for action
  10159. * @hidden
  10160. */
  10161. _actionManager: ActionManager;
  10162. private _nextActiveAction;
  10163. private _child;
  10164. private _condition?;
  10165. private _triggerParameter;
  10166. /**
  10167. * An event triggered prior to action being executed.
  10168. */
  10169. onBeforeExecuteObservable: Observable<Action>;
  10170. /**
  10171. * Creates a new Action
  10172. * @param triggerOptions the trigger, with or without parameters, for the action
  10173. * @param condition an optional determinant of action
  10174. */
  10175. constructor(
  10176. /** the trigger, with or without parameters, for the action */
  10177. triggerOptions: any, condition?: Condition);
  10178. /**
  10179. * Internal only
  10180. * @hidden
  10181. */
  10182. _prepare(): void;
  10183. /**
  10184. * Gets the trigger parameters
  10185. * @returns the trigger parameters
  10186. */
  10187. getTriggerParameter(): any;
  10188. /**
  10189. * Internal only - executes current action event
  10190. * @hidden
  10191. */
  10192. _executeCurrent(evt?: ActionEvent): void;
  10193. /**
  10194. * Execute placeholder for child classes
  10195. * @param evt optional action event
  10196. */
  10197. execute(evt?: ActionEvent): void;
  10198. /**
  10199. * Skips to next active action
  10200. */
  10201. skipToNextActiveAction(): void;
  10202. /**
  10203. * Adds action to chain of actions, may be a DoNothingAction
  10204. * @param action defines the next action to execute
  10205. * @returns The action passed in
  10206. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10207. */
  10208. then(action: Action): Action;
  10209. /**
  10210. * Internal only
  10211. * @hidden
  10212. */
  10213. _getProperty(propertyPath: string): string;
  10214. /**
  10215. * Internal only
  10216. * @hidden
  10217. */
  10218. _getEffectiveTarget(target: any, propertyPath: string): any;
  10219. /**
  10220. * Serialize placeholder for child classes
  10221. * @param parent of child
  10222. * @returns the serialized object
  10223. */
  10224. serialize(parent: any): any;
  10225. /**
  10226. * Internal only called by serialize
  10227. * @hidden
  10228. */
  10229. protected _serialize(serializedAction: any, parent?: any): any;
  10230. /**
  10231. * Internal only
  10232. * @hidden
  10233. */
  10234. static _SerializeValueAsString: (value: any) => string;
  10235. /**
  10236. * Internal only
  10237. * @hidden
  10238. */
  10239. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10240. name: string;
  10241. targetType: string;
  10242. value: string;
  10243. };
  10244. }
  10245. }
  10246. declare module "babylonjs/Actions/condition" {
  10247. import { ActionManager } from "babylonjs/Actions/actionManager";
  10248. /**
  10249. * A Condition applied to an Action
  10250. */
  10251. export class Condition {
  10252. /**
  10253. * Internal only - manager for action
  10254. * @hidden
  10255. */
  10256. _actionManager: ActionManager;
  10257. /**
  10258. * Internal only
  10259. * @hidden
  10260. */
  10261. _evaluationId: number;
  10262. /**
  10263. * Internal only
  10264. * @hidden
  10265. */
  10266. _currentResult: boolean;
  10267. /**
  10268. * Creates a new Condition
  10269. * @param actionManager the manager of the action the condition is applied to
  10270. */
  10271. constructor(actionManager: ActionManager);
  10272. /**
  10273. * Check if the current condition is valid
  10274. * @returns a boolean
  10275. */
  10276. isValid(): boolean;
  10277. /**
  10278. * Internal only
  10279. * @hidden
  10280. */
  10281. _getProperty(propertyPath: string): string;
  10282. /**
  10283. * Internal only
  10284. * @hidden
  10285. */
  10286. _getEffectiveTarget(target: any, propertyPath: string): any;
  10287. /**
  10288. * Serialize placeholder for child classes
  10289. * @returns the serialized object
  10290. */
  10291. serialize(): any;
  10292. /**
  10293. * Internal only
  10294. * @hidden
  10295. */
  10296. protected _serialize(serializedCondition: any): any;
  10297. }
  10298. /**
  10299. * Defines specific conditional operators as extensions of Condition
  10300. */
  10301. export class ValueCondition extends Condition {
  10302. /** path to specify the property of the target the conditional operator uses */
  10303. propertyPath: string;
  10304. /** the value compared by the conditional operator against the current value of the property */
  10305. value: any;
  10306. /** the conditional operator, default ValueCondition.IsEqual */
  10307. operator: number;
  10308. /**
  10309. * Internal only
  10310. * @hidden
  10311. */
  10312. private static _IsEqual;
  10313. /**
  10314. * Internal only
  10315. * @hidden
  10316. */
  10317. private static _IsDifferent;
  10318. /**
  10319. * Internal only
  10320. * @hidden
  10321. */
  10322. private static _IsGreater;
  10323. /**
  10324. * Internal only
  10325. * @hidden
  10326. */
  10327. private static _IsLesser;
  10328. /**
  10329. * returns the number for IsEqual
  10330. */
  10331. static readonly IsEqual: number;
  10332. /**
  10333. * Returns the number for IsDifferent
  10334. */
  10335. static readonly IsDifferent: number;
  10336. /**
  10337. * Returns the number for IsGreater
  10338. */
  10339. static readonly IsGreater: number;
  10340. /**
  10341. * Returns the number for IsLesser
  10342. */
  10343. static readonly IsLesser: number;
  10344. /**
  10345. * Internal only The action manager for the condition
  10346. * @hidden
  10347. */
  10348. _actionManager: ActionManager;
  10349. /**
  10350. * Internal only
  10351. * @hidden
  10352. */
  10353. private _target;
  10354. /**
  10355. * Internal only
  10356. * @hidden
  10357. */
  10358. private _effectiveTarget;
  10359. /**
  10360. * Internal only
  10361. * @hidden
  10362. */
  10363. private _property;
  10364. /**
  10365. * Creates a new ValueCondition
  10366. * @param actionManager manager for the action the condition applies to
  10367. * @param target for the action
  10368. * @param propertyPath path to specify the property of the target the conditional operator uses
  10369. * @param value the value compared by the conditional operator against the current value of the property
  10370. * @param operator the conditional operator, default ValueCondition.IsEqual
  10371. */
  10372. constructor(actionManager: ActionManager, target: any,
  10373. /** path to specify the property of the target the conditional operator uses */
  10374. propertyPath: string,
  10375. /** the value compared by the conditional operator against the current value of the property */
  10376. value: any,
  10377. /** the conditional operator, default ValueCondition.IsEqual */
  10378. operator?: number);
  10379. /**
  10380. * Compares the given value with the property value for the specified conditional operator
  10381. * @returns the result of the comparison
  10382. */
  10383. isValid(): boolean;
  10384. /**
  10385. * Serialize the ValueCondition into a JSON compatible object
  10386. * @returns serialization object
  10387. */
  10388. serialize(): any;
  10389. /**
  10390. * Gets the name of the conditional operator for the ValueCondition
  10391. * @param operator the conditional operator
  10392. * @returns the name
  10393. */
  10394. static GetOperatorName(operator: number): string;
  10395. }
  10396. /**
  10397. * Defines a predicate condition as an extension of Condition
  10398. */
  10399. export class PredicateCondition extends Condition {
  10400. /** defines the predicate function used to validate the condition */
  10401. predicate: () => boolean;
  10402. /**
  10403. * Internal only - manager for action
  10404. * @hidden
  10405. */
  10406. _actionManager: ActionManager;
  10407. /**
  10408. * Creates a new PredicateCondition
  10409. * @param actionManager manager for the action the condition applies to
  10410. * @param predicate defines the predicate function used to validate the condition
  10411. */
  10412. constructor(actionManager: ActionManager,
  10413. /** defines the predicate function used to validate the condition */
  10414. predicate: () => boolean);
  10415. /**
  10416. * @returns the validity of the predicate condition
  10417. */
  10418. isValid(): boolean;
  10419. }
  10420. /**
  10421. * Defines a state condition as an extension of Condition
  10422. */
  10423. export class StateCondition extends Condition {
  10424. /** Value to compare with target state */
  10425. value: string;
  10426. /**
  10427. * Internal only - manager for action
  10428. * @hidden
  10429. */
  10430. _actionManager: ActionManager;
  10431. /**
  10432. * Internal only
  10433. * @hidden
  10434. */
  10435. private _target;
  10436. /**
  10437. * Creates a new StateCondition
  10438. * @param actionManager manager for the action the condition applies to
  10439. * @param target of the condition
  10440. * @param value to compare with target state
  10441. */
  10442. constructor(actionManager: ActionManager, target: any,
  10443. /** Value to compare with target state */
  10444. value: string);
  10445. /**
  10446. * Gets a boolean indicating if the current condition is met
  10447. * @returns the validity of the state
  10448. */
  10449. isValid(): boolean;
  10450. /**
  10451. * Serialize the StateCondition into a JSON compatible object
  10452. * @returns serialization object
  10453. */
  10454. serialize(): any;
  10455. }
  10456. }
  10457. declare module "babylonjs/Actions/directActions" {
  10458. import { Action } from "babylonjs/Actions/action";
  10459. import { Condition } from "babylonjs/Actions/condition";
  10460. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10461. /**
  10462. * This defines an action responsible to toggle a boolean once triggered.
  10463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10464. */
  10465. export class SwitchBooleanAction extends Action {
  10466. /**
  10467. * The path to the boolean property in the target object
  10468. */
  10469. propertyPath: string;
  10470. private _target;
  10471. private _effectiveTarget;
  10472. private _property;
  10473. /**
  10474. * Instantiate the action
  10475. * @param triggerOptions defines the trigger options
  10476. * @param target defines the object containing the boolean
  10477. * @param propertyPath defines the path to the boolean property in the target object
  10478. * @param condition defines the trigger related conditions
  10479. */
  10480. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10481. /** @hidden */
  10482. _prepare(): void;
  10483. /**
  10484. * Execute the action toggle the boolean value.
  10485. */
  10486. execute(): void;
  10487. /**
  10488. * Serializes the actions and its related information.
  10489. * @param parent defines the object to serialize in
  10490. * @returns the serialized object
  10491. */
  10492. serialize(parent: any): any;
  10493. }
  10494. /**
  10495. * This defines an action responsible to set a the state field of the target
  10496. * to a desired value once triggered.
  10497. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10498. */
  10499. export class SetStateAction extends Action {
  10500. /**
  10501. * The value to store in the state field.
  10502. */
  10503. value: string;
  10504. private _target;
  10505. /**
  10506. * Instantiate the action
  10507. * @param triggerOptions defines the trigger options
  10508. * @param target defines the object containing the state property
  10509. * @param value defines the value to store in the state field
  10510. * @param condition defines the trigger related conditions
  10511. */
  10512. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10513. /**
  10514. * Execute the action and store the value on the target state property.
  10515. */
  10516. execute(): void;
  10517. /**
  10518. * Serializes the actions and its related information.
  10519. * @param parent defines the object to serialize in
  10520. * @returns the serialized object
  10521. */
  10522. serialize(parent: any): any;
  10523. }
  10524. /**
  10525. * This defines an action responsible to set a property of the target
  10526. * to a desired value once triggered.
  10527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10528. */
  10529. export class SetValueAction extends Action {
  10530. /**
  10531. * The path of the property to set in the target.
  10532. */
  10533. propertyPath: string;
  10534. /**
  10535. * The value to set in the property
  10536. */
  10537. value: any;
  10538. private _target;
  10539. private _effectiveTarget;
  10540. private _property;
  10541. /**
  10542. * Instantiate the action
  10543. * @param triggerOptions defines the trigger options
  10544. * @param target defines the object containing the property
  10545. * @param propertyPath defines the path of the property to set in the target
  10546. * @param value defines the value to set in the property
  10547. * @param condition defines the trigger related conditions
  10548. */
  10549. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10550. /** @hidden */
  10551. _prepare(): void;
  10552. /**
  10553. * Execute the action and set the targetted property to the desired value.
  10554. */
  10555. execute(): void;
  10556. /**
  10557. * Serializes the actions and its related information.
  10558. * @param parent defines the object to serialize in
  10559. * @returns the serialized object
  10560. */
  10561. serialize(parent: any): any;
  10562. }
  10563. /**
  10564. * This defines an action responsible to increment the target value
  10565. * to a desired value once triggered.
  10566. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10567. */
  10568. export class IncrementValueAction extends Action {
  10569. /**
  10570. * The path of the property to increment in the target.
  10571. */
  10572. propertyPath: string;
  10573. /**
  10574. * The value we should increment the property by.
  10575. */
  10576. value: any;
  10577. private _target;
  10578. private _effectiveTarget;
  10579. private _property;
  10580. /**
  10581. * Instantiate the action
  10582. * @param triggerOptions defines the trigger options
  10583. * @param target defines the object containing the property
  10584. * @param propertyPath defines the path of the property to increment in the target
  10585. * @param value defines the value value we should increment the property by
  10586. * @param condition defines the trigger related conditions
  10587. */
  10588. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10589. /** @hidden */
  10590. _prepare(): void;
  10591. /**
  10592. * Execute the action and increment the target of the value amount.
  10593. */
  10594. execute(): void;
  10595. /**
  10596. * Serializes the actions and its related information.
  10597. * @param parent defines the object to serialize in
  10598. * @returns the serialized object
  10599. */
  10600. serialize(parent: any): any;
  10601. }
  10602. /**
  10603. * This defines an action responsible to start an animation once triggered.
  10604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10605. */
  10606. export class PlayAnimationAction extends Action {
  10607. /**
  10608. * Where the animation should start (animation frame)
  10609. */
  10610. from: number;
  10611. /**
  10612. * Where the animation should stop (animation frame)
  10613. */
  10614. to: number;
  10615. /**
  10616. * Define if the animation should loop or stop after the first play.
  10617. */
  10618. loop?: boolean;
  10619. private _target;
  10620. /**
  10621. * Instantiate the action
  10622. * @param triggerOptions defines the trigger options
  10623. * @param target defines the target animation or animation name
  10624. * @param from defines from where the animation should start (animation frame)
  10625. * @param end defines where the animation should stop (animation frame)
  10626. * @param loop defines if the animation should loop or stop after the first play
  10627. * @param condition defines the trigger related conditions
  10628. */
  10629. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10630. /** @hidden */
  10631. _prepare(): void;
  10632. /**
  10633. * Execute the action and play the animation.
  10634. */
  10635. execute(): void;
  10636. /**
  10637. * Serializes the actions and its related information.
  10638. * @param parent defines the object to serialize in
  10639. * @returns the serialized object
  10640. */
  10641. serialize(parent: any): any;
  10642. }
  10643. /**
  10644. * This defines an action responsible to stop an animation once triggered.
  10645. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10646. */
  10647. export class StopAnimationAction extends Action {
  10648. private _target;
  10649. /**
  10650. * Instantiate the action
  10651. * @param triggerOptions defines the trigger options
  10652. * @param target defines the target animation or animation name
  10653. * @param condition defines the trigger related conditions
  10654. */
  10655. constructor(triggerOptions: any, target: any, condition?: Condition);
  10656. /** @hidden */
  10657. _prepare(): void;
  10658. /**
  10659. * Execute the action and stop the animation.
  10660. */
  10661. execute(): void;
  10662. /**
  10663. * Serializes the actions and its related information.
  10664. * @param parent defines the object to serialize in
  10665. * @returns the serialized object
  10666. */
  10667. serialize(parent: any): any;
  10668. }
  10669. /**
  10670. * This defines an action responsible that does nothing once triggered.
  10671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10672. */
  10673. export class DoNothingAction extends Action {
  10674. /**
  10675. * Instantiate the action
  10676. * @param triggerOptions defines the trigger options
  10677. * @param condition defines the trigger related conditions
  10678. */
  10679. constructor(triggerOptions?: any, condition?: Condition);
  10680. /**
  10681. * Execute the action and do nothing.
  10682. */
  10683. execute(): void;
  10684. /**
  10685. * Serializes the actions and its related information.
  10686. * @param parent defines the object to serialize in
  10687. * @returns the serialized object
  10688. */
  10689. serialize(parent: any): any;
  10690. }
  10691. /**
  10692. * This defines an action responsible to trigger several actions once triggered.
  10693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10694. */
  10695. export class CombineAction extends Action {
  10696. /**
  10697. * The list of aggregated animations to run.
  10698. */
  10699. children: Action[];
  10700. /**
  10701. * Instantiate the action
  10702. * @param triggerOptions defines the trigger options
  10703. * @param children defines the list of aggregated animations to run
  10704. * @param condition defines the trigger related conditions
  10705. */
  10706. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10707. /** @hidden */
  10708. _prepare(): void;
  10709. /**
  10710. * Execute the action and executes all the aggregated actions.
  10711. */
  10712. execute(evt: ActionEvent): void;
  10713. /**
  10714. * Serializes the actions and its related information.
  10715. * @param parent defines the object to serialize in
  10716. * @returns the serialized object
  10717. */
  10718. serialize(parent: any): any;
  10719. }
  10720. /**
  10721. * This defines an action responsible to run code (external event) once triggered.
  10722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10723. */
  10724. export class ExecuteCodeAction extends Action {
  10725. /**
  10726. * The callback function to run.
  10727. */
  10728. func: (evt: ActionEvent) => void;
  10729. /**
  10730. * Instantiate the action
  10731. * @param triggerOptions defines the trigger options
  10732. * @param func defines the callback function to run
  10733. * @param condition defines the trigger related conditions
  10734. */
  10735. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10736. /**
  10737. * Execute the action and run the attached code.
  10738. */
  10739. execute(evt: ActionEvent): void;
  10740. }
  10741. /**
  10742. * This defines an action responsible to set the parent property of the target once triggered.
  10743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10744. */
  10745. export class SetParentAction extends Action {
  10746. private _parent;
  10747. private _target;
  10748. /**
  10749. * Instantiate the action
  10750. * @param triggerOptions defines the trigger options
  10751. * @param target defines the target containing the parent property
  10752. * @param parent defines from where the animation should start (animation frame)
  10753. * @param condition defines the trigger related conditions
  10754. */
  10755. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10756. /** @hidden */
  10757. _prepare(): void;
  10758. /**
  10759. * Execute the action and set the parent property.
  10760. */
  10761. execute(): void;
  10762. /**
  10763. * Serializes the actions and its related information.
  10764. * @param parent defines the object to serialize in
  10765. * @returns the serialized object
  10766. */
  10767. serialize(parent: any): any;
  10768. }
  10769. }
  10770. declare module "babylonjs/Actions/abstractActionManager" {
  10771. import { IDisposable } from "babylonjs/scene";
  10772. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10773. import { IAction } from "babylonjs/Actions/action";
  10774. /**
  10775. * Abstract class used to decouple action Manager from scene and meshes.
  10776. * Do not instantiate.
  10777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10778. */
  10779. export abstract class AbstractActionManager implements IDisposable {
  10780. /** Gets the list of active triggers */
  10781. static Triggers: {
  10782. [key: string]: number;
  10783. };
  10784. /** Gets the cursor to use when hovering items */
  10785. hoverCursor: string;
  10786. /** Gets the list of actions */
  10787. actions: IAction[];
  10788. /**
  10789. * Releases all associated resources
  10790. */
  10791. abstract dispose(): void;
  10792. /**
  10793. * Does this action manager has pointer triggers
  10794. */
  10795. abstract readonly hasPointerTriggers: boolean;
  10796. /**
  10797. * Does this action manager has pick triggers
  10798. */
  10799. abstract readonly hasPickTriggers: boolean;
  10800. /**
  10801. * Process a specific trigger
  10802. * @param trigger defines the trigger to process
  10803. * @param evt defines the event details to be processed
  10804. */
  10805. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  10806. /**
  10807. * Does this action manager handles actions of any of the given triggers
  10808. * @param triggers defines the triggers to be tested
  10809. * @return a boolean indicating whether one (or more) of the triggers is handled
  10810. */
  10811. abstract hasSpecificTriggers(triggers: number[]): boolean;
  10812. /**
  10813. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10814. * speed.
  10815. * @param triggerA defines the trigger to be tested
  10816. * @param triggerB defines the trigger to be tested
  10817. * @return a boolean indicating whether one (or more) of the triggers is handled
  10818. */
  10819. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10820. /**
  10821. * Does this action manager handles actions of a given trigger
  10822. * @param trigger defines the trigger to be tested
  10823. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10824. * @return whether the trigger is handled
  10825. */
  10826. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10827. /**
  10828. * Serialize this manager to a JSON object
  10829. * @param name defines the property name to store this manager
  10830. * @returns a JSON representation of this manager
  10831. */
  10832. abstract serialize(name: string): any;
  10833. /**
  10834. * Does exist one action manager with at least one trigger
  10835. **/
  10836. static readonly HasTriggers: boolean;
  10837. /**
  10838. * Does exist one action manager with at least one pick trigger
  10839. **/
  10840. static readonly HasPickTriggers: boolean;
  10841. /**
  10842. * Does exist one action manager that handles actions of a given trigger
  10843. * @param trigger defines the trigger to be tested
  10844. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  10845. **/
  10846. static HasSpecificTrigger(trigger: number): boolean;
  10847. }
  10848. }
  10849. declare module "babylonjs/Actions/actionManager" {
  10850. import { Nullable } from "babylonjs/types";
  10851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10852. import { Scene } from "babylonjs/scene";
  10853. import { Action } from "babylonjs/Actions/action";
  10854. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10855. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10856. /**
  10857. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10858. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10860. */
  10861. export class ActionManager extends AbstractActionManager {
  10862. /**
  10863. * Nothing
  10864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10865. */
  10866. static readonly NothingTrigger: number;
  10867. /**
  10868. * On pick
  10869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10870. */
  10871. static readonly OnPickTrigger: number;
  10872. /**
  10873. * On left pick
  10874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10875. */
  10876. static readonly OnLeftPickTrigger: number;
  10877. /**
  10878. * On right pick
  10879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10880. */
  10881. static readonly OnRightPickTrigger: number;
  10882. /**
  10883. * On center pick
  10884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10885. */
  10886. static readonly OnCenterPickTrigger: number;
  10887. /**
  10888. * On pick down
  10889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10890. */
  10891. static readonly OnPickDownTrigger: number;
  10892. /**
  10893. * On double pick
  10894. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10895. */
  10896. static readonly OnDoublePickTrigger: number;
  10897. /**
  10898. * On pick up
  10899. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10900. */
  10901. static readonly OnPickUpTrigger: number;
  10902. /**
  10903. * On pick out.
  10904. * This trigger will only be raised if you also declared a OnPickDown
  10905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10906. */
  10907. static readonly OnPickOutTrigger: number;
  10908. /**
  10909. * On long press
  10910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10911. */
  10912. static readonly OnLongPressTrigger: number;
  10913. /**
  10914. * On pointer over
  10915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10916. */
  10917. static readonly OnPointerOverTrigger: number;
  10918. /**
  10919. * On pointer out
  10920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10921. */
  10922. static readonly OnPointerOutTrigger: number;
  10923. /**
  10924. * On every frame
  10925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10926. */
  10927. static readonly OnEveryFrameTrigger: number;
  10928. /**
  10929. * On intersection enter
  10930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10931. */
  10932. static readonly OnIntersectionEnterTrigger: number;
  10933. /**
  10934. * On intersection exit
  10935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10936. */
  10937. static readonly OnIntersectionExitTrigger: number;
  10938. /**
  10939. * On key down
  10940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10941. */
  10942. static readonly OnKeyDownTrigger: number;
  10943. /**
  10944. * On key up
  10945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10946. */
  10947. static readonly OnKeyUpTrigger: number;
  10948. private _scene;
  10949. /**
  10950. * Creates a new action manager
  10951. * @param scene defines the hosting scene
  10952. */
  10953. constructor(scene: Scene);
  10954. /**
  10955. * Releases all associated resources
  10956. */
  10957. dispose(): void;
  10958. /**
  10959. * Gets hosting scene
  10960. * @returns the hosting scene
  10961. */
  10962. getScene(): Scene;
  10963. /**
  10964. * Does this action manager handles actions of any of the given triggers
  10965. * @param triggers defines the triggers to be tested
  10966. * @return a boolean indicating whether one (or more) of the triggers is handled
  10967. */
  10968. hasSpecificTriggers(triggers: number[]): boolean;
  10969. /**
  10970. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10971. * speed.
  10972. * @param triggerA defines the trigger to be tested
  10973. * @param triggerB defines the trigger to be tested
  10974. * @return a boolean indicating whether one (or more) of the triggers is handled
  10975. */
  10976. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10977. /**
  10978. * Does this action manager handles actions of a given trigger
  10979. * @param trigger defines the trigger to be tested
  10980. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10981. * @return whether the trigger is handled
  10982. */
  10983. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10984. /**
  10985. * Does this action manager has pointer triggers
  10986. */
  10987. readonly hasPointerTriggers: boolean;
  10988. /**
  10989. * Does this action manager has pick triggers
  10990. */
  10991. readonly hasPickTriggers: boolean;
  10992. /**
  10993. * Registers an action to this action manager
  10994. * @param action defines the action to be registered
  10995. * @return the action amended (prepared) after registration
  10996. */
  10997. registerAction(action: Action): Nullable<Action>;
  10998. /**
  10999. * Unregisters an action to this action manager
  11000. * @param action defines the action to be unregistered
  11001. * @return a boolean indicating whether the action has been unregistered
  11002. */
  11003. unregisterAction(action: Action): Boolean;
  11004. /**
  11005. * Process a specific trigger
  11006. * @param trigger defines the trigger to process
  11007. * @param evt defines the event details to be processed
  11008. */
  11009. processTrigger(trigger: number, evt?: IActionEvent): void;
  11010. /** @hidden */
  11011. _getEffectiveTarget(target: any, propertyPath: string): any;
  11012. /** @hidden */
  11013. _getProperty(propertyPath: string): string;
  11014. /**
  11015. * Serialize this manager to a JSON object
  11016. * @param name defines the property name to store this manager
  11017. * @returns a JSON representation of this manager
  11018. */
  11019. serialize(name: string): any;
  11020. /**
  11021. * Creates a new ActionManager from a JSON data
  11022. * @param parsedActions defines the JSON data to read from
  11023. * @param object defines the hosting mesh
  11024. * @param scene defines the hosting scene
  11025. */
  11026. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11027. /**
  11028. * Get a trigger name by index
  11029. * @param trigger defines the trigger index
  11030. * @returns a trigger name
  11031. */
  11032. static GetTriggerName(trigger: number): string;
  11033. }
  11034. }
  11035. declare module "babylonjs/Culling/ray" {
  11036. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11037. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11039. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11040. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11041. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11042. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11043. /**
  11044. * Class representing a ray with position and direction
  11045. */
  11046. export class Ray {
  11047. /** origin point */
  11048. origin: Vector3;
  11049. /** direction */
  11050. direction: Vector3;
  11051. /** length of the ray */
  11052. length: number;
  11053. private static readonly TmpVector3;
  11054. private _tmpRay;
  11055. /**
  11056. * Creates a new ray
  11057. * @param origin origin point
  11058. * @param direction direction
  11059. * @param length length of the ray
  11060. */
  11061. constructor(
  11062. /** origin point */
  11063. origin: Vector3,
  11064. /** direction */
  11065. direction: Vector3,
  11066. /** length of the ray */
  11067. length?: number);
  11068. /**
  11069. * Checks if the ray intersects a box
  11070. * @param minimum bound of the box
  11071. * @param maximum bound of the box
  11072. * @param intersectionTreshold extra extend to be added to the box in all direction
  11073. * @returns if the box was hit
  11074. */
  11075. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11076. /**
  11077. * Checks if the ray intersects a box
  11078. * @param box the bounding box to check
  11079. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11080. * @returns if the box was hit
  11081. */
  11082. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11083. /**
  11084. * If the ray hits a sphere
  11085. * @param sphere the bounding sphere to check
  11086. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11087. * @returns true if it hits the sphere
  11088. */
  11089. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11090. /**
  11091. * If the ray hits a triange
  11092. * @param vertex0 triangle vertex
  11093. * @param vertex1 triangle vertex
  11094. * @param vertex2 triangle vertex
  11095. * @returns intersection information if hit
  11096. */
  11097. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11098. /**
  11099. * Checks if ray intersects a plane
  11100. * @param plane the plane to check
  11101. * @returns the distance away it was hit
  11102. */
  11103. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11104. /**
  11105. * Checks if ray intersects a mesh
  11106. * @param mesh the mesh to check
  11107. * @param fastCheck if only the bounding box should checked
  11108. * @returns picking info of the intersecton
  11109. */
  11110. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11111. /**
  11112. * Checks if ray intersects a mesh
  11113. * @param meshes the meshes to check
  11114. * @param fastCheck if only the bounding box should checked
  11115. * @param results array to store result in
  11116. * @returns Array of picking infos
  11117. */
  11118. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11119. private _comparePickingInfo;
  11120. private static smallnum;
  11121. private static rayl;
  11122. /**
  11123. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11124. * @param sega the first point of the segment to test the intersection against
  11125. * @param segb the second point of the segment to test the intersection against
  11126. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11127. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11128. */
  11129. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11130. /**
  11131. * Update the ray from viewport position
  11132. * @param x position
  11133. * @param y y position
  11134. * @param viewportWidth viewport width
  11135. * @param viewportHeight viewport height
  11136. * @param world world matrix
  11137. * @param view view matrix
  11138. * @param projection projection matrix
  11139. * @returns this ray updated
  11140. */
  11141. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11142. /**
  11143. * Creates a ray with origin and direction of 0,0,0
  11144. * @returns the new ray
  11145. */
  11146. static Zero(): Ray;
  11147. /**
  11148. * Creates a new ray from screen space and viewport
  11149. * @param x position
  11150. * @param y y position
  11151. * @param viewportWidth viewport width
  11152. * @param viewportHeight viewport height
  11153. * @param world world matrix
  11154. * @param view view matrix
  11155. * @param projection projection matrix
  11156. * @returns new ray
  11157. */
  11158. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11159. /**
  11160. * 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
  11161. * transformed to the given world matrix.
  11162. * @param origin The origin point
  11163. * @param end The end point
  11164. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11165. * @returns the new ray
  11166. */
  11167. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11168. /**
  11169. * Transforms a ray by a matrix
  11170. * @param ray ray to transform
  11171. * @param matrix matrix to apply
  11172. * @returns the resulting new ray
  11173. */
  11174. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11175. /**
  11176. * Transforms a ray by a matrix
  11177. * @param ray ray to transform
  11178. * @param matrix matrix to apply
  11179. * @param result ray to store result in
  11180. */
  11181. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11182. /**
  11183. * Unproject a ray from screen space to object space
  11184. * @param sourceX defines the screen space x coordinate to use
  11185. * @param sourceY defines the screen space y coordinate to use
  11186. * @param viewportWidth defines the current width of the viewport
  11187. * @param viewportHeight defines the current height of the viewport
  11188. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11189. * @param view defines the view matrix to use
  11190. * @param projection defines the projection matrix to use
  11191. */
  11192. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11193. }
  11194. module "babylonjs/scene" {
  11195. interface Scene {
  11196. /** @hidden */
  11197. _tempPickingRay: Nullable<Ray>;
  11198. /** @hidden */
  11199. _cachedRayForTransform: Ray;
  11200. /** @hidden */
  11201. _pickWithRayInverseMatrix: Matrix;
  11202. /** @hidden */
  11203. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11204. /** @hidden */
  11205. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  11206. }
  11207. }
  11208. }
  11209. declare module "babylonjs/sceneComponent" {
  11210. import { Scene } from "babylonjs/scene";
  11211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11212. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11213. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11214. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11215. import { Nullable } from "babylonjs/types";
  11216. import { Camera } from "babylonjs/Cameras/camera";
  11217. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11218. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11219. import { AbstractScene } from "babylonjs/abstractScene";
  11220. /**
  11221. * Groups all the scene component constants in one place to ease maintenance.
  11222. * @hidden
  11223. */
  11224. export class SceneComponentConstants {
  11225. static readonly NAME_EFFECTLAYER: string;
  11226. static readonly NAME_LAYER: string;
  11227. static readonly NAME_LENSFLARESYSTEM: string;
  11228. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11229. static readonly NAME_PARTICLESYSTEM: string;
  11230. static readonly NAME_GAMEPAD: string;
  11231. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11232. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11233. static readonly NAME_DEPTHRENDERER: string;
  11234. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11235. static readonly NAME_SPRITE: string;
  11236. static readonly NAME_OUTLINERENDERER: string;
  11237. static readonly NAME_PROCEDURALTEXTURE: string;
  11238. static readonly NAME_SHADOWGENERATOR: string;
  11239. static readonly NAME_OCTREE: string;
  11240. static readonly NAME_PHYSICSENGINE: string;
  11241. static readonly NAME_AUDIO: string;
  11242. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11243. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11244. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11245. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11246. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11247. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11248. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11249. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11250. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11251. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11252. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11253. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11254. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11255. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11256. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11257. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11258. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11259. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11260. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11261. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11262. static readonly STEP_AFTERRENDER_AUDIO: number;
  11263. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11264. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11265. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11266. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11267. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11268. static readonly STEP_POINTERMOVE_SPRITE: number;
  11269. static readonly STEP_POINTERDOWN_SPRITE: number;
  11270. static readonly STEP_POINTERUP_SPRITE: number;
  11271. }
  11272. /**
  11273. * This represents a scene component.
  11274. *
  11275. * This is used to decouple the dependency the scene is having on the different workloads like
  11276. * layers, post processes...
  11277. */
  11278. export interface ISceneComponent {
  11279. /**
  11280. * The name of the component. Each component must have a unique name.
  11281. */
  11282. name: string;
  11283. /**
  11284. * The scene the component belongs to.
  11285. */
  11286. scene: Scene;
  11287. /**
  11288. * Register the component to one instance of a scene.
  11289. */
  11290. register(): void;
  11291. /**
  11292. * Rebuilds the elements related to this component in case of
  11293. * context lost for instance.
  11294. */
  11295. rebuild(): void;
  11296. /**
  11297. * Disposes the component and the associated ressources.
  11298. */
  11299. dispose(): void;
  11300. }
  11301. /**
  11302. * This represents a SERIALIZABLE scene component.
  11303. *
  11304. * This extends Scene Component to add Serialization methods on top.
  11305. */
  11306. export interface ISceneSerializableComponent extends ISceneComponent {
  11307. /**
  11308. * Adds all the element from the container to the scene
  11309. * @param container the container holding the elements
  11310. */
  11311. addFromContainer(container: AbstractScene): void;
  11312. /**
  11313. * Removes all the elements in the container from the scene
  11314. * @param container contains the elements to remove
  11315. */
  11316. removeFromContainer(container: AbstractScene): void;
  11317. /**
  11318. * Serializes the component data to the specified json object
  11319. * @param serializationObject The object to serialize to
  11320. */
  11321. serialize(serializationObject: any): void;
  11322. }
  11323. /**
  11324. * Strong typing of a Mesh related stage step action
  11325. */
  11326. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11327. /**
  11328. * Strong typing of a Evaluate Sub Mesh related stage step action
  11329. */
  11330. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11331. /**
  11332. * Strong typing of a Active Mesh related stage step action
  11333. */
  11334. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11335. /**
  11336. * Strong typing of a Camera related stage step action
  11337. */
  11338. export type CameraStageAction = (camera: Camera) => void;
  11339. /**
  11340. * Strong typing of a Render Target related stage step action
  11341. */
  11342. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11343. /**
  11344. * Strong typing of a RenderingGroup related stage step action
  11345. */
  11346. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11347. /**
  11348. * Strong typing of a Mesh Render related stage step action
  11349. */
  11350. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11351. /**
  11352. * Strong typing of a simple stage step action
  11353. */
  11354. export type SimpleStageAction = () => void;
  11355. /**
  11356. * Strong typing of a render target action.
  11357. */
  11358. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11359. /**
  11360. * Strong typing of a pointer move action.
  11361. */
  11362. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11363. /**
  11364. * Strong typing of a pointer up/down action.
  11365. */
  11366. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11367. /**
  11368. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11369. * @hidden
  11370. */
  11371. export class Stage<T extends Function> extends Array<{
  11372. index: number;
  11373. component: ISceneComponent;
  11374. action: T;
  11375. }> {
  11376. /**
  11377. * Hide ctor from the rest of the world.
  11378. * @param items The items to add.
  11379. */
  11380. private constructor();
  11381. /**
  11382. * Creates a new Stage.
  11383. * @returns A new instance of a Stage
  11384. */
  11385. static Create<T extends Function>(): Stage<T>;
  11386. /**
  11387. * Registers a step in an ordered way in the targeted stage.
  11388. * @param index Defines the position to register the step in
  11389. * @param component Defines the component attached to the step
  11390. * @param action Defines the action to launch during the step
  11391. */
  11392. registerStep(index: number, component: ISceneComponent, action: T): void;
  11393. /**
  11394. * Clears all the steps from the stage.
  11395. */
  11396. clear(): void;
  11397. }
  11398. }
  11399. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11400. import { Nullable } from "babylonjs/types";
  11401. import { Observable } from "babylonjs/Misc/observable";
  11402. import { Scene } from "babylonjs/scene";
  11403. import { Sprite } from "babylonjs/Sprites/sprite";
  11404. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11405. import { Ray } from "babylonjs/Culling/ray";
  11406. import { Camera } from "babylonjs/Cameras/camera";
  11407. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11408. import { ISceneComponent } from "babylonjs/sceneComponent";
  11409. module "babylonjs/scene" {
  11410. interface Scene {
  11411. /** @hidden */
  11412. _pointerOverSprite: Nullable<Sprite>;
  11413. /** @hidden */
  11414. _pickedDownSprite: Nullable<Sprite>;
  11415. /** @hidden */
  11416. _tempSpritePickingRay: Nullable<Ray>;
  11417. /**
  11418. * All of the sprite managers added to this scene
  11419. * @see http://doc.babylonjs.com/babylon101/sprites
  11420. */
  11421. spriteManagers: Array<ISpriteManager>;
  11422. /**
  11423. * An event triggered when sprites rendering is about to start
  11424. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11425. */
  11426. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11427. /**
  11428. * An event triggered when sprites rendering is done
  11429. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11430. */
  11431. onAfterSpritesRenderingObservable: Observable<Scene>;
  11432. /** @hidden */
  11433. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11434. /** Launch a ray to try to pick a sprite in the scene
  11435. * @param x position on screen
  11436. * @param y position on screen
  11437. * @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
  11438. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11439. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11440. * @returns a PickingInfo
  11441. */
  11442. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11443. /** Use the given ray to pick a sprite in the scene
  11444. * @param ray The ray (in world space) to use to pick meshes
  11445. * @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
  11446. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11447. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11448. * @returns a PickingInfo
  11449. */
  11450. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11451. /**
  11452. * Force the sprite under the pointer
  11453. * @param sprite defines the sprite to use
  11454. */
  11455. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11456. /**
  11457. * Gets the sprite under the pointer
  11458. * @returns a Sprite or null if no sprite is under the pointer
  11459. */
  11460. getPointerOverSprite(): Nullable<Sprite>;
  11461. }
  11462. }
  11463. /**
  11464. * Defines the sprite scene component responsible to manage sprites
  11465. * in a given scene.
  11466. */
  11467. export class SpriteSceneComponent implements ISceneComponent {
  11468. /**
  11469. * The component name helpfull to identify the component in the list of scene components.
  11470. */
  11471. readonly name: string;
  11472. /**
  11473. * The scene the component belongs to.
  11474. */
  11475. scene: Scene;
  11476. /** @hidden */
  11477. private _spritePredicate;
  11478. /**
  11479. * Creates a new instance of the component for the given scene
  11480. * @param scene Defines the scene to register the component in
  11481. */
  11482. constructor(scene: Scene);
  11483. /**
  11484. * Registers the component in a given scene
  11485. */
  11486. register(): void;
  11487. /**
  11488. * Rebuilds the elements related to this component in case of
  11489. * context lost for instance.
  11490. */
  11491. rebuild(): void;
  11492. /**
  11493. * Disposes the component and the associated ressources.
  11494. */
  11495. dispose(): void;
  11496. private _pickSpriteButKeepRay;
  11497. private _pointerMove;
  11498. private _pointerDown;
  11499. private _pointerUp;
  11500. }
  11501. }
  11502. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11503. /** @hidden */
  11504. export var fogFragmentDeclaration: {
  11505. name: string;
  11506. shader: string;
  11507. };
  11508. }
  11509. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11510. /** @hidden */
  11511. export var fogFragment: {
  11512. name: string;
  11513. shader: string;
  11514. };
  11515. }
  11516. declare module "babylonjs/Shaders/sprites.fragment" {
  11517. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11518. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11519. /** @hidden */
  11520. export var spritesPixelShader: {
  11521. name: string;
  11522. shader: string;
  11523. };
  11524. }
  11525. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11526. /** @hidden */
  11527. export var fogVertexDeclaration: {
  11528. name: string;
  11529. shader: string;
  11530. };
  11531. }
  11532. declare module "babylonjs/Shaders/sprites.vertex" {
  11533. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11534. /** @hidden */
  11535. export var spritesVertexShader: {
  11536. name: string;
  11537. shader: string;
  11538. };
  11539. }
  11540. declare module "babylonjs/Sprites/spriteManager" {
  11541. import { IDisposable, Scene } from "babylonjs/scene";
  11542. import { Nullable } from "babylonjs/types";
  11543. import { Observable } from "babylonjs/Misc/observable";
  11544. import { Sprite } from "babylonjs/Sprites/sprite";
  11545. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11546. import { Camera } from "babylonjs/Cameras/camera";
  11547. import { Texture } from "babylonjs/Materials/Textures/texture";
  11548. import "babylonjs/Shaders/sprites.fragment";
  11549. import "babylonjs/Shaders/sprites.vertex";
  11550. import { Ray } from "babylonjs/Culling/ray";
  11551. /**
  11552. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11553. */
  11554. export interface ISpriteManager extends IDisposable {
  11555. /**
  11556. * Restricts the camera to viewing objects with the same layerMask.
  11557. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11558. */
  11559. layerMask: number;
  11560. /**
  11561. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11562. */
  11563. isPickable: boolean;
  11564. /**
  11565. * Specifies the rendering group id for this mesh (0 by default)
  11566. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11567. */
  11568. renderingGroupId: number;
  11569. /**
  11570. * Defines the list of sprites managed by the manager.
  11571. */
  11572. sprites: Array<Sprite>;
  11573. /**
  11574. * Tests the intersection of a sprite with a specific ray.
  11575. * @param ray The ray we are sending to test the collision
  11576. * @param camera The camera space we are sending rays in
  11577. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11578. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11579. * @returns picking info or null.
  11580. */
  11581. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11582. /**
  11583. * Renders the list of sprites on screen.
  11584. */
  11585. render(): void;
  11586. }
  11587. /**
  11588. * Class used to manage multiple sprites on the same spritesheet
  11589. * @see http://doc.babylonjs.com/babylon101/sprites
  11590. */
  11591. export class SpriteManager implements ISpriteManager {
  11592. /** defines the manager's name */
  11593. name: string;
  11594. /** Gets the list of sprites */
  11595. sprites: Sprite[];
  11596. /** Gets or sets the rendering group id (0 by default) */
  11597. renderingGroupId: number;
  11598. /** Gets or sets camera layer mask */
  11599. layerMask: number;
  11600. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11601. fogEnabled: boolean;
  11602. /** Gets or sets a boolean indicating if the sprites are pickable */
  11603. isPickable: boolean;
  11604. /** Defines the default width of a cell in the spritesheet */
  11605. cellWidth: number;
  11606. /** Defines the default height of a cell in the spritesheet */
  11607. cellHeight: number;
  11608. /**
  11609. * An event triggered when the manager is disposed.
  11610. */
  11611. onDisposeObservable: Observable<SpriteManager>;
  11612. private _onDisposeObserver;
  11613. /**
  11614. * Callback called when the manager is disposed
  11615. */
  11616. onDispose: () => void;
  11617. private _capacity;
  11618. private _spriteTexture;
  11619. private _epsilon;
  11620. private _scene;
  11621. private _vertexData;
  11622. private _buffer;
  11623. private _vertexBuffers;
  11624. private _indexBuffer;
  11625. private _effectBase;
  11626. private _effectFog;
  11627. /**
  11628. * Gets or sets the spritesheet texture
  11629. */
  11630. texture: Texture;
  11631. /**
  11632. * Creates a new sprite manager
  11633. * @param name defines the manager's name
  11634. * @param imgUrl defines the sprite sheet url
  11635. * @param capacity defines the maximum allowed number of sprites
  11636. * @param cellSize defines the size of a sprite cell
  11637. * @param scene defines the hosting scene
  11638. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11639. * @param samplingMode defines the smapling mode to use with spritesheet
  11640. */
  11641. constructor(
  11642. /** defines the manager's name */
  11643. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11644. private _appendSpriteVertex;
  11645. /**
  11646. * Intersects the sprites with a ray
  11647. * @param ray defines the ray to intersect with
  11648. * @param camera defines the current active camera
  11649. * @param predicate defines a predicate used to select candidate sprites
  11650. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11651. * @returns null if no hit or a PickingInfo
  11652. */
  11653. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11654. /**
  11655. * Render all child sprites
  11656. */
  11657. render(): void;
  11658. /**
  11659. * Release associated resources
  11660. */
  11661. dispose(): void;
  11662. }
  11663. }
  11664. declare module "babylonjs/Sprites/sprite" {
  11665. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11666. import { Nullable } from "babylonjs/types";
  11667. import { ActionManager } from "babylonjs/Actions/actionManager";
  11668. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11669. /**
  11670. * Class used to represent a sprite
  11671. * @see http://doc.babylonjs.com/babylon101/sprites
  11672. */
  11673. export class Sprite {
  11674. /** defines the name */
  11675. name: string;
  11676. /** Gets or sets the current world position */
  11677. position: Vector3;
  11678. /** Gets or sets the main color */
  11679. color: Color4;
  11680. /** Gets or sets the width */
  11681. width: number;
  11682. /** Gets or sets the height */
  11683. height: number;
  11684. /** Gets or sets rotation angle */
  11685. angle: number;
  11686. /** Gets or sets the cell index in the sprite sheet */
  11687. cellIndex: number;
  11688. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11689. invertU: number;
  11690. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11691. invertV: number;
  11692. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11693. disposeWhenFinishedAnimating: boolean;
  11694. /** Gets the list of attached animations */
  11695. animations: Animation[];
  11696. /** Gets or sets a boolean indicating if the sprite can be picked */
  11697. isPickable: boolean;
  11698. /**
  11699. * Gets or sets the associated action manager
  11700. */
  11701. actionManager: Nullable<ActionManager>;
  11702. private _animationStarted;
  11703. private _loopAnimation;
  11704. private _fromIndex;
  11705. private _toIndex;
  11706. private _delay;
  11707. private _direction;
  11708. private _manager;
  11709. private _time;
  11710. private _onAnimationEnd;
  11711. /**
  11712. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11713. */
  11714. isVisible: boolean;
  11715. /**
  11716. * Gets or sets the sprite size
  11717. */
  11718. size: number;
  11719. /**
  11720. * Creates a new Sprite
  11721. * @param name defines the name
  11722. * @param manager defines the manager
  11723. */
  11724. constructor(
  11725. /** defines the name */
  11726. name: string, manager: ISpriteManager);
  11727. /**
  11728. * Starts an animation
  11729. * @param from defines the initial key
  11730. * @param to defines the end key
  11731. * @param loop defines if the animation must loop
  11732. * @param delay defines the start delay (in ms)
  11733. * @param onAnimationEnd defines a callback to call when animation ends
  11734. */
  11735. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11736. /** Stops current animation (if any) */
  11737. stopAnimation(): void;
  11738. /** @hidden */
  11739. _animate(deltaTime: number): void;
  11740. /** Release associated resources */
  11741. dispose(): void;
  11742. }
  11743. }
  11744. declare module "babylonjs/Collisions/pickingInfo" {
  11745. import { Nullable } from "babylonjs/types";
  11746. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  11747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11748. import { Sprite } from "babylonjs/Sprites/sprite";
  11749. import { Ray } from "babylonjs/Culling/ray";
  11750. /**
  11751. * Information about the result of picking within a scene
  11752. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11753. */
  11754. export class PickingInfo {
  11755. /** @hidden */
  11756. _pickingUnavailable: boolean;
  11757. /**
  11758. * If the pick collided with an object
  11759. */
  11760. hit: boolean;
  11761. /**
  11762. * Distance away where the pick collided
  11763. */
  11764. distance: number;
  11765. /**
  11766. * The location of pick collision
  11767. */
  11768. pickedPoint: Nullable<Vector3>;
  11769. /**
  11770. * The mesh corresponding the the pick collision
  11771. */
  11772. pickedMesh: Nullable<AbstractMesh>;
  11773. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11774. bu: number;
  11775. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11776. bv: number;
  11777. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11778. faceId: number;
  11779. /** Id of the the submesh that was picked */
  11780. subMeshId: number;
  11781. /** If a sprite was picked, this will be the sprite the pick collided with */
  11782. pickedSprite: Nullable<Sprite>;
  11783. /**
  11784. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11785. */
  11786. originMesh: Nullable<AbstractMesh>;
  11787. /**
  11788. * The ray that was used to perform the picking.
  11789. */
  11790. ray: Nullable<Ray>;
  11791. /**
  11792. * Gets the normal correspodning to the face the pick collided with
  11793. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11794. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11795. * @returns The normal correspodning to the face the pick collided with
  11796. */
  11797. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11798. /**
  11799. * Gets the texture coordinates of where the pick occured
  11800. * @returns the vector containing the coordnates of the texture
  11801. */
  11802. getTextureCoordinates(): Nullable<Vector2>;
  11803. }
  11804. }
  11805. declare module "babylonjs/Events/pointerEvents" {
  11806. import { Nullable } from "babylonjs/types";
  11807. import { Vector2 } from "babylonjs/Maths/math";
  11808. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11809. import { Ray } from "babylonjs/Culling/ray";
  11810. /**
  11811. * Gather the list of pointer event types as constants.
  11812. */
  11813. export class PointerEventTypes {
  11814. /**
  11815. * 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.
  11816. */
  11817. static readonly POINTERDOWN: number;
  11818. /**
  11819. * The pointerup event is fired when a pointer is no longer active.
  11820. */
  11821. static readonly POINTERUP: number;
  11822. /**
  11823. * The pointermove event is fired when a pointer changes coordinates.
  11824. */
  11825. static readonly POINTERMOVE: number;
  11826. /**
  11827. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11828. */
  11829. static readonly POINTERWHEEL: number;
  11830. /**
  11831. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11832. */
  11833. static readonly POINTERPICK: number;
  11834. /**
  11835. * The pointertap event is fired when a the object has been touched and released without drag.
  11836. */
  11837. static readonly POINTERTAP: number;
  11838. /**
  11839. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11840. */
  11841. static readonly POINTERDOUBLETAP: number;
  11842. }
  11843. /**
  11844. * Base class of pointer info types.
  11845. */
  11846. export class PointerInfoBase {
  11847. /**
  11848. * Defines the type of event (PointerEventTypes)
  11849. */
  11850. type: number;
  11851. /**
  11852. * Defines the related dom event
  11853. */
  11854. event: PointerEvent | MouseWheelEvent;
  11855. /**
  11856. * Instantiates the base class of pointers info.
  11857. * @param type Defines the type of event (PointerEventTypes)
  11858. * @param event Defines the related dom event
  11859. */
  11860. constructor(
  11861. /**
  11862. * Defines the type of event (PointerEventTypes)
  11863. */
  11864. type: number,
  11865. /**
  11866. * Defines the related dom event
  11867. */
  11868. event: PointerEvent | MouseWheelEvent);
  11869. }
  11870. /**
  11871. * This class is used to store pointer related info for the onPrePointerObservable event.
  11872. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11873. */
  11874. export class PointerInfoPre extends PointerInfoBase {
  11875. /**
  11876. * Ray from a pointer if availible (eg. 6dof controller)
  11877. */
  11878. ray: Nullable<Ray>;
  11879. /**
  11880. * Defines the local position of the pointer on the canvas.
  11881. */
  11882. localPosition: Vector2;
  11883. /**
  11884. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11885. */
  11886. skipOnPointerObservable: boolean;
  11887. /**
  11888. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11889. * @param type Defines the type of event (PointerEventTypes)
  11890. * @param event Defines the related dom event
  11891. * @param localX Defines the local x coordinates of the pointer when the event occured
  11892. * @param localY Defines the local y coordinates of the pointer when the event occured
  11893. */
  11894. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11895. }
  11896. /**
  11897. * This type contains all the data related to a pointer event in Babylon.js.
  11898. * 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.
  11899. */
  11900. export class PointerInfo extends PointerInfoBase {
  11901. /**
  11902. * Defines the picking info associated to the info (if any)\
  11903. */
  11904. pickInfo: Nullable<PickingInfo>;
  11905. /**
  11906. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11907. * @param type Defines the type of event (PointerEventTypes)
  11908. * @param event Defines the related dom event
  11909. * @param pickInfo Defines the picking info associated to the info (if any)\
  11910. */
  11911. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11912. /**
  11913. * Defines the picking info associated to the info (if any)\
  11914. */
  11915. pickInfo: Nullable<PickingInfo>);
  11916. }
  11917. }
  11918. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11919. import { Nullable } from "babylonjs/types";
  11920. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11921. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11922. /**
  11923. * Manage the mouse inputs to control the movement of a free camera.
  11924. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11925. */
  11926. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11927. /**
  11928. * Define if touch is enabled in the mouse input
  11929. */
  11930. touchEnabled: boolean;
  11931. /**
  11932. * Defines the camera the input is attached to.
  11933. */
  11934. camera: FreeCamera;
  11935. /**
  11936. * Defines the buttons associated with the input to handle camera move.
  11937. */
  11938. buttons: number[];
  11939. /**
  11940. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11941. */
  11942. angularSensibility: number;
  11943. private _pointerInput;
  11944. private _onMouseMove;
  11945. private _observer;
  11946. private previousPosition;
  11947. /**
  11948. * Manage the mouse inputs to control the movement of a free camera.
  11949. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11950. * @param touchEnabled Defines if touch is enabled or not
  11951. */
  11952. constructor(
  11953. /**
  11954. * Define if touch is enabled in the mouse input
  11955. */
  11956. touchEnabled?: boolean);
  11957. /**
  11958. * Attach the input controls to a specific dom element to get the input from.
  11959. * @param element Defines the element the controls should be listened from
  11960. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11961. */
  11962. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11963. /**
  11964. * Detach the current controls from the specified dom element.
  11965. * @param element Defines the element to stop listening the inputs from
  11966. */
  11967. detachControl(element: Nullable<HTMLElement>): void;
  11968. /**
  11969. * Gets the class name of the current intput.
  11970. * @returns the class name
  11971. */
  11972. getClassName(): string;
  11973. /**
  11974. * Get the friendly name associated with the input class.
  11975. * @returns the input friendly name
  11976. */
  11977. getSimpleName(): string;
  11978. }
  11979. }
  11980. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  11981. import { Nullable } from "babylonjs/types";
  11982. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11983. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11984. /**
  11985. * Manage the touch inputs to control the movement of a free camera.
  11986. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11987. */
  11988. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11989. /**
  11990. * Defines the camera the input is attached to.
  11991. */
  11992. camera: FreeCamera;
  11993. /**
  11994. * Defines the touch sensibility for rotation.
  11995. * The higher the faster.
  11996. */
  11997. touchAngularSensibility: number;
  11998. /**
  11999. * Defines the touch sensibility for move.
  12000. * The higher the faster.
  12001. */
  12002. touchMoveSensibility: number;
  12003. private _offsetX;
  12004. private _offsetY;
  12005. private _pointerPressed;
  12006. private _pointerInput;
  12007. private _observer;
  12008. private _onLostFocus;
  12009. /**
  12010. * Attach the input controls to a specific dom element to get the input from.
  12011. * @param element Defines the element the controls should be listened from
  12012. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12013. */
  12014. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12015. /**
  12016. * Detach the current controls from the specified dom element.
  12017. * @param element Defines the element to stop listening the inputs from
  12018. */
  12019. detachControl(element: Nullable<HTMLElement>): void;
  12020. /**
  12021. * Update the current camera state depending on the inputs that have been used this frame.
  12022. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12023. */
  12024. checkInputs(): void;
  12025. /**
  12026. * Gets the class name of the current intput.
  12027. * @returns the class name
  12028. */
  12029. getClassName(): string;
  12030. /**
  12031. * Get the friendly name associated with the input class.
  12032. * @returns the input friendly name
  12033. */
  12034. getSimpleName(): string;
  12035. }
  12036. }
  12037. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12038. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12039. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12040. /**
  12041. * Default Inputs manager for the FreeCamera.
  12042. * It groups all the default supported inputs for ease of use.
  12043. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12044. */
  12045. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12046. /**
  12047. * Instantiates a new FreeCameraInputsManager.
  12048. * @param camera Defines the camera the inputs belong to
  12049. */
  12050. constructor(camera: FreeCamera);
  12051. /**
  12052. * Add keyboard input support to the input manager.
  12053. * @returns the current input manager
  12054. */
  12055. addKeyboard(): FreeCameraInputsManager;
  12056. /**
  12057. * Add mouse input support to the input manager.
  12058. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12059. * @returns the current input manager
  12060. */
  12061. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12062. /**
  12063. * Add touch input support to the input manager.
  12064. * @returns the current input manager
  12065. */
  12066. addTouch(): FreeCameraInputsManager;
  12067. }
  12068. }
  12069. declare module "babylonjs/Cameras/freeCamera" {
  12070. import { Vector3 } from "babylonjs/Maths/math";
  12071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12072. import { Scene } from "babylonjs/scene";
  12073. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12074. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12075. /**
  12076. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12077. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12078. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12079. */
  12080. export class FreeCamera extends TargetCamera {
  12081. /**
  12082. * Define the collision ellipsoid of the camera.
  12083. * This is helpful to simulate a camera body like the player body around the camera
  12084. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12085. */
  12086. ellipsoid: Vector3;
  12087. /**
  12088. * Define an offset for the position of the ellipsoid around the camera.
  12089. * This can be helpful to determine the center of the body near the gravity center of the body
  12090. * instead of its head.
  12091. */
  12092. ellipsoidOffset: Vector3;
  12093. /**
  12094. * Enable or disable collisions of the camera with the rest of the scene objects.
  12095. */
  12096. checkCollisions: boolean;
  12097. /**
  12098. * Enable or disable gravity on the camera.
  12099. */
  12100. applyGravity: boolean;
  12101. /**
  12102. * Define the input manager associated to the camera.
  12103. */
  12104. inputs: FreeCameraInputsManager;
  12105. /**
  12106. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12107. * Higher values reduce sensitivity.
  12108. */
  12109. /**
  12110. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12111. * Higher values reduce sensitivity.
  12112. */
  12113. angularSensibility: number;
  12114. /**
  12115. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12116. */
  12117. keysUp: number[];
  12118. /**
  12119. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12120. */
  12121. keysDown: number[];
  12122. /**
  12123. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12124. */
  12125. keysLeft: number[];
  12126. /**
  12127. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12128. */
  12129. keysRight: number[];
  12130. /**
  12131. * Event raised when the camera collide with a mesh in the scene.
  12132. */
  12133. onCollide: (collidedMesh: AbstractMesh) => void;
  12134. private _collider;
  12135. private _needMoveForGravity;
  12136. private _oldPosition;
  12137. private _diffPosition;
  12138. private _newPosition;
  12139. /** @hidden */
  12140. _localDirection: Vector3;
  12141. /** @hidden */
  12142. _transformedDirection: Vector3;
  12143. /**
  12144. * Instantiates a Free Camera.
  12145. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12146. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12147. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12148. * @param name Define the name of the camera in the scene
  12149. * @param position Define the start position of the camera in the scene
  12150. * @param scene Define the scene the camera belongs to
  12151. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12152. */
  12153. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12154. /**
  12155. * Attached controls to the current camera.
  12156. * @param element Defines the element the controls should be listened from
  12157. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12158. */
  12159. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12160. /**
  12161. * Detach the current controls from the camera.
  12162. * The camera will stop reacting to inputs.
  12163. * @param element Defines the element to stop listening the inputs from
  12164. */
  12165. detachControl(element: HTMLElement): void;
  12166. private _collisionMask;
  12167. /**
  12168. * Define a collision mask to limit the list of object the camera can collide with
  12169. */
  12170. collisionMask: number;
  12171. /** @hidden */
  12172. _collideWithWorld(displacement: Vector3): void;
  12173. private _onCollisionPositionChange;
  12174. /** @hidden */
  12175. _checkInputs(): void;
  12176. /** @hidden */
  12177. _decideIfNeedsToMove(): boolean;
  12178. /** @hidden */
  12179. _updatePosition(): void;
  12180. /**
  12181. * Destroy the camera and release the current resources hold by it.
  12182. */
  12183. dispose(): void;
  12184. /**
  12185. * Gets the current object class name.
  12186. * @return the class name
  12187. */
  12188. getClassName(): string;
  12189. }
  12190. }
  12191. declare module "babylonjs/Gamepads/gamepad" {
  12192. import { Observable } from "babylonjs/Misc/observable";
  12193. /**
  12194. * Represents a gamepad control stick position
  12195. */
  12196. export class StickValues {
  12197. /**
  12198. * The x component of the control stick
  12199. */
  12200. x: number;
  12201. /**
  12202. * The y component of the control stick
  12203. */
  12204. y: number;
  12205. /**
  12206. * Initializes the gamepad x and y control stick values
  12207. * @param x The x component of the gamepad control stick value
  12208. * @param y The y component of the gamepad control stick value
  12209. */
  12210. constructor(
  12211. /**
  12212. * The x component of the control stick
  12213. */
  12214. x: number,
  12215. /**
  12216. * The y component of the control stick
  12217. */
  12218. y: number);
  12219. }
  12220. /**
  12221. * An interface which manages callbacks for gamepad button changes
  12222. */
  12223. export interface GamepadButtonChanges {
  12224. /**
  12225. * Called when a gamepad has been changed
  12226. */
  12227. changed: boolean;
  12228. /**
  12229. * Called when a gamepad press event has been triggered
  12230. */
  12231. pressChanged: boolean;
  12232. /**
  12233. * Called when a touch event has been triggered
  12234. */
  12235. touchChanged: boolean;
  12236. /**
  12237. * Called when a value has changed
  12238. */
  12239. valueChanged: boolean;
  12240. }
  12241. /**
  12242. * Represents a gamepad
  12243. */
  12244. export class Gamepad {
  12245. /**
  12246. * The id of the gamepad
  12247. */
  12248. id: string;
  12249. /**
  12250. * The index of the gamepad
  12251. */
  12252. index: number;
  12253. /**
  12254. * The browser gamepad
  12255. */
  12256. browserGamepad: any;
  12257. /**
  12258. * Specifies what type of gamepad this represents
  12259. */
  12260. type: number;
  12261. private _leftStick;
  12262. private _rightStick;
  12263. /** @hidden */
  12264. _isConnected: boolean;
  12265. private _leftStickAxisX;
  12266. private _leftStickAxisY;
  12267. private _rightStickAxisX;
  12268. private _rightStickAxisY;
  12269. /**
  12270. * Triggered when the left control stick has been changed
  12271. */
  12272. private _onleftstickchanged;
  12273. /**
  12274. * Triggered when the right control stick has been changed
  12275. */
  12276. private _onrightstickchanged;
  12277. /**
  12278. * Represents a gamepad controller
  12279. */
  12280. static GAMEPAD: number;
  12281. /**
  12282. * Represents a generic controller
  12283. */
  12284. static GENERIC: number;
  12285. /**
  12286. * Represents an XBox controller
  12287. */
  12288. static XBOX: number;
  12289. /**
  12290. * Represents a pose-enabled controller
  12291. */
  12292. static POSE_ENABLED: number;
  12293. /**
  12294. * Specifies whether the left control stick should be Y-inverted
  12295. */
  12296. protected _invertLeftStickY: boolean;
  12297. /**
  12298. * Specifies if the gamepad has been connected
  12299. */
  12300. readonly isConnected: boolean;
  12301. /**
  12302. * Initializes the gamepad
  12303. * @param id The id of the gamepad
  12304. * @param index The index of the gamepad
  12305. * @param browserGamepad The browser gamepad
  12306. * @param leftStickX The x component of the left joystick
  12307. * @param leftStickY The y component of the left joystick
  12308. * @param rightStickX The x component of the right joystick
  12309. * @param rightStickY The y component of the right joystick
  12310. */
  12311. constructor(
  12312. /**
  12313. * The id of the gamepad
  12314. */
  12315. id: string,
  12316. /**
  12317. * The index of the gamepad
  12318. */
  12319. index: number,
  12320. /**
  12321. * The browser gamepad
  12322. */
  12323. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12324. /**
  12325. * Callback triggered when the left joystick has changed
  12326. * @param callback
  12327. */
  12328. onleftstickchanged(callback: (values: StickValues) => void): void;
  12329. /**
  12330. * Callback triggered when the right joystick has changed
  12331. * @param callback
  12332. */
  12333. onrightstickchanged(callback: (values: StickValues) => void): void;
  12334. /**
  12335. * Gets the left joystick
  12336. */
  12337. /**
  12338. * Sets the left joystick values
  12339. */
  12340. leftStick: StickValues;
  12341. /**
  12342. * Gets the right joystick
  12343. */
  12344. /**
  12345. * Sets the right joystick value
  12346. */
  12347. rightStick: StickValues;
  12348. /**
  12349. * Updates the gamepad joystick positions
  12350. */
  12351. update(): void;
  12352. /**
  12353. * Disposes the gamepad
  12354. */
  12355. dispose(): void;
  12356. }
  12357. /**
  12358. * Represents a generic gamepad
  12359. */
  12360. export class GenericPad extends Gamepad {
  12361. private _buttons;
  12362. private _onbuttondown;
  12363. private _onbuttonup;
  12364. /**
  12365. * Observable triggered when a button has been pressed
  12366. */
  12367. onButtonDownObservable: Observable<number>;
  12368. /**
  12369. * Observable triggered when a button has been released
  12370. */
  12371. onButtonUpObservable: Observable<number>;
  12372. /**
  12373. * Callback triggered when a button has been pressed
  12374. * @param callback Called when a button has been pressed
  12375. */
  12376. onbuttondown(callback: (buttonPressed: number) => void): void;
  12377. /**
  12378. * Callback triggered when a button has been released
  12379. * @param callback Called when a button has been released
  12380. */
  12381. onbuttonup(callback: (buttonReleased: number) => void): void;
  12382. /**
  12383. * Initializes the generic gamepad
  12384. * @param id The id of the generic gamepad
  12385. * @param index The index of the generic gamepad
  12386. * @param browserGamepad The browser gamepad
  12387. */
  12388. constructor(id: string, index: number, browserGamepad: any);
  12389. private _setButtonValue;
  12390. /**
  12391. * Updates the generic gamepad
  12392. */
  12393. update(): void;
  12394. /**
  12395. * Disposes the generic gamepad
  12396. */
  12397. dispose(): void;
  12398. }
  12399. }
  12400. declare module "babylonjs/Meshes/transformNode" {
  12401. import { DeepImmutable } from "babylonjs/types";
  12402. import { Observable } from "babylonjs/Misc/observable";
  12403. import { Nullable } from "babylonjs/types";
  12404. import { Camera } from "babylonjs/Cameras/camera";
  12405. import { Scene } from "babylonjs/scene";
  12406. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  12407. import { Node } from "babylonjs/node";
  12408. import { Bone } from "babylonjs/Bones/bone";
  12409. /**
  12410. * 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.
  12411. * @see https://doc.babylonjs.com/how_to/transformnode
  12412. */
  12413. export class TransformNode extends Node {
  12414. /**
  12415. * Object will not rotate to face the camera
  12416. */
  12417. static BILLBOARDMODE_NONE: number;
  12418. /**
  12419. * Object will rotate to face the camera but only on the x axis
  12420. */
  12421. static BILLBOARDMODE_X: number;
  12422. /**
  12423. * Object will rotate to face the camera but only on the y axis
  12424. */
  12425. static BILLBOARDMODE_Y: number;
  12426. /**
  12427. * Object will rotate to face the camera but only on the z axis
  12428. */
  12429. static BILLBOARDMODE_Z: number;
  12430. /**
  12431. * Object will rotate to face the camera
  12432. */
  12433. static BILLBOARDMODE_ALL: number;
  12434. private _forward;
  12435. private _forwardInverted;
  12436. private _up;
  12437. private _right;
  12438. private _rightInverted;
  12439. private _position;
  12440. private _rotation;
  12441. private _rotationQuaternion;
  12442. protected _scaling: Vector3;
  12443. protected _isDirty: boolean;
  12444. private _transformToBoneReferal;
  12445. /**
  12446. * Set the billboard mode. Default is 0.
  12447. *
  12448. * | Value | Type | Description |
  12449. * | --- | --- | --- |
  12450. * | 0 | BILLBOARDMODE_NONE | |
  12451. * | 1 | BILLBOARDMODE_X | |
  12452. * | 2 | BILLBOARDMODE_Y | |
  12453. * | 4 | BILLBOARDMODE_Z | |
  12454. * | 7 | BILLBOARDMODE_ALL | |
  12455. *
  12456. */
  12457. billboardMode: number;
  12458. /**
  12459. * 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
  12460. */
  12461. scalingDeterminant: number;
  12462. /**
  12463. * Sets the distance of the object to max, often used by skybox
  12464. */
  12465. infiniteDistance: boolean;
  12466. /**
  12467. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  12468. * By default the system will update normals to compensate
  12469. */
  12470. ignoreNonUniformScaling: boolean;
  12471. /** @hidden */
  12472. _poseMatrix: Matrix;
  12473. /** @hidden */
  12474. _localMatrix: Matrix;
  12475. private _absolutePosition;
  12476. private _pivotMatrix;
  12477. private _pivotMatrixInverse;
  12478. protected _postMultiplyPivotMatrix: boolean;
  12479. protected _isWorldMatrixFrozen: boolean;
  12480. /** @hidden */
  12481. _indexInSceneTransformNodesArray: number;
  12482. /**
  12483. * An event triggered after the world matrix is updated
  12484. */
  12485. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  12486. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  12487. /**
  12488. * Gets a string identifying the name of the class
  12489. * @returns "TransformNode" string
  12490. */
  12491. getClassName(): string;
  12492. /**
  12493. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  12494. */
  12495. position: Vector3;
  12496. /**
  12497. * 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)).
  12498. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  12499. */
  12500. rotation: Vector3;
  12501. /**
  12502. * 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)).
  12503. */
  12504. scaling: Vector3;
  12505. /**
  12506. * 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).
  12507. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  12508. */
  12509. rotationQuaternion: Nullable<Quaternion>;
  12510. /**
  12511. * The forward direction of that transform in world space.
  12512. */
  12513. readonly forward: Vector3;
  12514. /**
  12515. * The up direction of that transform in world space.
  12516. */
  12517. readonly up: Vector3;
  12518. /**
  12519. * The right direction of that transform in world space.
  12520. */
  12521. readonly right: Vector3;
  12522. /**
  12523. * Copies the parameter passed Matrix into the mesh Pose matrix.
  12524. * @param matrix the matrix to copy the pose from
  12525. * @returns this TransformNode.
  12526. */
  12527. updatePoseMatrix(matrix: Matrix): TransformNode;
  12528. /**
  12529. * Returns the mesh Pose matrix.
  12530. * @returns the pose matrix
  12531. */
  12532. getPoseMatrix(): Matrix;
  12533. /** @hidden */
  12534. _isSynchronized(): boolean;
  12535. /** @hidden */
  12536. _initCache(): void;
  12537. /**
  12538. * Flag the transform node as dirty (Forcing it to update everything)
  12539. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  12540. * @returns this transform node
  12541. */
  12542. markAsDirty(property: string): TransformNode;
  12543. /**
  12544. * Returns the current mesh absolute position.
  12545. * Returns a Vector3.
  12546. */
  12547. readonly absolutePosition: Vector3;
  12548. /**
  12549. * Sets a new matrix to apply before all other transformation
  12550. * @param matrix defines the transform matrix
  12551. * @returns the current TransformNode
  12552. */
  12553. setPreTransformMatrix(matrix: Matrix): TransformNode;
  12554. /**
  12555. * Sets a new pivot matrix to the current node
  12556. * @param matrix defines the new pivot matrix to use
  12557. * @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
  12558. * @returns the current TransformNode
  12559. */
  12560. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  12561. /**
  12562. * Returns the mesh pivot matrix.
  12563. * Default : Identity.
  12564. * @returns the matrix
  12565. */
  12566. getPivotMatrix(): Matrix;
  12567. /**
  12568. * Prevents the World matrix to be computed any longer.
  12569. * @returns the TransformNode.
  12570. */
  12571. freezeWorldMatrix(): TransformNode;
  12572. /**
  12573. * Allows back the World matrix computation.
  12574. * @returns the TransformNode.
  12575. */
  12576. unfreezeWorldMatrix(): this;
  12577. /**
  12578. * True if the World matrix has been frozen.
  12579. */
  12580. readonly isWorldMatrixFrozen: boolean;
  12581. /**
  12582. * Retuns the mesh absolute position in the World.
  12583. * @returns a Vector3.
  12584. */
  12585. getAbsolutePosition(): Vector3;
  12586. /**
  12587. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  12588. * @param absolutePosition the absolute position to set
  12589. * @returns the TransformNode.
  12590. */
  12591. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  12592. /**
  12593. * Sets the mesh position in its local space.
  12594. * @param vector3 the position to set in localspace
  12595. * @returns the TransformNode.
  12596. */
  12597. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  12598. /**
  12599. * Returns the mesh position in the local space from the current World matrix values.
  12600. * @returns a new Vector3.
  12601. */
  12602. getPositionExpressedInLocalSpace(): Vector3;
  12603. /**
  12604. * Translates the mesh along the passed Vector3 in its local space.
  12605. * @param vector3 the distance to translate in localspace
  12606. * @returns the TransformNode.
  12607. */
  12608. locallyTranslate(vector3: Vector3): TransformNode;
  12609. private static _lookAtVectorCache;
  12610. /**
  12611. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  12612. * @param targetPoint the position (must be in same space as current mesh) to look at
  12613. * @param yawCor optional yaw (y-axis) correction in radians
  12614. * @param pitchCor optional pitch (x-axis) correction in radians
  12615. * @param rollCor optional roll (z-axis) correction in radians
  12616. * @param space the choosen space of the target
  12617. * @returns the TransformNode.
  12618. */
  12619. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  12620. /**
  12621. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  12622. * This Vector3 is expressed in the World space.
  12623. * @param localAxis axis to rotate
  12624. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  12625. */
  12626. getDirection(localAxis: Vector3): Vector3;
  12627. /**
  12628. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  12629. * localAxis is expressed in the mesh local space.
  12630. * result is computed in the Wordl space from the mesh World matrix.
  12631. * @param localAxis axis to rotate
  12632. * @param result the resulting transformnode
  12633. * @returns this TransformNode.
  12634. */
  12635. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  12636. /**
  12637. * Sets this transform node rotation to the given local axis.
  12638. * @param localAxis the axis in local space
  12639. * @param yawCor optional yaw (y-axis) correction in radians
  12640. * @param pitchCor optional pitch (x-axis) correction in radians
  12641. * @param rollCor optional roll (z-axis) correction in radians
  12642. * @returns this TransformNode
  12643. */
  12644. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  12645. /**
  12646. * Sets a new pivot point to the current node
  12647. * @param point defines the new pivot point to use
  12648. * @param space defines if the point is in world or local space (local by default)
  12649. * @returns the current TransformNode
  12650. */
  12651. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  12652. /**
  12653. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  12654. * @returns the pivot point
  12655. */
  12656. getPivotPoint(): Vector3;
  12657. /**
  12658. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  12659. * @param result the vector3 to store the result
  12660. * @returns this TransformNode.
  12661. */
  12662. getPivotPointToRef(result: Vector3): TransformNode;
  12663. /**
  12664. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  12665. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  12666. */
  12667. getAbsolutePivotPoint(): Vector3;
  12668. /**
  12669. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  12670. * @param result vector3 to store the result
  12671. * @returns this TransformNode.
  12672. */
  12673. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  12674. /**
  12675. * Defines the passed node as the parent of the current node.
  12676. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  12677. * @param node the node ot set as the parent
  12678. * @returns this TransformNode.
  12679. */
  12680. setParent(node: Nullable<Node>): TransformNode;
  12681. private _nonUniformScaling;
  12682. /**
  12683. * True if the scaling property of this object is non uniform eg. (1,2,1)
  12684. */
  12685. readonly nonUniformScaling: boolean;
  12686. /** @hidden */
  12687. _updateNonUniformScalingState(value: boolean): boolean;
  12688. /**
  12689. * Attach the current TransformNode to another TransformNode associated with a bone
  12690. * @param bone Bone affecting the TransformNode
  12691. * @param affectedTransformNode TransformNode associated with the bone
  12692. * @returns this object
  12693. */
  12694. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  12695. /**
  12696. * Detach the transform node if its associated with a bone
  12697. * @returns this object
  12698. */
  12699. detachFromBone(): TransformNode;
  12700. private static _rotationAxisCache;
  12701. /**
  12702. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  12703. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  12704. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  12705. * The passed axis is also normalized.
  12706. * @param axis the axis to rotate around
  12707. * @param amount the amount to rotate in radians
  12708. * @param space Space to rotate in (Default: local)
  12709. * @returns the TransformNode.
  12710. */
  12711. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  12712. /**
  12713. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  12714. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  12715. * The passed axis is also normalized. .
  12716. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  12717. * @param point the point to rotate around
  12718. * @param axis the axis to rotate around
  12719. * @param amount the amount to rotate in radians
  12720. * @returns the TransformNode
  12721. */
  12722. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  12723. /**
  12724. * Translates the mesh along the axis vector for the passed distance in the given space.
  12725. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  12726. * @param axis the axis to translate in
  12727. * @param distance the distance to translate
  12728. * @param space Space to rotate in (Default: local)
  12729. * @returns the TransformNode.
  12730. */
  12731. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  12732. /**
  12733. * Adds a rotation step to the mesh current rotation.
  12734. * x, y, z are Euler angles expressed in radians.
  12735. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  12736. * This means this rotation is made in the mesh local space only.
  12737. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  12738. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  12739. * ```javascript
  12740. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  12741. * ```
  12742. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  12743. * 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.
  12744. * @param x Rotation to add
  12745. * @param y Rotation to add
  12746. * @param z Rotation to add
  12747. * @returns the TransformNode.
  12748. */
  12749. addRotation(x: number, y: number, z: number): TransformNode;
  12750. /**
  12751. * Computes the world matrix of the node
  12752. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12753. * @returns the world matrix
  12754. */
  12755. computeWorldMatrix(force?: boolean): Matrix;
  12756. protected _afterComputeWorldMatrix(): void;
  12757. /**
  12758. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  12759. * @param func callback function to add
  12760. *
  12761. * @returns the TransformNode.
  12762. */
  12763. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  12764. /**
  12765. * Removes a registered callback function.
  12766. * @param func callback function to remove
  12767. * @returns the TransformNode.
  12768. */
  12769. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  12770. /**
  12771. * Gets the position of the current mesh in camera space
  12772. * @param camera defines the camera to use
  12773. * @returns a position
  12774. */
  12775. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  12776. /**
  12777. * Returns the distance from the mesh to the active camera
  12778. * @param camera defines the camera to use
  12779. * @returns the distance
  12780. */
  12781. getDistanceToCamera(camera?: Nullable<Camera>): number;
  12782. /**
  12783. * Clone the current transform node
  12784. * @param name Name of the new clone
  12785. * @param newParent New parent for the clone
  12786. * @param doNotCloneChildren Do not clone children hierarchy
  12787. * @returns the new transform node
  12788. */
  12789. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  12790. /**
  12791. * Serializes the objects information.
  12792. * @param currentSerializationObject defines the object to serialize in
  12793. * @returns the serialized object
  12794. */
  12795. serialize(currentSerializationObject?: any): any;
  12796. /**
  12797. * Returns a new TransformNode object parsed from the source provided.
  12798. * @param parsedTransformNode is the source.
  12799. * @param scene the scne the object belongs to
  12800. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  12801. * @returns a new TransformNode object parsed from the source provided.
  12802. */
  12803. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  12804. /**
  12805. * Get all child-transformNodes of this node
  12806. * @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
  12807. * @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
  12808. * @returns an array of TransformNode
  12809. */
  12810. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  12811. /**
  12812. * Releases resources associated with this transform node.
  12813. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12814. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12815. */
  12816. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12817. }
  12818. }
  12819. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12820. import { Observable } from "babylonjs/Misc/observable";
  12821. import { Nullable } from "babylonjs/types";
  12822. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12823. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12824. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12825. import { Ray } from "babylonjs/Culling/ray";
  12826. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12827. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12828. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12829. /**
  12830. * Defines the types of pose enabled controllers that are supported
  12831. */
  12832. export enum PoseEnabledControllerType {
  12833. /**
  12834. * HTC Vive
  12835. */
  12836. VIVE = 0,
  12837. /**
  12838. * Oculus Rift
  12839. */
  12840. OCULUS = 1,
  12841. /**
  12842. * Windows mixed reality
  12843. */
  12844. WINDOWS = 2,
  12845. /**
  12846. * Samsung gear VR
  12847. */
  12848. GEAR_VR = 3,
  12849. /**
  12850. * Google Daydream
  12851. */
  12852. DAYDREAM = 4,
  12853. /**
  12854. * Generic
  12855. */
  12856. GENERIC = 5
  12857. }
  12858. /**
  12859. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12860. */
  12861. export interface MutableGamepadButton {
  12862. /**
  12863. * Value of the button/trigger
  12864. */
  12865. value: number;
  12866. /**
  12867. * If the button/trigger is currently touched
  12868. */
  12869. touched: boolean;
  12870. /**
  12871. * If the button/trigger is currently pressed
  12872. */
  12873. pressed: boolean;
  12874. }
  12875. /**
  12876. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12877. * @hidden
  12878. */
  12879. export interface ExtendedGamepadButton extends GamepadButton {
  12880. /**
  12881. * If the button/trigger is currently pressed
  12882. */
  12883. readonly pressed: boolean;
  12884. /**
  12885. * If the button/trigger is currently touched
  12886. */
  12887. readonly touched: boolean;
  12888. /**
  12889. * Value of the button/trigger
  12890. */
  12891. readonly value: number;
  12892. }
  12893. /** @hidden */
  12894. export interface _GamePadFactory {
  12895. /**
  12896. * Returns wether or not the current gamepad can be created for this type of controller.
  12897. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12898. * @returns true if it can be created, otherwise false
  12899. */
  12900. canCreate(gamepadInfo: any): boolean;
  12901. /**
  12902. * Creates a new instance of the Gamepad.
  12903. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12904. * @returns the new gamepad instance
  12905. */
  12906. create(gamepadInfo: any): Gamepad;
  12907. }
  12908. /**
  12909. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12910. */
  12911. export class PoseEnabledControllerHelper {
  12912. /** @hidden */
  12913. static _ControllerFactories: _GamePadFactory[];
  12914. /** @hidden */
  12915. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12916. /**
  12917. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12918. * @param vrGamepad the gamepad to initialized
  12919. * @returns a vr controller of the type the gamepad identified as
  12920. */
  12921. static InitiateController(vrGamepad: any): Gamepad;
  12922. }
  12923. /**
  12924. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12925. */
  12926. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12927. private _deviceRoomPosition;
  12928. private _deviceRoomRotationQuaternion;
  12929. /**
  12930. * The device position in babylon space
  12931. */
  12932. devicePosition: Vector3;
  12933. /**
  12934. * The device rotation in babylon space
  12935. */
  12936. deviceRotationQuaternion: Quaternion;
  12937. /**
  12938. * The scale factor of the device in babylon space
  12939. */
  12940. deviceScaleFactor: number;
  12941. /**
  12942. * (Likely devicePosition should be used instead) The device position in its room space
  12943. */
  12944. position: Vector3;
  12945. /**
  12946. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12947. */
  12948. rotationQuaternion: Quaternion;
  12949. /**
  12950. * The type of controller (Eg. Windows mixed reality)
  12951. */
  12952. controllerType: PoseEnabledControllerType;
  12953. protected _calculatedPosition: Vector3;
  12954. private _calculatedRotation;
  12955. /**
  12956. * The raw pose from the device
  12957. */
  12958. rawPose: DevicePose;
  12959. private _trackPosition;
  12960. private _maxRotationDistFromHeadset;
  12961. private _draggedRoomRotation;
  12962. /**
  12963. * @hidden
  12964. */
  12965. _disableTrackPosition(fixedPosition: Vector3): void;
  12966. /**
  12967. * Internal, the mesh attached to the controller
  12968. * @hidden
  12969. */
  12970. _mesh: Nullable<AbstractMesh>;
  12971. private _poseControlledCamera;
  12972. private _leftHandSystemQuaternion;
  12973. /**
  12974. * Internal, matrix used to convert room space to babylon space
  12975. * @hidden
  12976. */
  12977. _deviceToWorld: Matrix;
  12978. /**
  12979. * Node to be used when casting a ray from the controller
  12980. * @hidden
  12981. */
  12982. _pointingPoseNode: Nullable<TransformNode>;
  12983. /**
  12984. * Name of the child mesh that can be used to cast a ray from the controller
  12985. */
  12986. static readonly POINTING_POSE: string;
  12987. /**
  12988. * Creates a new PoseEnabledController from a gamepad
  12989. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12990. */
  12991. constructor(browserGamepad: any);
  12992. private _workingMatrix;
  12993. /**
  12994. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12995. */
  12996. update(): void;
  12997. /**
  12998. * Updates only the pose device and mesh without doing any button event checking
  12999. */
  13000. protected _updatePoseAndMesh(): void;
  13001. /**
  13002. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  13003. * @param poseData raw pose fromthe device
  13004. */
  13005. updateFromDevice(poseData: DevicePose): void;
  13006. /**
  13007. * @hidden
  13008. */
  13009. _meshAttachedObservable: Observable<AbstractMesh>;
  13010. /**
  13011. * Attaches a mesh to the controller
  13012. * @param mesh the mesh to be attached
  13013. */
  13014. attachToMesh(mesh: AbstractMesh): void;
  13015. /**
  13016. * Attaches the controllers mesh to a camera
  13017. * @param camera the camera the mesh should be attached to
  13018. */
  13019. attachToPoseControlledCamera(camera: TargetCamera): void;
  13020. /**
  13021. * Disposes of the controller
  13022. */
  13023. dispose(): void;
  13024. /**
  13025. * The mesh that is attached to the controller
  13026. */
  13027. readonly mesh: Nullable<AbstractMesh>;
  13028. /**
  13029. * Gets the ray of the controller in the direction the controller is pointing
  13030. * @param length the length the resulting ray should be
  13031. * @returns a ray in the direction the controller is pointing
  13032. */
  13033. getForwardRay(length?: number): Ray;
  13034. }
  13035. }
  13036. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13037. import { Observable } from "babylonjs/Misc/observable";
  13038. import { Scene } from "babylonjs/scene";
  13039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13040. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13041. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13042. /**
  13043. * Defines the WebVRController object that represents controllers tracked in 3D space
  13044. */
  13045. export abstract class WebVRController extends PoseEnabledController {
  13046. /**
  13047. * Internal, the default controller model for the controller
  13048. */
  13049. protected _defaultModel: AbstractMesh;
  13050. /**
  13051. * Fired when the trigger state has changed
  13052. */
  13053. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13054. /**
  13055. * Fired when the main button state has changed
  13056. */
  13057. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13058. /**
  13059. * Fired when the secondary button state has changed
  13060. */
  13061. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13062. /**
  13063. * Fired when the pad state has changed
  13064. */
  13065. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13066. /**
  13067. * Fired when controllers stick values have changed
  13068. */
  13069. onPadValuesChangedObservable: Observable<StickValues>;
  13070. /**
  13071. * Array of button availible on the controller
  13072. */
  13073. protected _buttons: Array<MutableGamepadButton>;
  13074. private _onButtonStateChange;
  13075. /**
  13076. * Fired when a controller button's state has changed
  13077. * @param callback the callback containing the button that was modified
  13078. */
  13079. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13080. /**
  13081. * X and Y axis corrisponding to the controllers joystick
  13082. */
  13083. pad: StickValues;
  13084. /**
  13085. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13086. */
  13087. hand: string;
  13088. /**
  13089. * The default controller model for the controller
  13090. */
  13091. readonly defaultModel: AbstractMesh;
  13092. /**
  13093. * Creates a new WebVRController from a gamepad
  13094. * @param vrGamepad the gamepad that the WebVRController should be created from
  13095. */
  13096. constructor(vrGamepad: any);
  13097. /**
  13098. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13099. */
  13100. update(): void;
  13101. /**
  13102. * Function to be called when a button is modified
  13103. */
  13104. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13105. /**
  13106. * Loads a mesh and attaches it to the controller
  13107. * @param scene the scene the mesh should be added to
  13108. * @param meshLoaded callback for when the mesh has been loaded
  13109. */
  13110. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13111. private _setButtonValue;
  13112. private _changes;
  13113. private _checkChanges;
  13114. /**
  13115. * Disposes of th webVRCOntroller
  13116. */
  13117. dispose(): void;
  13118. }
  13119. }
  13120. declare module "babylonjs/Lights/hemisphericLight" {
  13121. import { Nullable } from "babylonjs/types";
  13122. import { Scene } from "babylonjs/scene";
  13123. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13124. import { Effect } from "babylonjs/Materials/effect";
  13125. import { Light } from "babylonjs/Lights/light";
  13126. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13127. /**
  13128. * The HemisphericLight simulates the ambient environment light,
  13129. * so the passed direction is the light reflection direction, not the incoming direction.
  13130. */
  13131. export class HemisphericLight extends Light {
  13132. /**
  13133. * The groundColor is the light in the opposite direction to the one specified during creation.
  13134. * 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.
  13135. */
  13136. groundColor: Color3;
  13137. /**
  13138. * The light reflection direction, not the incoming direction.
  13139. */
  13140. direction: Vector3;
  13141. /**
  13142. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13143. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13144. * The HemisphericLight can't cast shadows.
  13145. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13146. * @param name The friendly name of the light
  13147. * @param direction The direction of the light reflection
  13148. * @param scene The scene the light belongs to
  13149. */
  13150. constructor(name: string, direction: Vector3, scene: Scene);
  13151. protected _buildUniformLayout(): void;
  13152. /**
  13153. * Returns the string "HemisphericLight".
  13154. * @return The class name
  13155. */
  13156. getClassName(): string;
  13157. /**
  13158. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13159. * Returns the updated direction.
  13160. * @param target The target the direction should point to
  13161. * @return The computed direction
  13162. */
  13163. setDirectionToTarget(target: Vector3): Vector3;
  13164. /**
  13165. * Returns the shadow generator associated to the light.
  13166. * @returns Always null for hemispheric lights because it does not support shadows.
  13167. */
  13168. getShadowGenerator(): Nullable<IShadowGenerator>;
  13169. /**
  13170. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13171. * @param effect The effect to update
  13172. * @param lightIndex The index of the light in the effect to update
  13173. * @returns The hemispheric light
  13174. */
  13175. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13176. /**
  13177. * Computes the world matrix of the node
  13178. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13179. * @param useWasUpdatedFlag defines a reserved property
  13180. * @returns the world matrix
  13181. */
  13182. computeWorldMatrix(): Matrix;
  13183. /**
  13184. * Returns the integer 3.
  13185. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13186. */
  13187. getTypeID(): number;
  13188. /**
  13189. * Prepares the list of defines specific to the light type.
  13190. * @param defines the list of defines
  13191. * @param lightIndex defines the index of the light for the effect
  13192. */
  13193. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13194. }
  13195. }
  13196. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13197. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13198. import { Nullable } from "babylonjs/types";
  13199. import { Observable } from "babylonjs/Misc/observable";
  13200. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13201. import { Scene } from "babylonjs/scene";
  13202. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13203. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13204. import { Node } from "babylonjs/node";
  13205. import { Ray } from "babylonjs/Culling/ray";
  13206. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13207. /**
  13208. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13209. * IMPORTANT!! The data is right-hand data.
  13210. * @export
  13211. * @interface DevicePose
  13212. */
  13213. export interface DevicePose {
  13214. /**
  13215. * The position of the device, values in array are [x,y,z].
  13216. */
  13217. readonly position: Nullable<Float32Array>;
  13218. /**
  13219. * The linearVelocity of the device, values in array are [x,y,z].
  13220. */
  13221. readonly linearVelocity: Nullable<Float32Array>;
  13222. /**
  13223. * The linearAcceleration of the device, values in array are [x,y,z].
  13224. */
  13225. readonly linearAcceleration: Nullable<Float32Array>;
  13226. /**
  13227. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13228. */
  13229. readonly orientation: Nullable<Float32Array>;
  13230. /**
  13231. * The angularVelocity of the device, values in array are [x,y,z].
  13232. */
  13233. readonly angularVelocity: Nullable<Float32Array>;
  13234. /**
  13235. * The angularAcceleration of the device, values in array are [x,y,z].
  13236. */
  13237. readonly angularAcceleration: Nullable<Float32Array>;
  13238. }
  13239. /**
  13240. * Interface representing a pose controlled object in Babylon.
  13241. * A pose controlled object has both regular pose values as well as pose values
  13242. * from an external device such as a VR head mounted display
  13243. */
  13244. export interface PoseControlled {
  13245. /**
  13246. * The position of the object in babylon space.
  13247. */
  13248. position: Vector3;
  13249. /**
  13250. * The rotation quaternion of the object in babylon space.
  13251. */
  13252. rotationQuaternion: Quaternion;
  13253. /**
  13254. * The position of the device in babylon space.
  13255. */
  13256. devicePosition?: Vector3;
  13257. /**
  13258. * The rotation quaternion of the device in babylon space.
  13259. */
  13260. deviceRotationQuaternion: Quaternion;
  13261. /**
  13262. * The raw pose coming from the device.
  13263. */
  13264. rawPose: Nullable<DevicePose>;
  13265. /**
  13266. * The scale of the device to be used when translating from device space to babylon space.
  13267. */
  13268. deviceScaleFactor: number;
  13269. /**
  13270. * Updates the poseControlled values based on the input device pose.
  13271. * @param poseData the pose data to update the object with
  13272. */
  13273. updateFromDevice(poseData: DevicePose): void;
  13274. }
  13275. /**
  13276. * Set of options to customize the webVRCamera
  13277. */
  13278. export interface WebVROptions {
  13279. /**
  13280. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13281. */
  13282. trackPosition?: boolean;
  13283. /**
  13284. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13285. */
  13286. positionScale?: number;
  13287. /**
  13288. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13289. */
  13290. displayName?: string;
  13291. /**
  13292. * Should the native controller meshes be initialized. (default: true)
  13293. */
  13294. controllerMeshes?: boolean;
  13295. /**
  13296. * Creating a default HemiLight only on controllers. (default: true)
  13297. */
  13298. defaultLightingOnControllers?: boolean;
  13299. /**
  13300. * If you don't want to use the default VR button of the helper. (default: false)
  13301. */
  13302. useCustomVRButton?: boolean;
  13303. /**
  13304. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13305. */
  13306. customVRButton?: HTMLButtonElement;
  13307. /**
  13308. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13309. */
  13310. rayLength?: number;
  13311. /**
  13312. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13313. */
  13314. defaultHeight?: number;
  13315. }
  13316. /**
  13317. * This represents a WebVR camera.
  13318. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13319. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13320. */
  13321. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13322. private webVROptions;
  13323. /**
  13324. * @hidden
  13325. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13326. */
  13327. _vrDevice: any;
  13328. /**
  13329. * The rawPose of the vrDevice.
  13330. */
  13331. rawPose: Nullable<DevicePose>;
  13332. private _onVREnabled;
  13333. private _specsVersion;
  13334. private _attached;
  13335. private _frameData;
  13336. protected _descendants: Array<Node>;
  13337. private _deviceRoomPosition;
  13338. /** @hidden */
  13339. _deviceRoomRotationQuaternion: Quaternion;
  13340. private _standingMatrix;
  13341. /**
  13342. * Represents device position in babylon space.
  13343. */
  13344. devicePosition: Vector3;
  13345. /**
  13346. * Represents device rotation in babylon space.
  13347. */
  13348. deviceRotationQuaternion: Quaternion;
  13349. /**
  13350. * The scale of the device to be used when translating from device space to babylon space.
  13351. */
  13352. deviceScaleFactor: number;
  13353. private _deviceToWorld;
  13354. private _worldToDevice;
  13355. /**
  13356. * References to the webVR controllers for the vrDevice.
  13357. */
  13358. controllers: Array<WebVRController>;
  13359. /**
  13360. * Emits an event when a controller is attached.
  13361. */
  13362. onControllersAttachedObservable: Observable<WebVRController[]>;
  13363. /**
  13364. * Emits an event when a controller's mesh has been loaded;
  13365. */
  13366. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13367. /**
  13368. * Emits an event when the HMD's pose has been updated.
  13369. */
  13370. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13371. private _poseSet;
  13372. /**
  13373. * If the rig cameras be used as parent instead of this camera.
  13374. */
  13375. rigParenting: boolean;
  13376. private _lightOnControllers;
  13377. private _defaultHeight?;
  13378. /**
  13379. * Instantiates a WebVRFreeCamera.
  13380. * @param name The name of the WebVRFreeCamera
  13381. * @param position The starting anchor position for the camera
  13382. * @param scene The scene the camera belongs to
  13383. * @param webVROptions a set of customizable options for the webVRCamera
  13384. */
  13385. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13386. /**
  13387. * Gets the device distance from the ground in meters.
  13388. * @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.
  13389. */
  13390. deviceDistanceToRoomGround(): number;
  13391. /**
  13392. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13393. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13394. */
  13395. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13396. /**
  13397. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13398. * @returns A promise with a boolean set to if the standing matrix is supported.
  13399. */
  13400. useStandingMatrixAsync(): Promise<boolean>;
  13401. /**
  13402. * Disposes the camera
  13403. */
  13404. dispose(): void;
  13405. /**
  13406. * Gets a vrController by name.
  13407. * @param name The name of the controller to retreive
  13408. * @returns the controller matching the name specified or null if not found
  13409. */
  13410. getControllerByName(name: string): Nullable<WebVRController>;
  13411. private _leftController;
  13412. /**
  13413. * The controller corrisponding to the users left hand.
  13414. */
  13415. readonly leftController: Nullable<WebVRController>;
  13416. private _rightController;
  13417. /**
  13418. * The controller corrisponding to the users right hand.
  13419. */
  13420. readonly rightController: Nullable<WebVRController>;
  13421. /**
  13422. * Casts a ray forward from the vrCamera's gaze.
  13423. * @param length Length of the ray (default: 100)
  13424. * @returns the ray corrisponding to the gaze
  13425. */
  13426. getForwardRay(length?: number): Ray;
  13427. /**
  13428. * @hidden
  13429. * Updates the camera based on device's frame data
  13430. */
  13431. _checkInputs(): void;
  13432. /**
  13433. * Updates the poseControlled values based on the input device pose.
  13434. * @param poseData Pose coming from the device
  13435. */
  13436. updateFromDevice(poseData: DevicePose): void;
  13437. private _htmlElementAttached;
  13438. private _detachIfAttached;
  13439. /**
  13440. * WebVR's attach control will start broadcasting frames to the device.
  13441. * Note that in certain browsers (chrome for example) this function must be called
  13442. * within a user-interaction callback. Example:
  13443. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13444. *
  13445. * @param element html element to attach the vrDevice to
  13446. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13447. */
  13448. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13449. /**
  13450. * Detaches the camera from the html element and disables VR
  13451. *
  13452. * @param element html element to detach from
  13453. */
  13454. detachControl(element: HTMLElement): void;
  13455. /**
  13456. * @returns the name of this class
  13457. */
  13458. getClassName(): string;
  13459. /**
  13460. * Calls resetPose on the vrDisplay
  13461. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13462. */
  13463. resetToCurrentRotation(): void;
  13464. /**
  13465. * @hidden
  13466. * Updates the rig cameras (left and right eye)
  13467. */
  13468. _updateRigCameras(): void;
  13469. private _workingVector;
  13470. private _oneVector;
  13471. private _workingMatrix;
  13472. private updateCacheCalled;
  13473. private _correctPositionIfNotTrackPosition;
  13474. /**
  13475. * @hidden
  13476. * Updates the cached values of the camera
  13477. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13478. */
  13479. _updateCache(ignoreParentClass?: boolean): void;
  13480. /**
  13481. * @hidden
  13482. * Get current device position in babylon world
  13483. */
  13484. _computeDevicePosition(): void;
  13485. /**
  13486. * Updates the current device position and rotation in the babylon world
  13487. */
  13488. update(): void;
  13489. /**
  13490. * @hidden
  13491. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13492. * @returns an identity matrix
  13493. */
  13494. _getViewMatrix(): Matrix;
  13495. private _tmpMatrix;
  13496. /**
  13497. * This function is called by the two RIG cameras.
  13498. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13499. * @hidden
  13500. */
  13501. _getWebVRViewMatrix(): Matrix;
  13502. /** @hidden */
  13503. _getWebVRProjectionMatrix(): Matrix;
  13504. private _onGamepadConnectedObserver;
  13505. private _onGamepadDisconnectedObserver;
  13506. private _updateCacheWhenTrackingDisabledObserver;
  13507. /**
  13508. * Initializes the controllers and their meshes
  13509. */
  13510. initControllers(): void;
  13511. }
  13512. }
  13513. declare module "babylonjs/PostProcesses/postProcess" {
  13514. import { Nullable } from "babylonjs/types";
  13515. import { SmartArray } from "babylonjs/Misc/smartArray";
  13516. import { Observable } from "babylonjs/Misc/observable";
  13517. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13518. import { Camera } from "babylonjs/Cameras/camera";
  13519. import { Effect } from "babylonjs/Materials/effect";
  13520. import "babylonjs/Shaders/postprocess.vertex";
  13521. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13522. import { Engine } from "babylonjs/Engines/engine";
  13523. /**
  13524. * Size options for a post process
  13525. */
  13526. export type PostProcessOptions = {
  13527. width: number;
  13528. height: number;
  13529. };
  13530. /**
  13531. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13532. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13533. */
  13534. export class PostProcess {
  13535. /** Name of the PostProcess. */
  13536. name: string;
  13537. /**
  13538. * Width of the texture to apply the post process on
  13539. */
  13540. width: number;
  13541. /**
  13542. * Height of the texture to apply the post process on
  13543. */
  13544. height: number;
  13545. /**
  13546. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13547. * @hidden
  13548. */
  13549. _outputTexture: Nullable<InternalTexture>;
  13550. /**
  13551. * Sampling mode used by the shader
  13552. * See https://doc.babylonjs.com/classes/3.1/texture
  13553. */
  13554. renderTargetSamplingMode: number;
  13555. /**
  13556. * Clear color to use when screen clearing
  13557. */
  13558. clearColor: Color4;
  13559. /**
  13560. * If the buffer needs to be cleared before applying the post process. (default: true)
  13561. * Should be set to false if shader will overwrite all previous pixels.
  13562. */
  13563. autoClear: boolean;
  13564. /**
  13565. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13566. */
  13567. alphaMode: number;
  13568. /**
  13569. * Sets the setAlphaBlendConstants of the babylon engine
  13570. */
  13571. alphaConstants: Color4;
  13572. /**
  13573. * Animations to be used for the post processing
  13574. */
  13575. animations: import("babylonjs/Animations/animation").Animation[];
  13576. /**
  13577. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13578. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13579. */
  13580. enablePixelPerfectMode: boolean;
  13581. /**
  13582. * Force the postprocess to be applied without taking in account viewport
  13583. */
  13584. forceFullscreenViewport: boolean;
  13585. /**
  13586. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13587. *
  13588. * | Value | Type | Description |
  13589. * | ----- | ----------------------------------- | ----------- |
  13590. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13591. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13592. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13593. *
  13594. */
  13595. scaleMode: number;
  13596. /**
  13597. * Force textures to be a power of two (default: false)
  13598. */
  13599. alwaysForcePOT: boolean;
  13600. private _samples;
  13601. /**
  13602. * Number of sample textures (default: 1)
  13603. */
  13604. samples: number;
  13605. /**
  13606. * Modify the scale of the post process to be the same as the viewport (default: false)
  13607. */
  13608. adaptScaleToCurrentViewport: boolean;
  13609. private _camera;
  13610. private _scene;
  13611. private _engine;
  13612. private _options;
  13613. private _reusable;
  13614. private _textureType;
  13615. /**
  13616. * Smart array of input and output textures for the post process.
  13617. * @hidden
  13618. */
  13619. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13620. /**
  13621. * The index in _textures that corresponds to the output texture.
  13622. * @hidden
  13623. */
  13624. _currentRenderTextureInd: number;
  13625. private _effect;
  13626. private _samplers;
  13627. private _fragmentUrl;
  13628. private _vertexUrl;
  13629. private _parameters;
  13630. private _scaleRatio;
  13631. protected _indexParameters: any;
  13632. private _shareOutputWithPostProcess;
  13633. private _texelSize;
  13634. private _forcedOutputTexture;
  13635. /**
  13636. * Returns the fragment url or shader name used in the post process.
  13637. * @returns the fragment url or name in the shader store.
  13638. */
  13639. getEffectName(): string;
  13640. /**
  13641. * An event triggered when the postprocess is activated.
  13642. */
  13643. onActivateObservable: Observable<Camera>;
  13644. private _onActivateObserver;
  13645. /**
  13646. * A function that is added to the onActivateObservable
  13647. */
  13648. onActivate: Nullable<(camera: Camera) => void>;
  13649. /**
  13650. * An event triggered when the postprocess changes its size.
  13651. */
  13652. onSizeChangedObservable: Observable<PostProcess>;
  13653. private _onSizeChangedObserver;
  13654. /**
  13655. * A function that is added to the onSizeChangedObservable
  13656. */
  13657. onSizeChanged: (postProcess: PostProcess) => void;
  13658. /**
  13659. * An event triggered when the postprocess applies its effect.
  13660. */
  13661. onApplyObservable: Observable<Effect>;
  13662. private _onApplyObserver;
  13663. /**
  13664. * A function that is added to the onApplyObservable
  13665. */
  13666. onApply: (effect: Effect) => void;
  13667. /**
  13668. * An event triggered before rendering the postprocess
  13669. */
  13670. onBeforeRenderObservable: Observable<Effect>;
  13671. private _onBeforeRenderObserver;
  13672. /**
  13673. * A function that is added to the onBeforeRenderObservable
  13674. */
  13675. onBeforeRender: (effect: Effect) => void;
  13676. /**
  13677. * An event triggered after rendering the postprocess
  13678. */
  13679. onAfterRenderObservable: Observable<Effect>;
  13680. private _onAfterRenderObserver;
  13681. /**
  13682. * A function that is added to the onAfterRenderObservable
  13683. */
  13684. onAfterRender: (efect: Effect) => void;
  13685. /**
  13686. * 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
  13687. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13688. */
  13689. inputTexture: InternalTexture;
  13690. /**
  13691. * Gets the camera which post process is applied to.
  13692. * @returns The camera the post process is applied to.
  13693. */
  13694. getCamera(): Camera;
  13695. /**
  13696. * Gets the texel size of the postprocess.
  13697. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13698. */
  13699. readonly texelSize: Vector2;
  13700. /**
  13701. * Creates a new instance PostProcess
  13702. * @param name The name of the PostProcess.
  13703. * @param fragmentUrl The url of the fragment shader to be used.
  13704. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13705. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13706. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13707. * @param camera The camera to apply the render pass to.
  13708. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13709. * @param engine The engine which the post process will be applied. (default: current engine)
  13710. * @param reusable If the post process can be reused on the same frame. (default: false)
  13711. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13712. * @param textureType Type of textures used when performing the post process. (default: 0)
  13713. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13714. * @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
  13715. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13716. */
  13717. constructor(
  13718. /** Name of the PostProcess. */
  13719. 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);
  13720. /**
  13721. * Gets the engine which this post process belongs to.
  13722. * @returns The engine the post process was enabled with.
  13723. */
  13724. getEngine(): Engine;
  13725. /**
  13726. * The effect that is created when initializing the post process.
  13727. * @returns The created effect corrisponding the the postprocess.
  13728. */
  13729. getEffect(): Effect;
  13730. /**
  13731. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13732. * @param postProcess The post process to share the output with.
  13733. * @returns This post process.
  13734. */
  13735. shareOutputWith(postProcess: PostProcess): PostProcess;
  13736. /**
  13737. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13738. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13739. */
  13740. useOwnOutput(): void;
  13741. /**
  13742. * Updates the effect with the current post process compile time values and recompiles the shader.
  13743. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13744. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13745. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13746. * @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
  13747. * @param onCompiled Called when the shader has been compiled.
  13748. * @param onError Called if there is an error when compiling a shader.
  13749. */
  13750. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13751. /**
  13752. * The post process is reusable if it can be used multiple times within one frame.
  13753. * @returns If the post process is reusable
  13754. */
  13755. isReusable(): boolean;
  13756. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13757. markTextureDirty(): void;
  13758. /**
  13759. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13760. * 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.
  13761. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13762. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13763. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13764. * @returns The target texture that was bound to be written to.
  13765. */
  13766. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13767. /**
  13768. * If the post process is supported.
  13769. */
  13770. readonly isSupported: boolean;
  13771. /**
  13772. * The aspect ratio of the output texture.
  13773. */
  13774. readonly aspectRatio: number;
  13775. /**
  13776. * Get a value indicating if the post-process is ready to be used
  13777. * @returns true if the post-process is ready (shader is compiled)
  13778. */
  13779. isReady(): boolean;
  13780. /**
  13781. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13782. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13783. */
  13784. apply(): Nullable<Effect>;
  13785. private _disposeTextures;
  13786. /**
  13787. * Disposes the post process.
  13788. * @param camera The camera to dispose the post process on.
  13789. */
  13790. dispose(camera?: Camera): void;
  13791. }
  13792. }
  13793. declare module "babylonjs/PostProcesses/postProcessManager" {
  13794. import { Nullable } from "babylonjs/types";
  13795. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13796. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13797. import { Scene } from "babylonjs/scene";
  13798. /**
  13799. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13800. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13801. */
  13802. export class PostProcessManager {
  13803. private _scene;
  13804. private _indexBuffer;
  13805. private _vertexBuffers;
  13806. /**
  13807. * Creates a new instance PostProcess
  13808. * @param scene The scene that the post process is associated with.
  13809. */
  13810. constructor(scene: Scene);
  13811. private _prepareBuffers;
  13812. private _buildIndexBuffer;
  13813. /**
  13814. * Rebuilds the vertex buffers of the manager.
  13815. * @hidden
  13816. */
  13817. _rebuild(): void;
  13818. /**
  13819. * Prepares a frame to be run through a post process.
  13820. * @param sourceTexture The input texture to the post procesess. (default: null)
  13821. * @param postProcesses An array of post processes to be run. (default: null)
  13822. * @returns True if the post processes were able to be run.
  13823. * @hidden
  13824. */
  13825. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13826. /**
  13827. * Manually render a set of post processes to a texture.
  13828. * @param postProcesses An array of post processes to be run.
  13829. * @param targetTexture The target texture to render to.
  13830. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13831. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13832. * @param lodLevel defines which lod of the texture to render to
  13833. */
  13834. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13835. /**
  13836. * Finalize the result of the output of the postprocesses.
  13837. * @param doNotPresent If true the result will not be displayed to the screen.
  13838. * @param targetTexture The target texture to render to.
  13839. * @param faceIndex The index of the face to bind the target texture to.
  13840. * @param postProcesses The array of post processes to render.
  13841. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13842. * @hidden
  13843. */
  13844. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13845. /**
  13846. * Disposes of the post process manager.
  13847. */
  13848. dispose(): void;
  13849. }
  13850. }
  13851. declare module "babylonjs/Materials/Textures/rawTexture" {
  13852. import { Scene } from "babylonjs/scene";
  13853. import { Texture } from "babylonjs/Materials/Textures/texture";
  13854. /**
  13855. * Raw texture can help creating a texture directly from an array of data.
  13856. * This can be super useful if you either get the data from an uncompressed source or
  13857. * if you wish to create your texture pixel by pixel.
  13858. */
  13859. export class RawTexture extends Texture {
  13860. /**
  13861. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13862. */
  13863. format: number;
  13864. private _engine;
  13865. /**
  13866. * Instantiates a new RawTexture.
  13867. * Raw texture can help creating a texture directly from an array of data.
  13868. * This can be super useful if you either get the data from an uncompressed source or
  13869. * if you wish to create your texture pixel by pixel.
  13870. * @param data define the array of data to use to create the texture
  13871. * @param width define the width of the texture
  13872. * @param height define the height of the texture
  13873. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13874. * @param scene define the scene the texture belongs to
  13875. * @param generateMipMaps define whether mip maps should be generated or not
  13876. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13877. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13878. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13879. */
  13880. constructor(data: ArrayBufferView, width: number, height: number,
  13881. /**
  13882. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13883. */
  13884. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13885. /**
  13886. * Updates the texture underlying data.
  13887. * @param data Define the new data of the texture
  13888. */
  13889. update(data: ArrayBufferView): void;
  13890. /**
  13891. * Creates a luminance texture from some data.
  13892. * @param data Define the texture data
  13893. * @param width Define the width of the texture
  13894. * @param height Define the height of the texture
  13895. * @param scene Define the scene the texture belongs to
  13896. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13897. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13898. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13899. * @returns the luminance texture
  13900. */
  13901. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13902. /**
  13903. * Creates a luminance alpha texture from some data.
  13904. * @param data Define the texture data
  13905. * @param width Define the width of the texture
  13906. * @param height Define the height of the texture
  13907. * @param scene Define the scene the texture belongs to
  13908. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13909. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13910. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13911. * @returns the luminance alpha texture
  13912. */
  13913. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13914. /**
  13915. * Creates an alpha texture from some data.
  13916. * @param data Define the texture data
  13917. * @param width Define the width of the texture
  13918. * @param height Define the height of the texture
  13919. * @param scene Define the scene the texture belongs to
  13920. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13921. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13922. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13923. * @returns the alpha texture
  13924. */
  13925. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13926. /**
  13927. * Creates a RGB texture from some data.
  13928. * @param data Define the texture data
  13929. * @param width Define the width of the texture
  13930. * @param height Define the height of the texture
  13931. * @param scene Define the scene the texture belongs to
  13932. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13933. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13934. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13935. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13936. * @returns the RGB alpha texture
  13937. */
  13938. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13939. /**
  13940. * Creates a RGBA texture from some data.
  13941. * @param data Define the texture data
  13942. * @param width Define the width of the texture
  13943. * @param height Define the height of the texture
  13944. * @param scene Define the scene the texture belongs to
  13945. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13946. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13947. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13948. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13949. * @returns the RGBA texture
  13950. */
  13951. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13952. /**
  13953. * Creates a R texture from some data.
  13954. * @param data Define the texture data
  13955. * @param width Define the width of the texture
  13956. * @param height Define the height of the texture
  13957. * @param scene Define the scene the texture belongs to
  13958. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13959. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13960. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13961. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13962. * @returns the R texture
  13963. */
  13964. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13965. }
  13966. }
  13967. declare module "babylonjs/Layers/layerSceneComponent" {
  13968. import { Scene } from "babylonjs/scene";
  13969. import { ISceneComponent } from "babylonjs/sceneComponent";
  13970. import { Layer } from "babylonjs/Layers/layer";
  13971. module "babylonjs/abstractScene" {
  13972. interface AbstractScene {
  13973. /**
  13974. * The list of layers (background and foreground) of the scene
  13975. */
  13976. layers: Array<Layer>;
  13977. }
  13978. }
  13979. /**
  13980. * Defines the layer scene component responsible to manage any layers
  13981. * in a given scene.
  13982. */
  13983. export class LayerSceneComponent implements ISceneComponent {
  13984. /**
  13985. * The component name helpfull to identify the component in the list of scene components.
  13986. */
  13987. readonly name: string;
  13988. /**
  13989. * The scene the component belongs to.
  13990. */
  13991. scene: Scene;
  13992. private _engine;
  13993. /**
  13994. * Creates a new instance of the component for the given scene
  13995. * @param scene Defines the scene to register the component in
  13996. */
  13997. constructor(scene: Scene);
  13998. /**
  13999. * Registers the component in a given scene
  14000. */
  14001. register(): void;
  14002. /**
  14003. * Rebuilds the elements related to this component in case of
  14004. * context lost for instance.
  14005. */
  14006. rebuild(): void;
  14007. /**
  14008. * Disposes the component and the associated ressources.
  14009. */
  14010. dispose(): void;
  14011. private _draw;
  14012. private _drawCameraPredicate;
  14013. private _drawCameraBackground;
  14014. private _drawCameraForeground;
  14015. private _drawRenderTargetPredicate;
  14016. private _drawRenderTargetBackground;
  14017. private _drawRenderTargetForeground;
  14018. }
  14019. }
  14020. declare module "babylonjs/Shaders/layer.fragment" {
  14021. /** @hidden */
  14022. export var layerPixelShader: {
  14023. name: string;
  14024. shader: string;
  14025. };
  14026. }
  14027. declare module "babylonjs/Shaders/layer.vertex" {
  14028. /** @hidden */
  14029. export var layerVertexShader: {
  14030. name: string;
  14031. shader: string;
  14032. };
  14033. }
  14034. declare module "babylonjs/Layers/layer" {
  14035. import { Observable } from "babylonjs/Misc/observable";
  14036. import { Nullable } from "babylonjs/types";
  14037. import { Scene } from "babylonjs/scene";
  14038. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14039. import { Texture } from "babylonjs/Materials/Textures/texture";
  14040. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14041. import "babylonjs/Shaders/layer.fragment";
  14042. import "babylonjs/Shaders/layer.vertex";
  14043. /**
  14044. * This represents a full screen 2d layer.
  14045. * This can be useful to display a picture in the background of your scene for instance.
  14046. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14047. */
  14048. export class Layer {
  14049. /**
  14050. * Define the name of the layer.
  14051. */
  14052. name: string;
  14053. /**
  14054. * Define the texture the layer should display.
  14055. */
  14056. texture: Nullable<Texture>;
  14057. /**
  14058. * Is the layer in background or foreground.
  14059. */
  14060. isBackground: boolean;
  14061. /**
  14062. * Define the color of the layer (instead of texture).
  14063. */
  14064. color: Color4;
  14065. /**
  14066. * Define the scale of the layer in order to zoom in out of the texture.
  14067. */
  14068. scale: Vector2;
  14069. /**
  14070. * Define an offset for the layer in order to shift the texture.
  14071. */
  14072. offset: Vector2;
  14073. /**
  14074. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14075. */
  14076. alphaBlendingMode: number;
  14077. /**
  14078. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14079. * Alpha test will not mix with the background color in case of transparency.
  14080. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14081. */
  14082. alphaTest: boolean;
  14083. /**
  14084. * Define a mask to restrict the layer to only some of the scene cameras.
  14085. */
  14086. layerMask: number;
  14087. /**
  14088. * Define the list of render target the layer is visible into.
  14089. */
  14090. renderTargetTextures: RenderTargetTexture[];
  14091. /**
  14092. * Define if the layer is only used in renderTarget or if it also
  14093. * renders in the main frame buffer of the canvas.
  14094. */
  14095. renderOnlyInRenderTargetTextures: boolean;
  14096. private _scene;
  14097. private _vertexBuffers;
  14098. private _indexBuffer;
  14099. private _effect;
  14100. private _alphaTestEffect;
  14101. /**
  14102. * An event triggered when the layer is disposed.
  14103. */
  14104. onDisposeObservable: Observable<Layer>;
  14105. private _onDisposeObserver;
  14106. /**
  14107. * Back compatibility with callback before the onDisposeObservable existed.
  14108. * The set callback will be triggered when the layer has been disposed.
  14109. */
  14110. onDispose: () => void;
  14111. /**
  14112. * An event triggered before rendering the scene
  14113. */
  14114. onBeforeRenderObservable: Observable<Layer>;
  14115. private _onBeforeRenderObserver;
  14116. /**
  14117. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14118. * The set callback will be triggered just before rendering the layer.
  14119. */
  14120. onBeforeRender: () => void;
  14121. /**
  14122. * An event triggered after rendering the scene
  14123. */
  14124. onAfterRenderObservable: Observable<Layer>;
  14125. private _onAfterRenderObserver;
  14126. /**
  14127. * Back compatibility with callback before the onAfterRenderObservable existed.
  14128. * The set callback will be triggered just after rendering the layer.
  14129. */
  14130. onAfterRender: () => void;
  14131. /**
  14132. * Instantiates a new layer.
  14133. * This represents a full screen 2d layer.
  14134. * This can be useful to display a picture in the background of your scene for instance.
  14135. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14136. * @param name Define the name of the layer in the scene
  14137. * @param imgUrl Define the url of the texture to display in the layer
  14138. * @param scene Define the scene the layer belongs to
  14139. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14140. * @param color Defines a color for the layer
  14141. */
  14142. constructor(
  14143. /**
  14144. * Define the name of the layer.
  14145. */
  14146. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14147. private _createIndexBuffer;
  14148. /** @hidden */
  14149. _rebuild(): void;
  14150. /**
  14151. * Renders the layer in the scene.
  14152. */
  14153. render(): void;
  14154. /**
  14155. * Disposes and releases the associated ressources.
  14156. */
  14157. dispose(): void;
  14158. }
  14159. }
  14160. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14161. import { Scene } from "babylonjs/scene";
  14162. import { ISceneComponent } from "babylonjs/sceneComponent";
  14163. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14164. module "babylonjs/abstractScene" {
  14165. interface AbstractScene {
  14166. /**
  14167. * The list of procedural textures added to the scene
  14168. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14169. */
  14170. proceduralTextures: Array<ProceduralTexture>;
  14171. }
  14172. }
  14173. /**
  14174. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14175. * in a given scene.
  14176. */
  14177. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14178. /**
  14179. * The component name helpfull to identify the component in the list of scene components.
  14180. */
  14181. readonly name: string;
  14182. /**
  14183. * The scene the component belongs to.
  14184. */
  14185. scene: Scene;
  14186. /**
  14187. * Creates a new instance of the component for the given scene
  14188. * @param scene Defines the scene to register the component in
  14189. */
  14190. constructor(scene: Scene);
  14191. /**
  14192. * Registers the component in a given scene
  14193. */
  14194. register(): void;
  14195. /**
  14196. * Rebuilds the elements related to this component in case of
  14197. * context lost for instance.
  14198. */
  14199. rebuild(): void;
  14200. /**
  14201. * Disposes the component and the associated ressources.
  14202. */
  14203. dispose(): void;
  14204. private _beforeClear;
  14205. }
  14206. }
  14207. declare module "babylonjs/Shaders/procedural.vertex" {
  14208. /** @hidden */
  14209. export var proceduralVertexShader: {
  14210. name: string;
  14211. shader: string;
  14212. };
  14213. }
  14214. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14215. import { Observable } from "babylonjs/Misc/observable";
  14216. import { Nullable } from "babylonjs/types";
  14217. import { Scene } from "babylonjs/scene";
  14218. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14219. import { Effect } from "babylonjs/Materials/effect";
  14220. import { Texture } from "babylonjs/Materials/Textures/texture";
  14221. import "babylonjs/Shaders/procedural.vertex";
  14222. /**
  14223. * 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.
  14224. * This is the base class of any Procedural texture and contains most of the shareable code.
  14225. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14226. */
  14227. export class ProceduralTexture extends Texture {
  14228. isCube: boolean;
  14229. /**
  14230. * Define if the texture is enabled or not (disabled texture will not render)
  14231. */
  14232. isEnabled: boolean;
  14233. /**
  14234. * Define if the texture must be cleared before rendering (default is true)
  14235. */
  14236. autoClear: boolean;
  14237. /**
  14238. * Callback called when the texture is generated
  14239. */
  14240. onGenerated: () => void;
  14241. /**
  14242. * Event raised when the texture is generated
  14243. */
  14244. onGeneratedObservable: Observable<ProceduralTexture>;
  14245. /** @hidden */
  14246. _generateMipMaps: boolean;
  14247. /** @hidden **/
  14248. _effect: Effect;
  14249. /** @hidden */
  14250. _textures: {
  14251. [key: string]: Texture;
  14252. };
  14253. private _size;
  14254. private _currentRefreshId;
  14255. private _refreshRate;
  14256. private _vertexBuffers;
  14257. private _indexBuffer;
  14258. private _uniforms;
  14259. private _samplers;
  14260. private _fragment;
  14261. private _floats;
  14262. private _ints;
  14263. private _floatsArrays;
  14264. private _colors3;
  14265. private _colors4;
  14266. private _vectors2;
  14267. private _vectors3;
  14268. private _matrices;
  14269. private _fallbackTexture;
  14270. private _fallbackTextureUsed;
  14271. private _engine;
  14272. private _cachedDefines;
  14273. private _contentUpdateId;
  14274. private _contentData;
  14275. /**
  14276. * Instantiates a new procedural texture.
  14277. * 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.
  14278. * This is the base class of any Procedural texture and contains most of the shareable code.
  14279. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14280. * @param name Define the name of the texture
  14281. * @param size Define the size of the texture to create
  14282. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14283. * @param scene Define the scene the texture belongs to
  14284. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14285. * @param generateMipMaps Define if the texture should creates mip maps or not
  14286. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14287. */
  14288. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14289. /**
  14290. * The effect that is created when initializing the post process.
  14291. * @returns The created effect corrisponding the the postprocess.
  14292. */
  14293. getEffect(): Effect;
  14294. /**
  14295. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14296. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14297. */
  14298. getContent(): Nullable<ArrayBufferView>;
  14299. private _createIndexBuffer;
  14300. /** @hidden */
  14301. _rebuild(): void;
  14302. /**
  14303. * Resets the texture in order to recreate its associated resources.
  14304. * This can be called in case of context loss
  14305. */
  14306. reset(): void;
  14307. protected _getDefines(): string;
  14308. /**
  14309. * Is the texture ready to be used ? (rendered at least once)
  14310. * @returns true if ready, otherwise, false.
  14311. */
  14312. isReady(): boolean;
  14313. /**
  14314. * Resets the refresh counter of the texture and start bak from scratch.
  14315. * Could be useful to regenerate the texture if it is setup to render only once.
  14316. */
  14317. resetRefreshCounter(): void;
  14318. /**
  14319. * Set the fragment shader to use in order to render the texture.
  14320. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14321. */
  14322. setFragment(fragment: any): void;
  14323. /**
  14324. * Define the refresh rate of the texture or the rendering frequency.
  14325. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14326. */
  14327. refreshRate: number;
  14328. /** @hidden */
  14329. _shouldRender(): boolean;
  14330. /**
  14331. * Get the size the texture is rendering at.
  14332. * @returns the size (texture is always squared)
  14333. */
  14334. getRenderSize(): number;
  14335. /**
  14336. * Resize the texture to new value.
  14337. * @param size Define the new size the texture should have
  14338. * @param generateMipMaps Define whether the new texture should create mip maps
  14339. */
  14340. resize(size: number, generateMipMaps: boolean): void;
  14341. private _checkUniform;
  14342. /**
  14343. * Set a texture in the shader program used to render.
  14344. * @param name Define the name of the uniform samplers as defined in the shader
  14345. * @param texture Define the texture to bind to this sampler
  14346. * @return the texture itself allowing "fluent" like uniform updates
  14347. */
  14348. setTexture(name: string, texture: Texture): ProceduralTexture;
  14349. /**
  14350. * Set a float in the shader.
  14351. * @param name Define the name of the uniform as defined in the shader
  14352. * @param value Define the value to give to the uniform
  14353. * @return the texture itself allowing "fluent" like uniform updates
  14354. */
  14355. setFloat(name: string, value: number): ProceduralTexture;
  14356. /**
  14357. * Set a int in the shader.
  14358. * @param name Define the name of the uniform as defined in the shader
  14359. * @param value Define the value to give to the uniform
  14360. * @return the texture itself allowing "fluent" like uniform updates
  14361. */
  14362. setInt(name: string, value: number): ProceduralTexture;
  14363. /**
  14364. * Set an array of floats in the shader.
  14365. * @param name Define the name of the uniform as defined in the shader
  14366. * @param value Define the value to give to the uniform
  14367. * @return the texture itself allowing "fluent" like uniform updates
  14368. */
  14369. setFloats(name: string, value: number[]): ProceduralTexture;
  14370. /**
  14371. * Set a vec3 in the shader from a Color3.
  14372. * @param name Define the name of the uniform as defined in the shader
  14373. * @param value Define the value to give to the uniform
  14374. * @return the texture itself allowing "fluent" like uniform updates
  14375. */
  14376. setColor3(name: string, value: Color3): ProceduralTexture;
  14377. /**
  14378. * Set a vec4 in the shader from a Color4.
  14379. * @param name Define the name of the uniform as defined in the shader
  14380. * @param value Define the value to give to the uniform
  14381. * @return the texture itself allowing "fluent" like uniform updates
  14382. */
  14383. setColor4(name: string, value: Color4): ProceduralTexture;
  14384. /**
  14385. * Set a vec2 in the shader from a Vector2.
  14386. * @param name Define the name of the uniform as defined in the shader
  14387. * @param value Define the value to give to the uniform
  14388. * @return the texture itself allowing "fluent" like uniform updates
  14389. */
  14390. setVector2(name: string, value: Vector2): ProceduralTexture;
  14391. /**
  14392. * Set a vec3 in the shader from a Vector3.
  14393. * @param name Define the name of the uniform as defined in the shader
  14394. * @param value Define the value to give to the uniform
  14395. * @return the texture itself allowing "fluent" like uniform updates
  14396. */
  14397. setVector3(name: string, value: Vector3): ProceduralTexture;
  14398. /**
  14399. * Set a mat4 in the shader from a MAtrix.
  14400. * @param name Define the name of the uniform as defined in the shader
  14401. * @param value Define the value to give to the uniform
  14402. * @return the texture itself allowing "fluent" like uniform updates
  14403. */
  14404. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14405. /**
  14406. * Render the texture to its associated render target.
  14407. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14408. */
  14409. render(useCameraPostProcess?: boolean): void;
  14410. /**
  14411. * Clone the texture.
  14412. * @returns the cloned texture
  14413. */
  14414. clone(): ProceduralTexture;
  14415. /**
  14416. * Dispose the texture and release its asoociated resources.
  14417. */
  14418. dispose(): void;
  14419. }
  14420. }
  14421. declare module "babylonjs/Particles/baseParticleSystem" {
  14422. import { Nullable } from "babylonjs/types";
  14423. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14425. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14426. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14427. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14428. import { Scene } from "babylonjs/scene";
  14429. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14430. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14431. import { Texture } from "babylonjs/Materials/Textures/texture";
  14432. import { Animation } from "babylonjs/Animations/animation";
  14433. /**
  14434. * This represents the base class for particle system in Babylon.
  14435. * 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.
  14436. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14437. * @example https://doc.babylonjs.com/babylon101/particles
  14438. */
  14439. export class BaseParticleSystem {
  14440. /**
  14441. * Source color is added to the destination color without alpha affecting the result
  14442. */
  14443. static BLENDMODE_ONEONE: number;
  14444. /**
  14445. * Blend current color and particle color using particle’s alpha
  14446. */
  14447. static BLENDMODE_STANDARD: number;
  14448. /**
  14449. * Add current color and particle color multiplied by particle’s alpha
  14450. */
  14451. static BLENDMODE_ADD: number;
  14452. /**
  14453. * Multiply current color with particle color
  14454. */
  14455. static BLENDMODE_MULTIPLY: number;
  14456. /**
  14457. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14458. */
  14459. static BLENDMODE_MULTIPLYADD: number;
  14460. /**
  14461. * List of animations used by the particle system.
  14462. */
  14463. animations: Animation[];
  14464. /**
  14465. * The id of the Particle system.
  14466. */
  14467. id: string;
  14468. /**
  14469. * The friendly name of the Particle system.
  14470. */
  14471. name: string;
  14472. /**
  14473. * The rendering group used by the Particle system to chose when to render.
  14474. */
  14475. renderingGroupId: number;
  14476. /**
  14477. * The emitter represents the Mesh or position we are attaching the particle system to.
  14478. */
  14479. emitter: Nullable<AbstractMesh | Vector3>;
  14480. /**
  14481. * The maximum number of particles to emit per frame
  14482. */
  14483. emitRate: number;
  14484. /**
  14485. * If you want to launch only a few particles at once, that can be done, as well.
  14486. */
  14487. manualEmitCount: number;
  14488. /**
  14489. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14490. */
  14491. updateSpeed: number;
  14492. /**
  14493. * The amount of time the particle system is running (depends of the overall update speed).
  14494. */
  14495. targetStopDuration: number;
  14496. /**
  14497. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14498. */
  14499. disposeOnStop: boolean;
  14500. /**
  14501. * Minimum power of emitting particles.
  14502. */
  14503. minEmitPower: number;
  14504. /**
  14505. * Maximum power of emitting particles.
  14506. */
  14507. maxEmitPower: number;
  14508. /**
  14509. * Minimum life time of emitting particles.
  14510. */
  14511. minLifeTime: number;
  14512. /**
  14513. * Maximum life time of emitting particles.
  14514. */
  14515. maxLifeTime: number;
  14516. /**
  14517. * Minimum Size of emitting particles.
  14518. */
  14519. minSize: number;
  14520. /**
  14521. * Maximum Size of emitting particles.
  14522. */
  14523. maxSize: number;
  14524. /**
  14525. * Minimum scale of emitting particles on X axis.
  14526. */
  14527. minScaleX: number;
  14528. /**
  14529. * Maximum scale of emitting particles on X axis.
  14530. */
  14531. maxScaleX: number;
  14532. /**
  14533. * Minimum scale of emitting particles on Y axis.
  14534. */
  14535. minScaleY: number;
  14536. /**
  14537. * Maximum scale of emitting particles on Y axis.
  14538. */
  14539. maxScaleY: number;
  14540. /**
  14541. * Gets or sets the minimal initial rotation in radians.
  14542. */
  14543. minInitialRotation: number;
  14544. /**
  14545. * Gets or sets the maximal initial rotation in radians.
  14546. */
  14547. maxInitialRotation: number;
  14548. /**
  14549. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14550. */
  14551. minAngularSpeed: number;
  14552. /**
  14553. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14554. */
  14555. maxAngularSpeed: number;
  14556. /**
  14557. * The texture used to render each particle. (this can be a spritesheet)
  14558. */
  14559. particleTexture: Nullable<Texture>;
  14560. /**
  14561. * The layer mask we are rendering the particles through.
  14562. */
  14563. layerMask: number;
  14564. /**
  14565. * This can help using your own shader to render the particle system.
  14566. * The according effect will be created
  14567. */
  14568. customShader: any;
  14569. /**
  14570. * By default particle system starts as soon as they are created. This prevents the
  14571. * automatic start to happen and let you decide when to start emitting particles.
  14572. */
  14573. preventAutoStart: boolean;
  14574. private _noiseTexture;
  14575. /**
  14576. * Gets or sets a texture used to add random noise to particle positions
  14577. */
  14578. noiseTexture: Nullable<ProceduralTexture>;
  14579. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14580. noiseStrength: Vector3;
  14581. /**
  14582. * Callback triggered when the particle animation is ending.
  14583. */
  14584. onAnimationEnd: Nullable<() => void>;
  14585. /**
  14586. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14587. */
  14588. blendMode: number;
  14589. /**
  14590. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14591. * to override the particles.
  14592. */
  14593. forceDepthWrite: boolean;
  14594. /** 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 */
  14595. preWarmCycles: number;
  14596. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14597. preWarmStepOffset: number;
  14598. /**
  14599. * 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)
  14600. */
  14601. spriteCellChangeSpeed: number;
  14602. /**
  14603. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14604. */
  14605. startSpriteCellID: number;
  14606. /**
  14607. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14608. */
  14609. endSpriteCellID: number;
  14610. /**
  14611. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14612. */
  14613. spriteCellWidth: number;
  14614. /**
  14615. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14616. */
  14617. spriteCellHeight: number;
  14618. /**
  14619. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14620. */
  14621. spriteRandomStartCell: boolean;
  14622. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14623. translationPivot: Vector2;
  14624. /** @hidden */
  14625. protected _isAnimationSheetEnabled: boolean;
  14626. /**
  14627. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14628. */
  14629. beginAnimationOnStart: boolean;
  14630. /**
  14631. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14632. */
  14633. beginAnimationFrom: number;
  14634. /**
  14635. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14636. */
  14637. beginAnimationTo: number;
  14638. /**
  14639. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14640. */
  14641. beginAnimationLoop: boolean;
  14642. /**
  14643. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14644. */
  14645. isAnimationSheetEnabled: boolean;
  14646. /**
  14647. * Get hosting scene
  14648. * @returns the scene
  14649. */
  14650. getScene(): Scene;
  14651. /**
  14652. * You can use gravity if you want to give an orientation to your particles.
  14653. */
  14654. gravity: Vector3;
  14655. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14656. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14657. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14658. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14659. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14660. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14661. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14662. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14663. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14664. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14665. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14666. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14667. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14668. /**
  14669. * Defines the delay in milliseconds before starting the system (0 by default)
  14670. */
  14671. startDelay: number;
  14672. /**
  14673. * Gets the current list of drag gradients.
  14674. * You must use addDragGradient and removeDragGradient to udpate this list
  14675. * @returns the list of drag gradients
  14676. */
  14677. getDragGradients(): Nullable<Array<FactorGradient>>;
  14678. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14679. limitVelocityDamping: number;
  14680. /**
  14681. * Gets the current list of limit velocity gradients.
  14682. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14683. * @returns the list of limit velocity gradients
  14684. */
  14685. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14686. /**
  14687. * Gets the current list of color gradients.
  14688. * You must use addColorGradient and removeColorGradient to udpate this list
  14689. * @returns the list of color gradients
  14690. */
  14691. getColorGradients(): Nullable<Array<ColorGradient>>;
  14692. /**
  14693. * Gets the current list of size gradients.
  14694. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14695. * @returns the list of size gradients
  14696. */
  14697. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14698. /**
  14699. * Gets the current list of color remap gradients.
  14700. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14701. * @returns the list of color remap gradients
  14702. */
  14703. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14704. /**
  14705. * Gets the current list of alpha remap gradients.
  14706. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14707. * @returns the list of alpha remap gradients
  14708. */
  14709. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14710. /**
  14711. * Gets the current list of life time gradients.
  14712. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14713. * @returns the list of life time gradients
  14714. */
  14715. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14716. /**
  14717. * Gets the current list of angular speed gradients.
  14718. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14719. * @returns the list of angular speed gradients
  14720. */
  14721. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14722. /**
  14723. * Gets the current list of velocity gradients.
  14724. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14725. * @returns the list of velocity gradients
  14726. */
  14727. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14728. /**
  14729. * Gets the current list of start size gradients.
  14730. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14731. * @returns the list of start size gradients
  14732. */
  14733. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14734. /**
  14735. * Gets the current list of emit rate gradients.
  14736. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14737. * @returns the list of emit rate gradients
  14738. */
  14739. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14740. /**
  14741. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14742. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14743. */
  14744. direction1: Vector3;
  14745. /**
  14746. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14747. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14748. */
  14749. direction2: Vector3;
  14750. /**
  14751. * 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.
  14752. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14753. */
  14754. minEmitBox: Vector3;
  14755. /**
  14756. * 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.
  14757. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14758. */
  14759. maxEmitBox: Vector3;
  14760. /**
  14761. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14762. */
  14763. color1: Color4;
  14764. /**
  14765. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14766. */
  14767. color2: Color4;
  14768. /**
  14769. * Color the particle will have at the end of its lifetime
  14770. */
  14771. colorDead: Color4;
  14772. /**
  14773. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14774. */
  14775. textureMask: Color4;
  14776. /**
  14777. * The particle emitter type defines the emitter used by the particle system.
  14778. * It can be for example box, sphere, or cone...
  14779. */
  14780. particleEmitterType: IParticleEmitterType;
  14781. /** @hidden */
  14782. _isSubEmitter: boolean;
  14783. /**
  14784. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14785. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14786. */
  14787. billboardMode: number;
  14788. protected _isBillboardBased: boolean;
  14789. /**
  14790. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14791. */
  14792. isBillboardBased: boolean;
  14793. /**
  14794. * The scene the particle system belongs to.
  14795. */
  14796. protected _scene: Scene;
  14797. /**
  14798. * Local cache of defines for image processing.
  14799. */
  14800. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14801. /**
  14802. * Default configuration related to image processing available in the standard Material.
  14803. */
  14804. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14805. /**
  14806. * Gets the image processing configuration used either in this material.
  14807. */
  14808. /**
  14809. * Sets the Default image processing configuration used either in the this material.
  14810. *
  14811. * If sets to null, the scene one is in use.
  14812. */
  14813. imageProcessingConfiguration: ImageProcessingConfiguration;
  14814. /**
  14815. * Attaches a new image processing configuration to the Standard Material.
  14816. * @param configuration
  14817. */
  14818. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14819. /** @hidden */
  14820. protected _reset(): void;
  14821. /** @hidden */
  14822. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14823. /**
  14824. * Instantiates a particle system.
  14825. * 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.
  14826. * @param name The name of the particle system
  14827. */
  14828. constructor(name: string);
  14829. /**
  14830. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14831. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14832. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14833. * @returns the emitter
  14834. */
  14835. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14836. /**
  14837. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14838. * @param radius The radius of the hemisphere to emit from
  14839. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14840. * @returns the emitter
  14841. */
  14842. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14843. /**
  14844. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14845. * @param radius The radius of the sphere to emit from
  14846. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14847. * @returns the emitter
  14848. */
  14849. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14850. /**
  14851. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14852. * @param radius The radius of the sphere to emit from
  14853. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14854. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14855. * @returns the emitter
  14856. */
  14857. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14858. /**
  14859. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14860. * @param radius The radius of the emission cylinder
  14861. * @param height The height of the emission cylinder
  14862. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14863. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14864. * @returns the emitter
  14865. */
  14866. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14867. /**
  14868. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14869. * @param radius The radius of the cylinder to emit from
  14870. * @param height The height of the emission cylinder
  14871. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14872. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14873. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14874. * @returns the emitter
  14875. */
  14876. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14877. /**
  14878. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14879. * @param radius The radius of the cone to emit from
  14880. * @param angle The base angle of the cone
  14881. * @returns the emitter
  14882. */
  14883. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14884. /**
  14885. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14886. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14887. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14888. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14889. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14890. * @returns the emitter
  14891. */
  14892. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14893. }
  14894. }
  14895. declare module "babylonjs/Particles/subEmitter" {
  14896. import { Scene } from "babylonjs/scene";
  14897. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14898. /**
  14899. * Type of sub emitter
  14900. */
  14901. export enum SubEmitterType {
  14902. /**
  14903. * Attached to the particle over it's lifetime
  14904. */
  14905. ATTACHED = 0,
  14906. /**
  14907. * Created when the particle dies
  14908. */
  14909. END = 1
  14910. }
  14911. /**
  14912. * Sub emitter class used to emit particles from an existing particle
  14913. */
  14914. export class SubEmitter {
  14915. /**
  14916. * the particle system to be used by the sub emitter
  14917. */
  14918. particleSystem: ParticleSystem;
  14919. /**
  14920. * Type of the submitter (Default: END)
  14921. */
  14922. type: SubEmitterType;
  14923. /**
  14924. * 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)
  14925. * Note: This only is supported when using an emitter of type Mesh
  14926. */
  14927. inheritDirection: boolean;
  14928. /**
  14929. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14930. */
  14931. inheritedVelocityAmount: number;
  14932. /**
  14933. * Creates a sub emitter
  14934. * @param particleSystem the particle system to be used by the sub emitter
  14935. */
  14936. constructor(
  14937. /**
  14938. * the particle system to be used by the sub emitter
  14939. */
  14940. particleSystem: ParticleSystem);
  14941. /**
  14942. * Clones the sub emitter
  14943. * @returns the cloned sub emitter
  14944. */
  14945. clone(): SubEmitter;
  14946. /**
  14947. * Serialize current object to a JSON object
  14948. * @returns the serialized object
  14949. */
  14950. serialize(): any;
  14951. /** @hidden */
  14952. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14953. /**
  14954. * Creates a new SubEmitter from a serialized JSON version
  14955. * @param serializationObject defines the JSON object to read from
  14956. * @param scene defines the hosting scene
  14957. * @param rootUrl defines the rootUrl for data loading
  14958. * @returns a new SubEmitter
  14959. */
  14960. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14961. /** Release associated resources */
  14962. dispose(): void;
  14963. }
  14964. }
  14965. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14966. /** @hidden */
  14967. export var clipPlaneFragmentDeclaration: {
  14968. name: string;
  14969. shader: string;
  14970. };
  14971. }
  14972. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14973. /** @hidden */
  14974. export var imageProcessingDeclaration: {
  14975. name: string;
  14976. shader: string;
  14977. };
  14978. }
  14979. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14980. /** @hidden */
  14981. export var imageProcessingFunctions: {
  14982. name: string;
  14983. shader: string;
  14984. };
  14985. }
  14986. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14987. /** @hidden */
  14988. export var clipPlaneFragment: {
  14989. name: string;
  14990. shader: string;
  14991. };
  14992. }
  14993. declare module "babylonjs/Shaders/particles.fragment" {
  14994. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14995. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14996. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14997. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14998. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14999. /** @hidden */
  15000. export var particlesPixelShader: {
  15001. name: string;
  15002. shader: string;
  15003. };
  15004. }
  15005. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15006. /** @hidden */
  15007. export var clipPlaneVertexDeclaration: {
  15008. name: string;
  15009. shader: string;
  15010. };
  15011. }
  15012. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15013. /** @hidden */
  15014. export var clipPlaneVertex: {
  15015. name: string;
  15016. shader: string;
  15017. };
  15018. }
  15019. declare module "babylonjs/Shaders/particles.vertex" {
  15020. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15021. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15022. /** @hidden */
  15023. export var particlesVertexShader: {
  15024. name: string;
  15025. shader: string;
  15026. };
  15027. }
  15028. declare module "babylonjs/Particles/particleSystem" {
  15029. import { Nullable } from "babylonjs/types";
  15030. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15031. import { Observable } from "babylonjs/Misc/observable";
  15032. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15033. import { Effect } from "babylonjs/Materials/effect";
  15034. import { Scene, IDisposable } from "babylonjs/scene";
  15035. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15036. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15037. import { Particle } from "babylonjs/Particles/particle";
  15038. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15039. import "babylonjs/Shaders/particles.fragment";
  15040. import "babylonjs/Shaders/particles.vertex";
  15041. /**
  15042. * This represents a particle system in Babylon.
  15043. * 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.
  15044. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15045. * @example https://doc.babylonjs.com/babylon101/particles
  15046. */
  15047. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15048. /**
  15049. * Billboard mode will only apply to Y axis
  15050. */
  15051. static readonly BILLBOARDMODE_Y: number;
  15052. /**
  15053. * Billboard mode will apply to all axes
  15054. */
  15055. static readonly BILLBOARDMODE_ALL: number;
  15056. /**
  15057. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15058. */
  15059. static readonly BILLBOARDMODE_STRETCHED: number;
  15060. /**
  15061. * This function can be defined to provide custom update for active particles.
  15062. * This function will be called instead of regular update (age, position, color, etc.).
  15063. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15064. */
  15065. updateFunction: (particles: Particle[]) => void;
  15066. private _emitterWorldMatrix;
  15067. /**
  15068. * This function can be defined to specify initial direction for every new particle.
  15069. * It by default use the emitterType defined function
  15070. */
  15071. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15072. /**
  15073. * This function can be defined to specify initial position for every new particle.
  15074. * It by default use the emitterType defined function
  15075. */
  15076. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15077. /**
  15078. * @hidden
  15079. */
  15080. _inheritedVelocityOffset: Vector3;
  15081. /**
  15082. * An event triggered when the system is disposed
  15083. */
  15084. onDisposeObservable: Observable<ParticleSystem>;
  15085. private _onDisposeObserver;
  15086. /**
  15087. * Sets a callback that will be triggered when the system is disposed
  15088. */
  15089. onDispose: () => void;
  15090. private _particles;
  15091. private _epsilon;
  15092. private _capacity;
  15093. private _stockParticles;
  15094. private _newPartsExcess;
  15095. private _vertexData;
  15096. private _vertexBuffer;
  15097. private _vertexBuffers;
  15098. private _spriteBuffer;
  15099. private _indexBuffer;
  15100. private _effect;
  15101. private _customEffect;
  15102. private _cachedDefines;
  15103. private _scaledColorStep;
  15104. private _colorDiff;
  15105. private _scaledDirection;
  15106. private _scaledGravity;
  15107. private _currentRenderId;
  15108. private _alive;
  15109. private _useInstancing;
  15110. private _started;
  15111. private _stopped;
  15112. private _actualFrame;
  15113. private _scaledUpdateSpeed;
  15114. private _vertexBufferSize;
  15115. /** @hidden */
  15116. _currentEmitRateGradient: Nullable<FactorGradient>;
  15117. /** @hidden */
  15118. _currentEmitRate1: number;
  15119. /** @hidden */
  15120. _currentEmitRate2: number;
  15121. /** @hidden */
  15122. _currentStartSizeGradient: Nullable<FactorGradient>;
  15123. /** @hidden */
  15124. _currentStartSize1: number;
  15125. /** @hidden */
  15126. _currentStartSize2: number;
  15127. private readonly _rawTextureWidth;
  15128. private _rampGradientsTexture;
  15129. private _useRampGradients;
  15130. /** Gets or sets a boolean indicating that ramp gradients must be used
  15131. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15132. */
  15133. useRampGradients: boolean;
  15134. /**
  15135. * 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.
  15136. * 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: [])
  15137. */
  15138. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15139. private _subEmitters;
  15140. /**
  15141. * @hidden
  15142. * If the particle systems emitter should be disposed when the particle system is disposed
  15143. */
  15144. _disposeEmitterOnDispose: boolean;
  15145. /**
  15146. * The current active Sub-systems, this property is used by the root particle system only.
  15147. */
  15148. activeSubSystems: Array<ParticleSystem>;
  15149. private _rootParticleSystem;
  15150. /**
  15151. * Gets the current list of active particles
  15152. */
  15153. readonly particles: Particle[];
  15154. /**
  15155. * Returns the string "ParticleSystem"
  15156. * @returns a string containing the class name
  15157. */
  15158. getClassName(): string;
  15159. /**
  15160. * Instantiates a particle system.
  15161. * 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.
  15162. * @param name The name of the particle system
  15163. * @param capacity The max number of particles alive at the same time
  15164. * @param scene The scene the particle system belongs to
  15165. * @param customEffect a custom effect used to change the way particles are rendered by default
  15166. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15167. * @param epsilon Offset used to render the particles
  15168. */
  15169. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15170. private _addFactorGradient;
  15171. private _removeFactorGradient;
  15172. /**
  15173. * Adds a new life time gradient
  15174. * @param gradient defines the gradient to use (between 0 and 1)
  15175. * @param factor defines the life time factor to affect to the specified gradient
  15176. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15177. * @returns the current particle system
  15178. */
  15179. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15180. /**
  15181. * Remove a specific life time gradient
  15182. * @param gradient defines the gradient to remove
  15183. * @returns the current particle system
  15184. */
  15185. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15186. /**
  15187. * Adds a new size gradient
  15188. * @param gradient defines the gradient to use (between 0 and 1)
  15189. * @param factor defines the size factor to affect to the specified gradient
  15190. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15191. * @returns the current particle system
  15192. */
  15193. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15194. /**
  15195. * Remove a specific size gradient
  15196. * @param gradient defines the gradient to remove
  15197. * @returns the current particle system
  15198. */
  15199. removeSizeGradient(gradient: number): IParticleSystem;
  15200. /**
  15201. * Adds a new color remap gradient
  15202. * @param gradient defines the gradient to use (between 0 and 1)
  15203. * @param min defines the color remap minimal range
  15204. * @param max defines the color remap maximal range
  15205. * @returns the current particle system
  15206. */
  15207. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15208. /**
  15209. * Remove a specific color remap gradient
  15210. * @param gradient defines the gradient to remove
  15211. * @returns the current particle system
  15212. */
  15213. removeColorRemapGradient(gradient: number): IParticleSystem;
  15214. /**
  15215. * Adds a new alpha remap gradient
  15216. * @param gradient defines the gradient to use (between 0 and 1)
  15217. * @param min defines the alpha remap minimal range
  15218. * @param max defines the alpha remap maximal range
  15219. * @returns the current particle system
  15220. */
  15221. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15222. /**
  15223. * Remove a specific alpha remap gradient
  15224. * @param gradient defines the gradient to remove
  15225. * @returns the current particle system
  15226. */
  15227. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15228. /**
  15229. * Adds a new angular speed gradient
  15230. * @param gradient defines the gradient to use (between 0 and 1)
  15231. * @param factor defines the angular speed to affect to the specified gradient
  15232. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15233. * @returns the current particle system
  15234. */
  15235. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15236. /**
  15237. * Remove a specific angular speed gradient
  15238. * @param gradient defines the gradient to remove
  15239. * @returns the current particle system
  15240. */
  15241. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15242. /**
  15243. * Adds a new velocity gradient
  15244. * @param gradient defines the gradient to use (between 0 and 1)
  15245. * @param factor defines the velocity to affect to the specified gradient
  15246. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15247. * @returns the current particle system
  15248. */
  15249. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15250. /**
  15251. * Remove a specific velocity gradient
  15252. * @param gradient defines the gradient to remove
  15253. * @returns the current particle system
  15254. */
  15255. removeVelocityGradient(gradient: number): IParticleSystem;
  15256. /**
  15257. * Adds a new limit velocity gradient
  15258. * @param gradient defines the gradient to use (between 0 and 1)
  15259. * @param factor defines the limit velocity value to affect to the specified gradient
  15260. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15261. * @returns the current particle system
  15262. */
  15263. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15264. /**
  15265. * Remove a specific limit velocity gradient
  15266. * @param gradient defines the gradient to remove
  15267. * @returns the current particle system
  15268. */
  15269. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15270. /**
  15271. * Adds a new drag gradient
  15272. * @param gradient defines the gradient to use (between 0 and 1)
  15273. * @param factor defines the drag value to affect to the specified gradient
  15274. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15275. * @returns the current particle system
  15276. */
  15277. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15278. /**
  15279. * Remove a specific drag gradient
  15280. * @param gradient defines the gradient to remove
  15281. * @returns the current particle system
  15282. */
  15283. removeDragGradient(gradient: number): IParticleSystem;
  15284. /**
  15285. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15286. * @param gradient defines the gradient to use (between 0 and 1)
  15287. * @param factor defines the emit rate value to affect to the specified gradient
  15288. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15289. * @returns the current particle system
  15290. */
  15291. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15292. /**
  15293. * Remove a specific emit rate gradient
  15294. * @param gradient defines the gradient to remove
  15295. * @returns the current particle system
  15296. */
  15297. removeEmitRateGradient(gradient: number): IParticleSystem;
  15298. /**
  15299. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15300. * @param gradient defines the gradient to use (between 0 and 1)
  15301. * @param factor defines the start size value to affect to the specified gradient
  15302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15303. * @returns the current particle system
  15304. */
  15305. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15306. /**
  15307. * Remove a specific start size gradient
  15308. * @param gradient defines the gradient to remove
  15309. * @returns the current particle system
  15310. */
  15311. removeStartSizeGradient(gradient: number): IParticleSystem;
  15312. private _createRampGradientTexture;
  15313. /**
  15314. * Gets the current list of ramp gradients.
  15315. * You must use addRampGradient and removeRampGradient to udpate this list
  15316. * @returns the list of ramp gradients
  15317. */
  15318. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15319. /**
  15320. * Adds a new ramp gradient used to remap particle colors
  15321. * @param gradient defines the gradient to use (between 0 and 1)
  15322. * @param color defines the color to affect to the specified gradient
  15323. * @returns the current particle system
  15324. */
  15325. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15326. /**
  15327. * Remove a specific ramp gradient
  15328. * @param gradient defines the gradient to remove
  15329. * @returns the current particle system
  15330. */
  15331. removeRampGradient(gradient: number): ParticleSystem;
  15332. /**
  15333. * Adds a new color gradient
  15334. * @param gradient defines the gradient to use (between 0 and 1)
  15335. * @param color1 defines the color to affect to the specified gradient
  15336. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15337. * @returns this particle system
  15338. */
  15339. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15340. /**
  15341. * Remove a specific color gradient
  15342. * @param gradient defines the gradient to remove
  15343. * @returns this particle system
  15344. */
  15345. removeColorGradient(gradient: number): IParticleSystem;
  15346. private _fetchR;
  15347. protected _reset(): void;
  15348. private _resetEffect;
  15349. private _createVertexBuffers;
  15350. private _createIndexBuffer;
  15351. /**
  15352. * Gets the maximum number of particles active at the same time.
  15353. * @returns The max number of active particles.
  15354. */
  15355. getCapacity(): number;
  15356. /**
  15357. * Gets whether there are still active particles in the system.
  15358. * @returns True if it is alive, otherwise false.
  15359. */
  15360. isAlive(): boolean;
  15361. /**
  15362. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15363. * @returns True if it has been started, otherwise false.
  15364. */
  15365. isStarted(): boolean;
  15366. private _prepareSubEmitterInternalArray;
  15367. /**
  15368. * Starts the particle system and begins to emit
  15369. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15370. */
  15371. start(delay?: number): void;
  15372. /**
  15373. * Stops the particle system.
  15374. * @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.
  15375. */
  15376. stop(stopSubEmitters?: boolean): void;
  15377. /**
  15378. * Remove all active particles
  15379. */
  15380. reset(): void;
  15381. /**
  15382. * @hidden (for internal use only)
  15383. */
  15384. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15385. /**
  15386. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15387. * Its lifetime will start back at 0.
  15388. */
  15389. recycleParticle: (particle: Particle) => void;
  15390. private _stopSubEmitters;
  15391. private _createParticle;
  15392. private _removeFromRoot;
  15393. private _emitFromParticle;
  15394. private _update;
  15395. /** @hidden */
  15396. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15397. /** @hidden */
  15398. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15399. /** @hidden */
  15400. private _getEffect;
  15401. /**
  15402. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15403. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15404. */
  15405. animate(preWarmOnly?: boolean): void;
  15406. private _appendParticleVertices;
  15407. /**
  15408. * Rebuilds the particle system.
  15409. */
  15410. rebuild(): void;
  15411. /**
  15412. * Is this system ready to be used/rendered
  15413. * @return true if the system is ready
  15414. */
  15415. isReady(): boolean;
  15416. private _render;
  15417. /**
  15418. * Renders the particle system in its current state.
  15419. * @returns the current number of particles
  15420. */
  15421. render(): number;
  15422. /**
  15423. * Disposes the particle system and free the associated resources
  15424. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15425. */
  15426. dispose(disposeTexture?: boolean): void;
  15427. /**
  15428. * Clones the particle system.
  15429. * @param name The name of the cloned object
  15430. * @param newEmitter The new emitter to use
  15431. * @returns the cloned particle system
  15432. */
  15433. clone(name: string, newEmitter: any): ParticleSystem;
  15434. /**
  15435. * Serializes the particle system to a JSON object.
  15436. * @returns the JSON object
  15437. */
  15438. serialize(): any;
  15439. /** @hidden */
  15440. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15441. /** @hidden */
  15442. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15443. /**
  15444. * Parses a JSON object to create a particle system.
  15445. * @param parsedParticleSystem The JSON object to parse
  15446. * @param scene The scene to create the particle system in
  15447. * @param rootUrl The root url to use to load external dependencies like texture
  15448. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15449. * @returns the Parsed particle system
  15450. */
  15451. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15452. }
  15453. }
  15454. declare module "babylonjs/Particles/particle" {
  15455. import { Nullable } from "babylonjs/types";
  15456. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15457. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15458. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15459. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15460. /**
  15461. * A particle represents one of the element emitted by a particle system.
  15462. * This is mainly define by its coordinates, direction, velocity and age.
  15463. */
  15464. export class Particle {
  15465. /**
  15466. * The particle system the particle belongs to.
  15467. */
  15468. particleSystem: ParticleSystem;
  15469. private static _Count;
  15470. /**
  15471. * Unique ID of the particle
  15472. */
  15473. id: number;
  15474. /**
  15475. * The world position of the particle in the scene.
  15476. */
  15477. position: Vector3;
  15478. /**
  15479. * The world direction of the particle in the scene.
  15480. */
  15481. direction: Vector3;
  15482. /**
  15483. * The color of the particle.
  15484. */
  15485. color: Color4;
  15486. /**
  15487. * The color change of the particle per step.
  15488. */
  15489. colorStep: Color4;
  15490. /**
  15491. * Defines how long will the life of the particle be.
  15492. */
  15493. lifeTime: number;
  15494. /**
  15495. * The current age of the particle.
  15496. */
  15497. age: number;
  15498. /**
  15499. * The current size of the particle.
  15500. */
  15501. size: number;
  15502. /**
  15503. * The current scale of the particle.
  15504. */
  15505. scale: Vector2;
  15506. /**
  15507. * The current angle of the particle.
  15508. */
  15509. angle: number;
  15510. /**
  15511. * Defines how fast is the angle changing.
  15512. */
  15513. angularSpeed: number;
  15514. /**
  15515. * Defines the cell index used by the particle to be rendered from a sprite.
  15516. */
  15517. cellIndex: number;
  15518. /**
  15519. * The information required to support color remapping
  15520. */
  15521. remapData: Vector4;
  15522. /** @hidden */
  15523. _randomCellOffset?: number;
  15524. /** @hidden */
  15525. _initialDirection: Nullable<Vector3>;
  15526. /** @hidden */
  15527. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15528. /** @hidden */
  15529. _initialStartSpriteCellID: number;
  15530. /** @hidden */
  15531. _initialEndSpriteCellID: number;
  15532. /** @hidden */
  15533. _currentColorGradient: Nullable<ColorGradient>;
  15534. /** @hidden */
  15535. _currentColor1: Color4;
  15536. /** @hidden */
  15537. _currentColor2: Color4;
  15538. /** @hidden */
  15539. _currentSizeGradient: Nullable<FactorGradient>;
  15540. /** @hidden */
  15541. _currentSize1: number;
  15542. /** @hidden */
  15543. _currentSize2: number;
  15544. /** @hidden */
  15545. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15546. /** @hidden */
  15547. _currentAngularSpeed1: number;
  15548. /** @hidden */
  15549. _currentAngularSpeed2: number;
  15550. /** @hidden */
  15551. _currentVelocityGradient: Nullable<FactorGradient>;
  15552. /** @hidden */
  15553. _currentVelocity1: number;
  15554. /** @hidden */
  15555. _currentVelocity2: number;
  15556. /** @hidden */
  15557. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15558. /** @hidden */
  15559. _currentLimitVelocity1: number;
  15560. /** @hidden */
  15561. _currentLimitVelocity2: number;
  15562. /** @hidden */
  15563. _currentDragGradient: Nullable<FactorGradient>;
  15564. /** @hidden */
  15565. _currentDrag1: number;
  15566. /** @hidden */
  15567. _currentDrag2: number;
  15568. /** @hidden */
  15569. _randomNoiseCoordinates1: Vector3;
  15570. /** @hidden */
  15571. _randomNoiseCoordinates2: Vector3;
  15572. /**
  15573. * Creates a new instance Particle
  15574. * @param particleSystem the particle system the particle belongs to
  15575. */
  15576. constructor(
  15577. /**
  15578. * The particle system the particle belongs to.
  15579. */
  15580. particleSystem: ParticleSystem);
  15581. private updateCellInfoFromSystem;
  15582. /**
  15583. * Defines how the sprite cell index is updated for the particle
  15584. */
  15585. updateCellIndex(): void;
  15586. /** @hidden */
  15587. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15588. /** @hidden */
  15589. _inheritParticleInfoToSubEmitters(): void;
  15590. /** @hidden */
  15591. _reset(): void;
  15592. /**
  15593. * Copy the properties of particle to another one.
  15594. * @param other the particle to copy the information to.
  15595. */
  15596. copyTo(other: Particle): void;
  15597. }
  15598. }
  15599. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15600. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15601. import { Effect } from "babylonjs/Materials/effect";
  15602. import { Particle } from "babylonjs/Particles/particle";
  15603. /**
  15604. * Particle emitter represents a volume emitting particles.
  15605. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15606. */
  15607. export interface IParticleEmitterType {
  15608. /**
  15609. * Called by the particle System when the direction is computed for the created particle.
  15610. * @param worldMatrix is the world matrix of the particle system
  15611. * @param directionToUpdate is the direction vector to update with the result
  15612. * @param particle is the particle we are computed the direction for
  15613. */
  15614. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15615. /**
  15616. * Called by the particle System when the position is computed for the created particle.
  15617. * @param worldMatrix is the world matrix of the particle system
  15618. * @param positionToUpdate is the position vector to update with the result
  15619. * @param particle is the particle we are computed the position for
  15620. */
  15621. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15622. /**
  15623. * Clones the current emitter and returns a copy of it
  15624. * @returns the new emitter
  15625. */
  15626. clone(): IParticleEmitterType;
  15627. /**
  15628. * Called by the GPUParticleSystem to setup the update shader
  15629. * @param effect defines the update shader
  15630. */
  15631. applyToShader(effect: Effect): void;
  15632. /**
  15633. * Returns a string to use to update the GPU particles update shader
  15634. * @returns the effect defines string
  15635. */
  15636. getEffectDefines(): string;
  15637. /**
  15638. * Returns a string representing the class name
  15639. * @returns a string containing the class name
  15640. */
  15641. getClassName(): string;
  15642. /**
  15643. * Serializes the particle system to a JSON object.
  15644. * @returns the JSON object
  15645. */
  15646. serialize(): any;
  15647. /**
  15648. * Parse properties from a JSON object
  15649. * @param serializationObject defines the JSON object
  15650. */
  15651. parse(serializationObject: any): void;
  15652. }
  15653. }
  15654. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15655. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15656. import { Effect } from "babylonjs/Materials/effect";
  15657. import { Particle } from "babylonjs/Particles/particle";
  15658. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15659. /**
  15660. * Particle emitter emitting particles from the inside of a box.
  15661. * It emits the particles randomly between 2 given directions.
  15662. */
  15663. export class BoxParticleEmitter implements IParticleEmitterType {
  15664. /**
  15665. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15666. */
  15667. direction1: Vector3;
  15668. /**
  15669. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15670. */
  15671. direction2: Vector3;
  15672. /**
  15673. * 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.
  15674. */
  15675. minEmitBox: Vector3;
  15676. /**
  15677. * 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.
  15678. */
  15679. maxEmitBox: Vector3;
  15680. /**
  15681. * Creates a new instance BoxParticleEmitter
  15682. */
  15683. constructor();
  15684. /**
  15685. * Called by the particle System when the direction is computed for the created particle.
  15686. * @param worldMatrix is the world matrix of the particle system
  15687. * @param directionToUpdate is the direction vector to update with the result
  15688. * @param particle is the particle we are computed the direction for
  15689. */
  15690. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15691. /**
  15692. * Called by the particle System when the position is computed for the created particle.
  15693. * @param worldMatrix is the world matrix of the particle system
  15694. * @param positionToUpdate is the position vector to update with the result
  15695. * @param particle is the particle we are computed the position for
  15696. */
  15697. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15698. /**
  15699. * Clones the current emitter and returns a copy of it
  15700. * @returns the new emitter
  15701. */
  15702. clone(): BoxParticleEmitter;
  15703. /**
  15704. * Called by the GPUParticleSystem to setup the update shader
  15705. * @param effect defines the update shader
  15706. */
  15707. applyToShader(effect: Effect): void;
  15708. /**
  15709. * Returns a string to use to update the GPU particles update shader
  15710. * @returns a string containng the defines string
  15711. */
  15712. getEffectDefines(): string;
  15713. /**
  15714. * Returns the string "BoxParticleEmitter"
  15715. * @returns a string containing the class name
  15716. */
  15717. getClassName(): string;
  15718. /**
  15719. * Serializes the particle system to a JSON object.
  15720. * @returns the JSON object
  15721. */
  15722. serialize(): any;
  15723. /**
  15724. * Parse properties from a JSON object
  15725. * @param serializationObject defines the JSON object
  15726. */
  15727. parse(serializationObject: any): void;
  15728. }
  15729. }
  15730. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15731. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15732. import { Effect } from "babylonjs/Materials/effect";
  15733. import { Particle } from "babylonjs/Particles/particle";
  15734. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15735. /**
  15736. * Particle emitter emitting particles from the inside of a cone.
  15737. * It emits the particles alongside the cone volume from the base to the particle.
  15738. * The emission direction might be randomized.
  15739. */
  15740. export class ConeParticleEmitter implements IParticleEmitterType {
  15741. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15742. directionRandomizer: number;
  15743. private _radius;
  15744. private _angle;
  15745. private _height;
  15746. /**
  15747. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15748. */
  15749. radiusRange: number;
  15750. /**
  15751. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15752. */
  15753. heightRange: number;
  15754. /**
  15755. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15756. */
  15757. emitFromSpawnPointOnly: boolean;
  15758. /**
  15759. * Gets or sets the radius of the emission cone
  15760. */
  15761. radius: number;
  15762. /**
  15763. * Gets or sets the angle of the emission cone
  15764. */
  15765. angle: number;
  15766. private _buildHeight;
  15767. /**
  15768. * Creates a new instance ConeParticleEmitter
  15769. * @param radius the radius of the emission cone (1 by default)
  15770. * @param angle the cone base angle (PI by default)
  15771. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15772. */
  15773. constructor(radius?: number, angle?: number,
  15774. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15775. directionRandomizer?: number);
  15776. /**
  15777. * Called by the particle System when the direction is computed for the created particle.
  15778. * @param worldMatrix is the world matrix of the particle system
  15779. * @param directionToUpdate is the direction vector to update with the result
  15780. * @param particle is the particle we are computed the direction for
  15781. */
  15782. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15783. /**
  15784. * Called by the particle System when the position is computed for the created particle.
  15785. * @param worldMatrix is the world matrix of the particle system
  15786. * @param positionToUpdate is the position vector to update with the result
  15787. * @param particle is the particle we are computed the position for
  15788. */
  15789. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15790. /**
  15791. * Clones the current emitter and returns a copy of it
  15792. * @returns the new emitter
  15793. */
  15794. clone(): ConeParticleEmitter;
  15795. /**
  15796. * Called by the GPUParticleSystem to setup the update shader
  15797. * @param effect defines the update shader
  15798. */
  15799. applyToShader(effect: Effect): void;
  15800. /**
  15801. * Returns a string to use to update the GPU particles update shader
  15802. * @returns a string containng the defines string
  15803. */
  15804. getEffectDefines(): string;
  15805. /**
  15806. * Returns the string "ConeParticleEmitter"
  15807. * @returns a string containing the class name
  15808. */
  15809. getClassName(): string;
  15810. /**
  15811. * Serializes the particle system to a JSON object.
  15812. * @returns the JSON object
  15813. */
  15814. serialize(): any;
  15815. /**
  15816. * Parse properties from a JSON object
  15817. * @param serializationObject defines the JSON object
  15818. */
  15819. parse(serializationObject: any): void;
  15820. }
  15821. }
  15822. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15823. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15824. import { Effect } from "babylonjs/Materials/effect";
  15825. import { Particle } from "babylonjs/Particles/particle";
  15826. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15827. /**
  15828. * Particle emitter emitting particles from the inside of a cylinder.
  15829. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15830. */
  15831. export class CylinderParticleEmitter implements IParticleEmitterType {
  15832. /**
  15833. * The radius of the emission cylinder.
  15834. */
  15835. radius: number;
  15836. /**
  15837. * The height of the emission cylinder.
  15838. */
  15839. height: number;
  15840. /**
  15841. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15842. */
  15843. radiusRange: number;
  15844. /**
  15845. * How much to randomize the particle direction [0-1].
  15846. */
  15847. directionRandomizer: number;
  15848. /**
  15849. * Creates a new instance CylinderParticleEmitter
  15850. * @param radius the radius of the emission cylinder (1 by default)
  15851. * @param height the height of the emission cylinder (1 by default)
  15852. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15853. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15854. */
  15855. constructor(
  15856. /**
  15857. * The radius of the emission cylinder.
  15858. */
  15859. radius?: number,
  15860. /**
  15861. * The height of the emission cylinder.
  15862. */
  15863. height?: number,
  15864. /**
  15865. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15866. */
  15867. radiusRange?: number,
  15868. /**
  15869. * How much to randomize the particle direction [0-1].
  15870. */
  15871. directionRandomizer?: number);
  15872. /**
  15873. * Called by the particle System when the direction is computed for the created particle.
  15874. * @param worldMatrix is the world matrix of the particle system
  15875. * @param directionToUpdate is the direction vector to update with the result
  15876. * @param particle is the particle we are computed the direction for
  15877. */
  15878. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15879. /**
  15880. * Called by the particle System when the position is computed for the created particle.
  15881. * @param worldMatrix is the world matrix of the particle system
  15882. * @param positionToUpdate is the position vector to update with the result
  15883. * @param particle is the particle we are computed the position for
  15884. */
  15885. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15886. /**
  15887. * Clones the current emitter and returns a copy of it
  15888. * @returns the new emitter
  15889. */
  15890. clone(): CylinderParticleEmitter;
  15891. /**
  15892. * Called by the GPUParticleSystem to setup the update shader
  15893. * @param effect defines the update shader
  15894. */
  15895. applyToShader(effect: Effect): void;
  15896. /**
  15897. * Returns a string to use to update the GPU particles update shader
  15898. * @returns a string containng the defines string
  15899. */
  15900. getEffectDefines(): string;
  15901. /**
  15902. * Returns the string "CylinderParticleEmitter"
  15903. * @returns a string containing the class name
  15904. */
  15905. getClassName(): string;
  15906. /**
  15907. * Serializes the particle system to a JSON object.
  15908. * @returns the JSON object
  15909. */
  15910. serialize(): any;
  15911. /**
  15912. * Parse properties from a JSON object
  15913. * @param serializationObject defines the JSON object
  15914. */
  15915. parse(serializationObject: any): void;
  15916. }
  15917. /**
  15918. * Particle emitter emitting particles from the inside of a cylinder.
  15919. * It emits the particles randomly between two vectors.
  15920. */
  15921. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15922. /**
  15923. * The min limit of the emission direction.
  15924. */
  15925. direction1: Vector3;
  15926. /**
  15927. * The max limit of the emission direction.
  15928. */
  15929. direction2: Vector3;
  15930. /**
  15931. * Creates a new instance CylinderDirectedParticleEmitter
  15932. * @param radius the radius of the emission cylinder (1 by default)
  15933. * @param height the height of the emission cylinder (1 by default)
  15934. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15935. * @param direction1 the min limit of the emission direction (up vector by default)
  15936. * @param direction2 the max limit of the emission direction (up vector by default)
  15937. */
  15938. constructor(radius?: number, height?: number, radiusRange?: number,
  15939. /**
  15940. * The min limit of the emission direction.
  15941. */
  15942. direction1?: Vector3,
  15943. /**
  15944. * The max limit of the emission direction.
  15945. */
  15946. direction2?: Vector3);
  15947. /**
  15948. * Called by the particle System when the direction is computed for the created particle.
  15949. * @param worldMatrix is the world matrix of the particle system
  15950. * @param directionToUpdate is the direction vector to update with the result
  15951. * @param particle is the particle we are computed the direction for
  15952. */
  15953. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15954. /**
  15955. * Clones the current emitter and returns a copy of it
  15956. * @returns the new emitter
  15957. */
  15958. clone(): CylinderDirectedParticleEmitter;
  15959. /**
  15960. * Called by the GPUParticleSystem to setup the update shader
  15961. * @param effect defines the update shader
  15962. */
  15963. applyToShader(effect: Effect): void;
  15964. /**
  15965. * Returns a string to use to update the GPU particles update shader
  15966. * @returns a string containng the defines string
  15967. */
  15968. getEffectDefines(): string;
  15969. /**
  15970. * Returns the string "CylinderDirectedParticleEmitter"
  15971. * @returns a string containing the class name
  15972. */
  15973. getClassName(): string;
  15974. /**
  15975. * Serializes the particle system to a JSON object.
  15976. * @returns the JSON object
  15977. */
  15978. serialize(): any;
  15979. /**
  15980. * Parse properties from a JSON object
  15981. * @param serializationObject defines the JSON object
  15982. */
  15983. parse(serializationObject: any): void;
  15984. }
  15985. }
  15986. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15987. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15988. import { Effect } from "babylonjs/Materials/effect";
  15989. import { Particle } from "babylonjs/Particles/particle";
  15990. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15991. /**
  15992. * Particle emitter emitting particles from the inside of a hemisphere.
  15993. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15994. */
  15995. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15996. /**
  15997. * The radius of the emission hemisphere.
  15998. */
  15999. radius: number;
  16000. /**
  16001. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16002. */
  16003. radiusRange: number;
  16004. /**
  16005. * How much to randomize the particle direction [0-1].
  16006. */
  16007. directionRandomizer: number;
  16008. /**
  16009. * Creates a new instance HemisphericParticleEmitter
  16010. * @param radius the radius of the emission hemisphere (1 by default)
  16011. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16012. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16013. */
  16014. constructor(
  16015. /**
  16016. * The radius of the emission hemisphere.
  16017. */
  16018. radius?: number,
  16019. /**
  16020. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16021. */
  16022. radiusRange?: number,
  16023. /**
  16024. * How much to randomize the particle direction [0-1].
  16025. */
  16026. directionRandomizer?: number);
  16027. /**
  16028. * Called by the particle System when the direction is computed for the created particle.
  16029. * @param worldMatrix is the world matrix of the particle system
  16030. * @param directionToUpdate is the direction vector to update with the result
  16031. * @param particle is the particle we are computed the direction for
  16032. */
  16033. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16034. /**
  16035. * Called by the particle System when the position is computed for the created particle.
  16036. * @param worldMatrix is the world matrix of the particle system
  16037. * @param positionToUpdate is the position vector to update with the result
  16038. * @param particle is the particle we are computed the position for
  16039. */
  16040. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16041. /**
  16042. * Clones the current emitter and returns a copy of it
  16043. * @returns the new emitter
  16044. */
  16045. clone(): HemisphericParticleEmitter;
  16046. /**
  16047. * Called by the GPUParticleSystem to setup the update shader
  16048. * @param effect defines the update shader
  16049. */
  16050. applyToShader(effect: Effect): void;
  16051. /**
  16052. * Returns a string to use to update the GPU particles update shader
  16053. * @returns a string containng the defines string
  16054. */
  16055. getEffectDefines(): string;
  16056. /**
  16057. * Returns the string "HemisphericParticleEmitter"
  16058. * @returns a string containing the class name
  16059. */
  16060. getClassName(): string;
  16061. /**
  16062. * Serializes the particle system to a JSON object.
  16063. * @returns the JSON object
  16064. */
  16065. serialize(): any;
  16066. /**
  16067. * Parse properties from a JSON object
  16068. * @param serializationObject defines the JSON object
  16069. */
  16070. parse(serializationObject: any): void;
  16071. }
  16072. }
  16073. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16074. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16075. import { Effect } from "babylonjs/Materials/effect";
  16076. import { Particle } from "babylonjs/Particles/particle";
  16077. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16078. /**
  16079. * Particle emitter emitting particles from a point.
  16080. * It emits the particles randomly between 2 given directions.
  16081. */
  16082. export class PointParticleEmitter implements IParticleEmitterType {
  16083. /**
  16084. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16085. */
  16086. direction1: Vector3;
  16087. /**
  16088. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16089. */
  16090. direction2: Vector3;
  16091. /**
  16092. * Creates a new instance PointParticleEmitter
  16093. */
  16094. constructor();
  16095. /**
  16096. * Called by the particle System when the direction is computed for the created particle.
  16097. * @param worldMatrix is the world matrix of the particle system
  16098. * @param directionToUpdate is the direction vector to update with the result
  16099. * @param particle is the particle we are computed the direction for
  16100. */
  16101. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16102. /**
  16103. * Called by the particle System when the position is computed for the created particle.
  16104. * @param worldMatrix is the world matrix of the particle system
  16105. * @param positionToUpdate is the position vector to update with the result
  16106. * @param particle is the particle we are computed the position for
  16107. */
  16108. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16109. /**
  16110. * Clones the current emitter and returns a copy of it
  16111. * @returns the new emitter
  16112. */
  16113. clone(): PointParticleEmitter;
  16114. /**
  16115. * Called by the GPUParticleSystem to setup the update shader
  16116. * @param effect defines the update shader
  16117. */
  16118. applyToShader(effect: Effect): void;
  16119. /**
  16120. * Returns a string to use to update the GPU particles update shader
  16121. * @returns a string containng the defines string
  16122. */
  16123. getEffectDefines(): string;
  16124. /**
  16125. * Returns the string "PointParticleEmitter"
  16126. * @returns a string containing the class name
  16127. */
  16128. getClassName(): string;
  16129. /**
  16130. * Serializes the particle system to a JSON object.
  16131. * @returns the JSON object
  16132. */
  16133. serialize(): any;
  16134. /**
  16135. * Parse properties from a JSON object
  16136. * @param serializationObject defines the JSON object
  16137. */
  16138. parse(serializationObject: any): void;
  16139. }
  16140. }
  16141. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16142. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16143. import { Effect } from "babylonjs/Materials/effect";
  16144. import { Particle } from "babylonjs/Particles/particle";
  16145. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16146. /**
  16147. * Particle emitter emitting particles from the inside of a sphere.
  16148. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16149. */
  16150. export class SphereParticleEmitter implements IParticleEmitterType {
  16151. /**
  16152. * The radius of the emission sphere.
  16153. */
  16154. radius: number;
  16155. /**
  16156. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16157. */
  16158. radiusRange: number;
  16159. /**
  16160. * How much to randomize the particle direction [0-1].
  16161. */
  16162. directionRandomizer: number;
  16163. /**
  16164. * Creates a new instance SphereParticleEmitter
  16165. * @param radius the radius of the emission sphere (1 by default)
  16166. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16167. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16168. */
  16169. constructor(
  16170. /**
  16171. * The radius of the emission sphere.
  16172. */
  16173. radius?: number,
  16174. /**
  16175. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16176. */
  16177. radiusRange?: number,
  16178. /**
  16179. * How much to randomize the particle direction [0-1].
  16180. */
  16181. directionRandomizer?: number);
  16182. /**
  16183. * Called by the particle System when the direction is computed for the created particle.
  16184. * @param worldMatrix is the world matrix of the particle system
  16185. * @param directionToUpdate is the direction vector to update with the result
  16186. * @param particle is the particle we are computed the direction for
  16187. */
  16188. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16189. /**
  16190. * Called by the particle System when the position is computed for the created particle.
  16191. * @param worldMatrix is the world matrix of the particle system
  16192. * @param positionToUpdate is the position vector to update with the result
  16193. * @param particle is the particle we are computed the position for
  16194. */
  16195. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16196. /**
  16197. * Clones the current emitter and returns a copy of it
  16198. * @returns the new emitter
  16199. */
  16200. clone(): SphereParticleEmitter;
  16201. /**
  16202. * Called by the GPUParticleSystem to setup the update shader
  16203. * @param effect defines the update shader
  16204. */
  16205. applyToShader(effect: Effect): void;
  16206. /**
  16207. * Returns a string to use to update the GPU particles update shader
  16208. * @returns a string containng the defines string
  16209. */
  16210. getEffectDefines(): string;
  16211. /**
  16212. * Returns the string "SphereParticleEmitter"
  16213. * @returns a string containing the class name
  16214. */
  16215. getClassName(): string;
  16216. /**
  16217. * Serializes the particle system to a JSON object.
  16218. * @returns the JSON object
  16219. */
  16220. serialize(): any;
  16221. /**
  16222. * Parse properties from a JSON object
  16223. * @param serializationObject defines the JSON object
  16224. */
  16225. parse(serializationObject: any): void;
  16226. }
  16227. /**
  16228. * Particle emitter emitting particles from the inside of a sphere.
  16229. * It emits the particles randomly between two vectors.
  16230. */
  16231. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16232. /**
  16233. * The min limit of the emission direction.
  16234. */
  16235. direction1: Vector3;
  16236. /**
  16237. * The max limit of the emission direction.
  16238. */
  16239. direction2: Vector3;
  16240. /**
  16241. * Creates a new instance SphereDirectedParticleEmitter
  16242. * @param radius the radius of the emission sphere (1 by default)
  16243. * @param direction1 the min limit of the emission direction (up vector by default)
  16244. * @param direction2 the max limit of the emission direction (up vector by default)
  16245. */
  16246. constructor(radius?: number,
  16247. /**
  16248. * The min limit of the emission direction.
  16249. */
  16250. direction1?: Vector3,
  16251. /**
  16252. * The max limit of the emission direction.
  16253. */
  16254. direction2?: Vector3);
  16255. /**
  16256. * Called by the particle System when the direction is computed for the created particle.
  16257. * @param worldMatrix is the world matrix of the particle system
  16258. * @param directionToUpdate is the direction vector to update with the result
  16259. * @param particle is the particle we are computed the direction for
  16260. */
  16261. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16262. /**
  16263. * Clones the current emitter and returns a copy of it
  16264. * @returns the new emitter
  16265. */
  16266. clone(): SphereDirectedParticleEmitter;
  16267. /**
  16268. * Called by the GPUParticleSystem to setup the update shader
  16269. * @param effect defines the update shader
  16270. */
  16271. applyToShader(effect: Effect): void;
  16272. /**
  16273. * Returns a string to use to update the GPU particles update shader
  16274. * @returns a string containng the defines string
  16275. */
  16276. getEffectDefines(): string;
  16277. /**
  16278. * Returns the string "SphereDirectedParticleEmitter"
  16279. * @returns a string containing the class name
  16280. */
  16281. getClassName(): string;
  16282. /**
  16283. * Serializes the particle system to a JSON object.
  16284. * @returns the JSON object
  16285. */
  16286. serialize(): any;
  16287. /**
  16288. * Parse properties from a JSON object
  16289. * @param serializationObject defines the JSON object
  16290. */
  16291. parse(serializationObject: any): void;
  16292. }
  16293. }
  16294. declare module "babylonjs/Particles/EmitterTypes/index" {
  16295. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16296. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16297. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16298. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16299. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16300. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16301. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16302. }
  16303. declare module "babylonjs/Particles/IParticleSystem" {
  16304. import { Nullable } from "babylonjs/types";
  16305. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16307. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16308. import { Texture } from "babylonjs/Materials/Textures/texture";
  16309. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16310. import { Scene } from "babylonjs/scene";
  16311. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16312. import { Animation } from "babylonjs/Animations/animation";
  16313. /**
  16314. * Interface representing a particle system in Babylon.js.
  16315. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16316. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16317. */
  16318. export interface IParticleSystem {
  16319. /**
  16320. * List of animations used by the particle system.
  16321. */
  16322. animations: Animation[];
  16323. /**
  16324. * The id of the Particle system.
  16325. */
  16326. id: string;
  16327. /**
  16328. * The name of the Particle system.
  16329. */
  16330. name: string;
  16331. /**
  16332. * The emitter represents the Mesh or position we are attaching the particle system to.
  16333. */
  16334. emitter: Nullable<AbstractMesh | Vector3>;
  16335. /**
  16336. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16337. */
  16338. isBillboardBased: boolean;
  16339. /**
  16340. * The rendering group used by the Particle system to chose when to render.
  16341. */
  16342. renderingGroupId: number;
  16343. /**
  16344. * The layer mask we are rendering the particles through.
  16345. */
  16346. layerMask: number;
  16347. /**
  16348. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16349. */
  16350. updateSpeed: number;
  16351. /**
  16352. * The amount of time the particle system is running (depends of the overall update speed).
  16353. */
  16354. targetStopDuration: number;
  16355. /**
  16356. * The texture used to render each particle. (this can be a spritesheet)
  16357. */
  16358. particleTexture: Nullable<Texture>;
  16359. /**
  16360. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16361. */
  16362. blendMode: number;
  16363. /**
  16364. * Minimum life time of emitting particles.
  16365. */
  16366. minLifeTime: number;
  16367. /**
  16368. * Maximum life time of emitting particles.
  16369. */
  16370. maxLifeTime: number;
  16371. /**
  16372. * Minimum Size of emitting particles.
  16373. */
  16374. minSize: number;
  16375. /**
  16376. * Maximum Size of emitting particles.
  16377. */
  16378. maxSize: number;
  16379. /**
  16380. * Minimum scale of emitting particles on X axis.
  16381. */
  16382. minScaleX: number;
  16383. /**
  16384. * Maximum scale of emitting particles on X axis.
  16385. */
  16386. maxScaleX: number;
  16387. /**
  16388. * Minimum scale of emitting particles on Y axis.
  16389. */
  16390. minScaleY: number;
  16391. /**
  16392. * Maximum scale of emitting particles on Y axis.
  16393. */
  16394. maxScaleY: number;
  16395. /**
  16396. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16397. */
  16398. color1: Color4;
  16399. /**
  16400. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16401. */
  16402. color2: Color4;
  16403. /**
  16404. * Color the particle will have at the end of its lifetime.
  16405. */
  16406. colorDead: Color4;
  16407. /**
  16408. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16409. */
  16410. emitRate: number;
  16411. /**
  16412. * You can use gravity if you want to give an orientation to your particles.
  16413. */
  16414. gravity: Vector3;
  16415. /**
  16416. * Minimum power of emitting particles.
  16417. */
  16418. minEmitPower: number;
  16419. /**
  16420. * Maximum power of emitting particles.
  16421. */
  16422. maxEmitPower: number;
  16423. /**
  16424. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16425. */
  16426. minAngularSpeed: number;
  16427. /**
  16428. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16429. */
  16430. maxAngularSpeed: number;
  16431. /**
  16432. * Gets or sets the minimal initial rotation in radians.
  16433. */
  16434. minInitialRotation: number;
  16435. /**
  16436. * Gets or sets the maximal initial rotation in radians.
  16437. */
  16438. maxInitialRotation: number;
  16439. /**
  16440. * The particle emitter type defines the emitter used by the particle system.
  16441. * It can be for example box, sphere, or cone...
  16442. */
  16443. particleEmitterType: Nullable<IParticleEmitterType>;
  16444. /**
  16445. * Defines the delay in milliseconds before starting the system (0 by default)
  16446. */
  16447. startDelay: number;
  16448. /**
  16449. * 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
  16450. */
  16451. preWarmCycles: number;
  16452. /**
  16453. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16454. */
  16455. preWarmStepOffset: number;
  16456. /**
  16457. * 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)
  16458. */
  16459. spriteCellChangeSpeed: number;
  16460. /**
  16461. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16462. */
  16463. startSpriteCellID: number;
  16464. /**
  16465. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16466. */
  16467. endSpriteCellID: number;
  16468. /**
  16469. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16470. */
  16471. spriteCellWidth: number;
  16472. /**
  16473. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16474. */
  16475. spriteCellHeight: number;
  16476. /**
  16477. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16478. */
  16479. spriteRandomStartCell: boolean;
  16480. /**
  16481. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16482. */
  16483. isAnimationSheetEnabled: boolean;
  16484. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16485. translationPivot: Vector2;
  16486. /**
  16487. * Gets or sets a texture used to add random noise to particle positions
  16488. */
  16489. noiseTexture: Nullable<BaseTexture>;
  16490. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16491. noiseStrength: Vector3;
  16492. /**
  16493. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16494. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16495. */
  16496. billboardMode: number;
  16497. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16498. limitVelocityDamping: number;
  16499. /**
  16500. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16501. */
  16502. beginAnimationOnStart: boolean;
  16503. /**
  16504. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16505. */
  16506. beginAnimationFrom: number;
  16507. /**
  16508. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16509. */
  16510. beginAnimationTo: number;
  16511. /**
  16512. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16513. */
  16514. beginAnimationLoop: boolean;
  16515. /**
  16516. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16517. */
  16518. disposeOnStop: boolean;
  16519. /**
  16520. * Gets the maximum number of particles active at the same time.
  16521. * @returns The max number of active particles.
  16522. */
  16523. getCapacity(): number;
  16524. /**
  16525. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16526. * @returns True if it has been started, otherwise false.
  16527. */
  16528. isStarted(): boolean;
  16529. /**
  16530. * Animates the particle system for this frame.
  16531. */
  16532. animate(): void;
  16533. /**
  16534. * Renders the particle system in its current state.
  16535. * @returns the current number of particles
  16536. */
  16537. render(): number;
  16538. /**
  16539. * Dispose the particle system and frees its associated resources.
  16540. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16541. */
  16542. dispose(disposeTexture?: boolean): void;
  16543. /**
  16544. * Clones the particle system.
  16545. * @param name The name of the cloned object
  16546. * @param newEmitter The new emitter to use
  16547. * @returns the cloned particle system
  16548. */
  16549. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16550. /**
  16551. * Serializes the particle system to a JSON object.
  16552. * @returns the JSON object
  16553. */
  16554. serialize(): any;
  16555. /**
  16556. * Rebuild the particle system
  16557. */
  16558. rebuild(): void;
  16559. /**
  16560. * Starts the particle system and begins to emit
  16561. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16562. */
  16563. start(delay?: number): void;
  16564. /**
  16565. * Stops the particle system.
  16566. */
  16567. stop(): void;
  16568. /**
  16569. * Remove all active particles
  16570. */
  16571. reset(): void;
  16572. /**
  16573. * Is this system ready to be used/rendered
  16574. * @return true if the system is ready
  16575. */
  16576. isReady(): boolean;
  16577. /**
  16578. * Adds a new color gradient
  16579. * @param gradient defines the gradient to use (between 0 and 1)
  16580. * @param color1 defines the color to affect to the specified gradient
  16581. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16582. * @returns the current particle system
  16583. */
  16584. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16585. /**
  16586. * Remove a specific color gradient
  16587. * @param gradient defines the gradient to remove
  16588. * @returns the current particle system
  16589. */
  16590. removeColorGradient(gradient: number): IParticleSystem;
  16591. /**
  16592. * Adds a new size gradient
  16593. * @param gradient defines the gradient to use (between 0 and 1)
  16594. * @param factor defines the size factor to affect to the specified gradient
  16595. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16596. * @returns the current particle system
  16597. */
  16598. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16599. /**
  16600. * Remove a specific size gradient
  16601. * @param gradient defines the gradient to remove
  16602. * @returns the current particle system
  16603. */
  16604. removeSizeGradient(gradient: number): IParticleSystem;
  16605. /**
  16606. * Gets the current list of color gradients.
  16607. * You must use addColorGradient and removeColorGradient to udpate this list
  16608. * @returns the list of color gradients
  16609. */
  16610. getColorGradients(): Nullable<Array<ColorGradient>>;
  16611. /**
  16612. * Gets the current list of size gradients.
  16613. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16614. * @returns the list of size gradients
  16615. */
  16616. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16617. /**
  16618. * Gets the current list of angular speed gradients.
  16619. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16620. * @returns the list of angular speed gradients
  16621. */
  16622. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16623. /**
  16624. * Adds a new angular speed gradient
  16625. * @param gradient defines the gradient to use (between 0 and 1)
  16626. * @param factor defines the angular speed to affect to the specified gradient
  16627. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16628. * @returns the current particle system
  16629. */
  16630. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16631. /**
  16632. * Remove a specific angular speed gradient
  16633. * @param gradient defines the gradient to remove
  16634. * @returns the current particle system
  16635. */
  16636. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16637. /**
  16638. * Gets the current list of velocity gradients.
  16639. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16640. * @returns the list of velocity gradients
  16641. */
  16642. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16643. /**
  16644. * Adds a new velocity gradient
  16645. * @param gradient defines the gradient to use (between 0 and 1)
  16646. * @param factor defines the velocity to affect to the specified gradient
  16647. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16648. * @returns the current particle system
  16649. */
  16650. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16651. /**
  16652. * Remove a specific velocity gradient
  16653. * @param gradient defines the gradient to remove
  16654. * @returns the current particle system
  16655. */
  16656. removeVelocityGradient(gradient: number): IParticleSystem;
  16657. /**
  16658. * Gets the current list of limit velocity gradients.
  16659. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16660. * @returns the list of limit velocity gradients
  16661. */
  16662. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16663. /**
  16664. * Adds a new limit velocity gradient
  16665. * @param gradient defines the gradient to use (between 0 and 1)
  16666. * @param factor defines the limit velocity to affect to the specified gradient
  16667. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16668. * @returns the current particle system
  16669. */
  16670. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16671. /**
  16672. * Remove a specific limit velocity gradient
  16673. * @param gradient defines the gradient to remove
  16674. * @returns the current particle system
  16675. */
  16676. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16677. /**
  16678. * Adds a new drag gradient
  16679. * @param gradient defines the gradient to use (between 0 and 1)
  16680. * @param factor defines the drag to affect to the specified gradient
  16681. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16682. * @returns the current particle system
  16683. */
  16684. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16685. /**
  16686. * Remove a specific drag gradient
  16687. * @param gradient defines the gradient to remove
  16688. * @returns the current particle system
  16689. */
  16690. removeDragGradient(gradient: number): IParticleSystem;
  16691. /**
  16692. * Gets the current list of drag gradients.
  16693. * You must use addDragGradient and removeDragGradient to udpate this list
  16694. * @returns the list of drag gradients
  16695. */
  16696. getDragGradients(): Nullable<Array<FactorGradient>>;
  16697. /**
  16698. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16699. * @param gradient defines the gradient to use (between 0 and 1)
  16700. * @param factor defines the emit rate to affect to the specified gradient
  16701. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16702. * @returns the current particle system
  16703. */
  16704. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16705. /**
  16706. * Remove a specific emit rate gradient
  16707. * @param gradient defines the gradient to remove
  16708. * @returns the current particle system
  16709. */
  16710. removeEmitRateGradient(gradient: number): IParticleSystem;
  16711. /**
  16712. * Gets the current list of emit rate gradients.
  16713. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16714. * @returns the list of emit rate gradients
  16715. */
  16716. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16717. /**
  16718. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16719. * @param gradient defines the gradient to use (between 0 and 1)
  16720. * @param factor defines the start size to affect to the specified gradient
  16721. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16722. * @returns the current particle system
  16723. */
  16724. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16725. /**
  16726. * Remove a specific start size gradient
  16727. * @param gradient defines the gradient to remove
  16728. * @returns the current particle system
  16729. */
  16730. removeStartSizeGradient(gradient: number): IParticleSystem;
  16731. /**
  16732. * Gets the current list of start size gradients.
  16733. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16734. * @returns the list of start size gradients
  16735. */
  16736. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16737. /**
  16738. * Adds a new life time gradient
  16739. * @param gradient defines the gradient to use (between 0 and 1)
  16740. * @param factor defines the life time factor to affect to the specified gradient
  16741. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16742. * @returns the current particle system
  16743. */
  16744. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16745. /**
  16746. * Remove a specific life time gradient
  16747. * @param gradient defines the gradient to remove
  16748. * @returns the current particle system
  16749. */
  16750. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16751. /**
  16752. * Gets the current list of life time gradients.
  16753. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16754. * @returns the list of life time gradients
  16755. */
  16756. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16757. /**
  16758. * Gets the current list of color gradients.
  16759. * You must use addColorGradient and removeColorGradient to udpate this list
  16760. * @returns the list of color gradients
  16761. */
  16762. getColorGradients(): Nullable<Array<ColorGradient>>;
  16763. /**
  16764. * Adds a new ramp gradient used to remap particle colors
  16765. * @param gradient defines the gradient to use (between 0 and 1)
  16766. * @param color defines the color to affect to the specified gradient
  16767. * @returns the current particle system
  16768. */
  16769. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16770. /**
  16771. * Gets the current list of ramp gradients.
  16772. * You must use addRampGradient and removeRampGradient to udpate this list
  16773. * @returns the list of ramp gradients
  16774. */
  16775. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16776. /** Gets or sets a boolean indicating that ramp gradients must be used
  16777. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16778. */
  16779. useRampGradients: boolean;
  16780. /**
  16781. * Adds a new color remap gradient
  16782. * @param gradient defines the gradient to use (between 0 and 1)
  16783. * @param min defines the color remap minimal range
  16784. * @param max defines the color remap maximal range
  16785. * @returns the current particle system
  16786. */
  16787. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16788. /**
  16789. * Gets the current list of color remap gradients.
  16790. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16791. * @returns the list of color remap gradients
  16792. */
  16793. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16794. /**
  16795. * Adds a new alpha remap gradient
  16796. * @param gradient defines the gradient to use (between 0 and 1)
  16797. * @param min defines the alpha remap minimal range
  16798. * @param max defines the alpha remap maximal range
  16799. * @returns the current particle system
  16800. */
  16801. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16802. /**
  16803. * Gets the current list of alpha remap gradients.
  16804. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16805. * @returns the list of alpha remap gradients
  16806. */
  16807. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16808. /**
  16809. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16810. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16811. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16812. * @returns the emitter
  16813. */
  16814. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16815. /**
  16816. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16817. * @param radius The radius of the hemisphere to emit from
  16818. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16819. * @returns the emitter
  16820. */
  16821. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16822. /**
  16823. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16824. * @param radius The radius of the sphere to emit from
  16825. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16826. * @returns the emitter
  16827. */
  16828. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16829. /**
  16830. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16831. * @param radius The radius of the sphere to emit from
  16832. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16833. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16834. * @returns the emitter
  16835. */
  16836. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16837. /**
  16838. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16839. * @param radius The radius of the emission cylinder
  16840. * @param height The height of the emission cylinder
  16841. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16842. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16843. * @returns the emitter
  16844. */
  16845. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16846. /**
  16847. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16848. * @param radius The radius of the cylinder to emit from
  16849. * @param height The height of the emission cylinder
  16850. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16851. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16852. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16853. * @returns the emitter
  16854. */
  16855. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16856. /**
  16857. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16858. * @param radius The radius of the cone to emit from
  16859. * @param angle The base angle of the cone
  16860. * @returns the emitter
  16861. */
  16862. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16863. /**
  16864. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16865. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16866. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16867. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16868. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16869. * @returns the emitter
  16870. */
  16871. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16872. /**
  16873. * Get hosting scene
  16874. * @returns the scene
  16875. */
  16876. getScene(): Scene;
  16877. }
  16878. }
  16879. declare module "babylonjs/Shaders/line.fragment" {
  16880. /** @hidden */
  16881. export var linePixelShader: {
  16882. name: string;
  16883. shader: string;
  16884. };
  16885. }
  16886. declare module "babylonjs/Shaders/line.vertex" {
  16887. /** @hidden */
  16888. export var lineVertexShader: {
  16889. name: string;
  16890. shader: string;
  16891. };
  16892. }
  16893. declare module "babylonjs/Rendering/edgesRenderer" {
  16894. import { Nullable } from "babylonjs/types";
  16895. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16897. import { Vector3 } from "babylonjs/Maths/math";
  16898. import { IDisposable } from "babylonjs/scene";
  16899. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16900. import "babylonjs/Shaders/line.fragment";
  16901. import "babylonjs/Shaders/line.vertex";
  16902. module "babylonjs/Meshes/abstractMesh" {
  16903. interface AbstractMesh {
  16904. /**
  16905. * Disables the mesh edge rendering mode
  16906. * @returns the currentAbstractMesh
  16907. */
  16908. disableEdgesRendering(): AbstractMesh;
  16909. /**
  16910. * Enables the edge rendering mode on the mesh.
  16911. * This mode makes the mesh edges visible
  16912. * @param epsilon defines the maximal distance between two angles to detect a face
  16913. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16914. * @returns the currentAbstractMesh
  16915. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16916. */
  16917. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16918. /**
  16919. * Gets the edgesRenderer associated with the mesh
  16920. */
  16921. edgesRenderer: Nullable<EdgesRenderer>;
  16922. }
  16923. }
  16924. module "babylonjs/Meshes/linesMesh" {
  16925. interface LinesMesh {
  16926. /**
  16927. * Enables the edge rendering mode on the mesh.
  16928. * This mode makes the mesh edges visible
  16929. * @param epsilon defines the maximal distance between two angles to detect a face
  16930. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16931. * @returns the currentAbstractMesh
  16932. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16933. */
  16934. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16935. }
  16936. }
  16937. module "babylonjs/Meshes/linesMesh" {
  16938. interface InstancedLinesMesh {
  16939. /**
  16940. * Enables the edge rendering mode on the mesh.
  16941. * This mode makes the mesh edges visible
  16942. * @param epsilon defines the maximal distance between two angles to detect a face
  16943. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16944. * @returns the current InstancedLinesMesh
  16945. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16946. */
  16947. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16948. }
  16949. }
  16950. /**
  16951. * Defines the minimum contract an Edges renderer should follow.
  16952. */
  16953. export interface IEdgesRenderer extends IDisposable {
  16954. /**
  16955. * Gets or sets a boolean indicating if the edgesRenderer is active
  16956. */
  16957. isEnabled: boolean;
  16958. /**
  16959. * Renders the edges of the attached mesh,
  16960. */
  16961. render(): void;
  16962. /**
  16963. * Checks wether or not the edges renderer is ready to render.
  16964. * @return true if ready, otherwise false.
  16965. */
  16966. isReady(): boolean;
  16967. }
  16968. /**
  16969. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16970. */
  16971. export class EdgesRenderer implements IEdgesRenderer {
  16972. /**
  16973. * Define the size of the edges with an orthographic camera
  16974. */
  16975. edgesWidthScalerForOrthographic: number;
  16976. /**
  16977. * Define the size of the edges with a perspective camera
  16978. */
  16979. edgesWidthScalerForPerspective: number;
  16980. protected _source: AbstractMesh;
  16981. protected _linesPositions: number[];
  16982. protected _linesNormals: number[];
  16983. protected _linesIndices: number[];
  16984. protected _epsilon: number;
  16985. protected _indicesCount: number;
  16986. protected _lineShader: ShaderMaterial;
  16987. protected _ib: WebGLBuffer;
  16988. protected _buffers: {
  16989. [key: string]: Nullable<VertexBuffer>;
  16990. };
  16991. protected _checkVerticesInsteadOfIndices: boolean;
  16992. private _meshRebuildObserver;
  16993. private _meshDisposeObserver;
  16994. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16995. isEnabled: boolean;
  16996. /**
  16997. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16998. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16999. * @param source Mesh used to create edges
  17000. * @param epsilon sum of angles in adjacency to check for edge
  17001. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17002. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17003. */
  17004. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17005. protected _prepareRessources(): void;
  17006. /** @hidden */
  17007. _rebuild(): void;
  17008. /**
  17009. * Releases the required resources for the edges renderer
  17010. */
  17011. dispose(): void;
  17012. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17013. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17014. /**
  17015. * Checks if the pair of p0 and p1 is en edge
  17016. * @param faceIndex
  17017. * @param edge
  17018. * @param faceNormals
  17019. * @param p0
  17020. * @param p1
  17021. * @private
  17022. */
  17023. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17024. /**
  17025. * push line into the position, normal and index buffer
  17026. * @protected
  17027. */
  17028. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17029. /**
  17030. * Generates lines edges from adjacencjes
  17031. * @private
  17032. */
  17033. _generateEdgesLines(): void;
  17034. /**
  17035. * Checks wether or not the edges renderer is ready to render.
  17036. * @return true if ready, otherwise false.
  17037. */
  17038. isReady(): boolean;
  17039. /**
  17040. * Renders the edges of the attached mesh,
  17041. */
  17042. render(): void;
  17043. }
  17044. /**
  17045. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17046. */
  17047. export class LineEdgesRenderer extends EdgesRenderer {
  17048. /**
  17049. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17050. * @param source LineMesh used to generate edges
  17051. * @param epsilon not important (specified angle for edge detection)
  17052. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17053. */
  17054. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17055. /**
  17056. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17057. */
  17058. _generateEdgesLines(): void;
  17059. }
  17060. }
  17061. declare module "babylonjs/Rendering/renderingGroup" {
  17062. import { SmartArray } from "babylonjs/Misc/smartArray";
  17063. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17065. import { Nullable } from "babylonjs/types";
  17066. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17067. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17068. import { Material } from "babylonjs/Materials/material";
  17069. import { Scene } from "babylonjs/scene";
  17070. /**
  17071. * This represents the object necessary to create a rendering group.
  17072. * This is exclusively used and created by the rendering manager.
  17073. * To modify the behavior, you use the available helpers in your scene or meshes.
  17074. * @hidden
  17075. */
  17076. export class RenderingGroup {
  17077. index: number;
  17078. private _scene;
  17079. private _opaqueSubMeshes;
  17080. private _transparentSubMeshes;
  17081. private _alphaTestSubMeshes;
  17082. private _depthOnlySubMeshes;
  17083. private _particleSystems;
  17084. private _spriteManagers;
  17085. private _opaqueSortCompareFn;
  17086. private _alphaTestSortCompareFn;
  17087. private _transparentSortCompareFn;
  17088. private _renderOpaque;
  17089. private _renderAlphaTest;
  17090. private _renderTransparent;
  17091. private _edgesRenderers;
  17092. onBeforeTransparentRendering: () => void;
  17093. /**
  17094. * Set the opaque sort comparison function.
  17095. * If null the sub meshes will be render in the order they were created
  17096. */
  17097. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17098. /**
  17099. * Set the alpha test sort comparison function.
  17100. * If null the sub meshes will be render in the order they were created
  17101. */
  17102. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17103. /**
  17104. * Set the transparent sort comparison function.
  17105. * If null the sub meshes will be render in the order they were created
  17106. */
  17107. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17108. /**
  17109. * Creates a new rendering group.
  17110. * @param index The rendering group index
  17111. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17112. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17113. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17114. */
  17115. 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>);
  17116. /**
  17117. * Render all the sub meshes contained in the group.
  17118. * @param customRenderFunction Used to override the default render behaviour of the group.
  17119. * @returns true if rendered some submeshes.
  17120. */
  17121. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17122. /**
  17123. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17124. * @param subMeshes The submeshes to render
  17125. */
  17126. private renderOpaqueSorted;
  17127. /**
  17128. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17129. * @param subMeshes The submeshes to render
  17130. */
  17131. private renderAlphaTestSorted;
  17132. /**
  17133. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17134. * @param subMeshes The submeshes to render
  17135. */
  17136. private renderTransparentSorted;
  17137. /**
  17138. * Renders the submeshes in a specified order.
  17139. * @param subMeshes The submeshes to sort before render
  17140. * @param sortCompareFn The comparison function use to sort
  17141. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17142. * @param transparent Specifies to activate blending if true
  17143. */
  17144. private static renderSorted;
  17145. /**
  17146. * Renders the submeshes in the order they were dispatched (no sort applied).
  17147. * @param subMeshes The submeshes to render
  17148. */
  17149. private static renderUnsorted;
  17150. /**
  17151. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17152. * are rendered back to front if in the same alpha index.
  17153. *
  17154. * @param a The first submesh
  17155. * @param b The second submesh
  17156. * @returns The result of the comparison
  17157. */
  17158. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17159. /**
  17160. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17161. * are rendered back to front.
  17162. *
  17163. * @param a The first submesh
  17164. * @param b The second submesh
  17165. * @returns The result of the comparison
  17166. */
  17167. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17168. /**
  17169. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17170. * are rendered front to back (prevent overdraw).
  17171. *
  17172. * @param a The first submesh
  17173. * @param b The second submesh
  17174. * @returns The result of the comparison
  17175. */
  17176. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17177. /**
  17178. * Resets the different lists of submeshes to prepare a new frame.
  17179. */
  17180. prepare(): void;
  17181. dispose(): void;
  17182. /**
  17183. * Inserts the submesh in its correct queue depending on its material.
  17184. * @param subMesh The submesh to dispatch
  17185. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17186. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17187. */
  17188. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17189. dispatchSprites(spriteManager: ISpriteManager): void;
  17190. dispatchParticles(particleSystem: IParticleSystem): void;
  17191. private _renderParticles;
  17192. private _renderSprites;
  17193. }
  17194. }
  17195. declare module "babylonjs/Rendering/renderingManager" {
  17196. import { Nullable } from "babylonjs/types";
  17197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17198. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17199. import { SmartArray } from "babylonjs/Misc/smartArray";
  17200. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17201. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17202. import { Material } from "babylonjs/Materials/material";
  17203. import { Scene } from "babylonjs/scene";
  17204. import { Camera } from "babylonjs/Cameras/camera";
  17205. /**
  17206. * Interface describing the different options available in the rendering manager
  17207. * regarding Auto Clear between groups.
  17208. */
  17209. export interface IRenderingManagerAutoClearSetup {
  17210. /**
  17211. * Defines whether or not autoclear is enable.
  17212. */
  17213. autoClear: boolean;
  17214. /**
  17215. * Defines whether or not to autoclear the depth buffer.
  17216. */
  17217. depth: boolean;
  17218. /**
  17219. * Defines whether or not to autoclear the stencil buffer.
  17220. */
  17221. stencil: boolean;
  17222. }
  17223. /**
  17224. * This class is used by the onRenderingGroupObservable
  17225. */
  17226. export class RenderingGroupInfo {
  17227. /**
  17228. * The Scene that being rendered
  17229. */
  17230. scene: Scene;
  17231. /**
  17232. * The camera currently used for the rendering pass
  17233. */
  17234. camera: Nullable<Camera>;
  17235. /**
  17236. * The ID of the renderingGroup being processed
  17237. */
  17238. renderingGroupId: number;
  17239. }
  17240. /**
  17241. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17242. * It is enable to manage the different groups as well as the different necessary sort functions.
  17243. * This should not be used directly aside of the few static configurations
  17244. */
  17245. export class RenderingManager {
  17246. /**
  17247. * The max id used for rendering groups (not included)
  17248. */
  17249. static MAX_RENDERINGGROUPS: number;
  17250. /**
  17251. * The min id used for rendering groups (included)
  17252. */
  17253. static MIN_RENDERINGGROUPS: number;
  17254. /**
  17255. * Used to globally prevent autoclearing scenes.
  17256. */
  17257. static AUTOCLEAR: boolean;
  17258. /**
  17259. * @hidden
  17260. */
  17261. _useSceneAutoClearSetup: boolean;
  17262. private _scene;
  17263. private _renderingGroups;
  17264. private _depthStencilBufferAlreadyCleaned;
  17265. private _autoClearDepthStencil;
  17266. private _customOpaqueSortCompareFn;
  17267. private _customAlphaTestSortCompareFn;
  17268. private _customTransparentSortCompareFn;
  17269. private _renderingGroupInfo;
  17270. /**
  17271. * Instantiates a new rendering group for a particular scene
  17272. * @param scene Defines the scene the groups belongs to
  17273. */
  17274. constructor(scene: Scene);
  17275. private _clearDepthStencilBuffer;
  17276. /**
  17277. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17278. * @hidden
  17279. */
  17280. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17281. /**
  17282. * Resets the different information of the group to prepare a new frame
  17283. * @hidden
  17284. */
  17285. reset(): void;
  17286. /**
  17287. * Dispose and release the group and its associated resources.
  17288. * @hidden
  17289. */
  17290. dispose(): void;
  17291. /**
  17292. * Clear the info related to rendering groups preventing retention points during dispose.
  17293. */
  17294. freeRenderingGroups(): void;
  17295. private _prepareRenderingGroup;
  17296. /**
  17297. * Add a sprite manager to the rendering manager in order to render it this frame.
  17298. * @param spriteManager Define the sprite manager to render
  17299. */
  17300. dispatchSprites(spriteManager: ISpriteManager): void;
  17301. /**
  17302. * Add a particle system to the rendering manager in order to render it this frame.
  17303. * @param particleSystem Define the particle system to render
  17304. */
  17305. dispatchParticles(particleSystem: IParticleSystem): void;
  17306. /**
  17307. * Add a submesh to the manager in order to render it this frame
  17308. * @param subMesh The submesh to dispatch
  17309. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17310. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17311. */
  17312. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17313. /**
  17314. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17315. * This allowed control for front to back rendering or reversly depending of the special needs.
  17316. *
  17317. * @param renderingGroupId The rendering group id corresponding to its index
  17318. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17319. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17320. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17321. */
  17322. 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;
  17323. /**
  17324. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17325. *
  17326. * @param renderingGroupId The rendering group id corresponding to its index
  17327. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17328. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17329. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17330. */
  17331. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17332. /**
  17333. * Gets the current auto clear configuration for one rendering group of the rendering
  17334. * manager.
  17335. * @param index the rendering group index to get the information for
  17336. * @returns The auto clear setup for the requested rendering group
  17337. */
  17338. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17339. }
  17340. }
  17341. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17342. import { Observable } from "babylonjs/Misc/observable";
  17343. import { SmartArray } from "babylonjs/Misc/smartArray";
  17344. import { Nullable } from "babylonjs/types";
  17345. import { Camera } from "babylonjs/Cameras/camera";
  17346. import { Scene } from "babylonjs/scene";
  17347. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17348. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17350. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17351. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17352. import { Texture } from "babylonjs/Materials/Textures/texture";
  17353. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17354. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17355. import { Engine } from "babylonjs/Engines/engine";
  17356. /**
  17357. * This Helps creating a texture that will be created from a camera in your scene.
  17358. * It is basically a dynamic texture that could be used to create special effects for instance.
  17359. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17360. */
  17361. export class RenderTargetTexture extends Texture {
  17362. isCube: boolean;
  17363. /**
  17364. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17365. */
  17366. static readonly REFRESHRATE_RENDER_ONCE: number;
  17367. /**
  17368. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17369. */
  17370. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17371. /**
  17372. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17373. * the central point of your effect and can save a lot of performances.
  17374. */
  17375. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17376. /**
  17377. * Use this predicate to dynamically define the list of mesh you want to render.
  17378. * If set, the renderList property will be overwritten.
  17379. */
  17380. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17381. private _renderList;
  17382. /**
  17383. * Use this list to define the list of mesh you want to render.
  17384. */
  17385. renderList: Nullable<Array<AbstractMesh>>;
  17386. private _hookArray;
  17387. /**
  17388. * Define if particles should be rendered in your texture.
  17389. */
  17390. renderParticles: boolean;
  17391. /**
  17392. * Define if sprites should be rendered in your texture.
  17393. */
  17394. renderSprites: boolean;
  17395. /**
  17396. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17397. */
  17398. coordinatesMode: number;
  17399. /**
  17400. * Define the camera used to render the texture.
  17401. */
  17402. activeCamera: Nullable<Camera>;
  17403. /**
  17404. * Override the render function of the texture with your own one.
  17405. */
  17406. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17407. /**
  17408. * Define if camera post processes should be use while rendering the texture.
  17409. */
  17410. useCameraPostProcesses: boolean;
  17411. /**
  17412. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17413. */
  17414. ignoreCameraViewport: boolean;
  17415. private _postProcessManager;
  17416. private _postProcesses;
  17417. private _resizeObserver;
  17418. /**
  17419. * An event triggered when the texture is unbind.
  17420. */
  17421. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17422. /**
  17423. * An event triggered when the texture is unbind.
  17424. */
  17425. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17426. private _onAfterUnbindObserver;
  17427. /**
  17428. * Set a after unbind callback in the texture.
  17429. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17430. */
  17431. onAfterUnbind: () => void;
  17432. /**
  17433. * An event triggered before rendering the texture
  17434. */
  17435. onBeforeRenderObservable: Observable<number>;
  17436. private _onBeforeRenderObserver;
  17437. /**
  17438. * Set a before render callback in the texture.
  17439. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17440. */
  17441. onBeforeRender: (faceIndex: number) => void;
  17442. /**
  17443. * An event triggered after rendering the texture
  17444. */
  17445. onAfterRenderObservable: Observable<number>;
  17446. private _onAfterRenderObserver;
  17447. /**
  17448. * Set a after render callback in the texture.
  17449. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17450. */
  17451. onAfterRender: (faceIndex: number) => void;
  17452. /**
  17453. * An event triggered after the texture clear
  17454. */
  17455. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17456. private _onClearObserver;
  17457. /**
  17458. * Set a clear callback in the texture.
  17459. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17460. */
  17461. onClear: (Engine: Engine) => void;
  17462. /**
  17463. * Define the clear color of the Render Target if it should be different from the scene.
  17464. */
  17465. clearColor: Color4;
  17466. protected _size: number | {
  17467. width: number;
  17468. height: number;
  17469. };
  17470. protected _initialSizeParameter: number | {
  17471. width: number;
  17472. height: number;
  17473. } | {
  17474. ratio: number;
  17475. };
  17476. protected _sizeRatio: Nullable<number>;
  17477. /** @hidden */
  17478. _generateMipMaps: boolean;
  17479. protected _renderingManager: RenderingManager;
  17480. /** @hidden */
  17481. _waitingRenderList: string[];
  17482. protected _doNotChangeAspectRatio: boolean;
  17483. protected _currentRefreshId: number;
  17484. protected _refreshRate: number;
  17485. protected _textureMatrix: Matrix;
  17486. protected _samples: number;
  17487. protected _renderTargetOptions: RenderTargetCreationOptions;
  17488. /**
  17489. * Gets render target creation options that were used.
  17490. */
  17491. readonly renderTargetOptions: RenderTargetCreationOptions;
  17492. protected _engine: Engine;
  17493. protected _onRatioRescale(): void;
  17494. /**
  17495. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17496. * It must define where the camera used to render the texture is set
  17497. */
  17498. boundingBoxPosition: Vector3;
  17499. private _boundingBoxSize;
  17500. /**
  17501. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17502. * When defined, the cubemap will switch to local mode
  17503. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17504. * @example https://www.babylonjs-playground.com/#RNASML
  17505. */
  17506. boundingBoxSize: Vector3;
  17507. /**
  17508. * In case the RTT has been created with a depth texture, get the associated
  17509. * depth texture.
  17510. * Otherwise, return null.
  17511. */
  17512. depthStencilTexture: Nullable<InternalTexture>;
  17513. /**
  17514. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17515. * or used a shadow, depth texture...
  17516. * @param name The friendly name of the texture
  17517. * @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)
  17518. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17519. * @param generateMipMaps True if mip maps need to be generated after render.
  17520. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17521. * @param type The type of the buffer in the RTT (int, half float, float...)
  17522. * @param isCube True if a cube texture needs to be created
  17523. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17524. * @param generateDepthBuffer True to generate a depth buffer
  17525. * @param generateStencilBuffer True to generate a stencil buffer
  17526. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17527. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17528. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17529. */
  17530. constructor(name: string, size: number | {
  17531. width: number;
  17532. height: number;
  17533. } | {
  17534. ratio: number;
  17535. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17536. /**
  17537. * Creates a depth stencil texture.
  17538. * This is only available in WebGL 2 or with the depth texture extension available.
  17539. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17540. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17541. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17542. */
  17543. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17544. private _processSizeParameter;
  17545. /**
  17546. * Define the number of samples to use in case of MSAA.
  17547. * It defaults to one meaning no MSAA has been enabled.
  17548. */
  17549. samples: number;
  17550. /**
  17551. * Resets the refresh counter of the texture and start bak from scratch.
  17552. * Could be useful to regenerate the texture if it is setup to render only once.
  17553. */
  17554. resetRefreshCounter(): void;
  17555. /**
  17556. * Define the refresh rate of the texture or the rendering frequency.
  17557. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17558. */
  17559. refreshRate: number;
  17560. /**
  17561. * Adds a post process to the render target rendering passes.
  17562. * @param postProcess define the post process to add
  17563. */
  17564. addPostProcess(postProcess: PostProcess): void;
  17565. /**
  17566. * Clear all the post processes attached to the render target
  17567. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17568. */
  17569. clearPostProcesses(dispose?: boolean): void;
  17570. /**
  17571. * Remove one of the post process from the list of attached post processes to the texture
  17572. * @param postProcess define the post process to remove from the list
  17573. */
  17574. removePostProcess(postProcess: PostProcess): void;
  17575. /** @hidden */
  17576. _shouldRender(): boolean;
  17577. /**
  17578. * Gets the actual render size of the texture.
  17579. * @returns the width of the render size
  17580. */
  17581. getRenderSize(): number;
  17582. /**
  17583. * Gets the actual render width of the texture.
  17584. * @returns the width of the render size
  17585. */
  17586. getRenderWidth(): number;
  17587. /**
  17588. * Gets the actual render height of the texture.
  17589. * @returns the height of the render size
  17590. */
  17591. getRenderHeight(): number;
  17592. /**
  17593. * Get if the texture can be rescaled or not.
  17594. */
  17595. readonly canRescale: boolean;
  17596. /**
  17597. * Resize the texture using a ratio.
  17598. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17599. */
  17600. scale(ratio: number): void;
  17601. /**
  17602. * Get the texture reflection matrix used to rotate/transform the reflection.
  17603. * @returns the reflection matrix
  17604. */
  17605. getReflectionTextureMatrix(): Matrix;
  17606. /**
  17607. * Resize the texture to a new desired size.
  17608. * Be carrefull as it will recreate all the data in the new texture.
  17609. * @param size Define the new size. It can be:
  17610. * - a number for squared texture,
  17611. * - an object containing { width: number, height: number }
  17612. * - or an object containing a ratio { ratio: number }
  17613. */
  17614. resize(size: number | {
  17615. width: number;
  17616. height: number;
  17617. } | {
  17618. ratio: number;
  17619. }): void;
  17620. /**
  17621. * Renders all the objects from the render list into the texture.
  17622. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17623. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17624. */
  17625. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17626. private _bestReflectionRenderTargetDimension;
  17627. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17628. private renderToTarget;
  17629. /**
  17630. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17631. * This allowed control for front to back rendering or reversly depending of the special needs.
  17632. *
  17633. * @param renderingGroupId The rendering group id corresponding to its index
  17634. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17635. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17636. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17637. */
  17638. 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;
  17639. /**
  17640. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17641. *
  17642. * @param renderingGroupId The rendering group id corresponding to its index
  17643. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17644. */
  17645. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17646. /**
  17647. * Clones the texture.
  17648. * @returns the cloned texture
  17649. */
  17650. clone(): RenderTargetTexture;
  17651. /**
  17652. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17653. * @returns The JSON representation of the texture
  17654. */
  17655. serialize(): any;
  17656. /**
  17657. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17658. */
  17659. disposeFramebufferObjects(): void;
  17660. /**
  17661. * Dispose the texture and release its associated resources.
  17662. */
  17663. dispose(): void;
  17664. /** @hidden */
  17665. _rebuild(): void;
  17666. /**
  17667. * Clear the info related to rendering groups preventing retention point in material dispose.
  17668. */
  17669. freeRenderingGroups(): void;
  17670. }
  17671. }
  17672. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  17673. import { Scene } from "babylonjs/scene";
  17674. import { Plane } from "babylonjs/Maths/math";
  17675. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17676. /**
  17677. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17678. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17679. * You can then easily use it as a reflectionTexture on a flat surface.
  17680. * In case the surface is not a plane, please consider relying on reflection probes.
  17681. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17682. */
  17683. export class MirrorTexture extends RenderTargetTexture {
  17684. private scene;
  17685. /**
  17686. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17687. * 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.
  17688. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17689. */
  17690. mirrorPlane: Plane;
  17691. /**
  17692. * Define the blur ratio used to blur the reflection if needed.
  17693. */
  17694. blurRatio: number;
  17695. /**
  17696. * Define the adaptive blur kernel used to blur the reflection if needed.
  17697. * This will autocompute the closest best match for the `blurKernel`
  17698. */
  17699. adaptiveBlurKernel: number;
  17700. /**
  17701. * Define the blur kernel used to blur the reflection if needed.
  17702. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17703. */
  17704. blurKernel: number;
  17705. /**
  17706. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17707. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17708. */
  17709. blurKernelX: number;
  17710. /**
  17711. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17712. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17713. */
  17714. blurKernelY: number;
  17715. private _autoComputeBlurKernel;
  17716. protected _onRatioRescale(): void;
  17717. private _updateGammaSpace;
  17718. private _imageProcessingConfigChangeObserver;
  17719. private _transformMatrix;
  17720. private _mirrorMatrix;
  17721. private _savedViewMatrix;
  17722. private _blurX;
  17723. private _blurY;
  17724. private _adaptiveBlurKernel;
  17725. private _blurKernelX;
  17726. private _blurKernelY;
  17727. private _blurRatio;
  17728. /**
  17729. * Instantiates a Mirror Texture.
  17730. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17731. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17732. * You can then easily use it as a reflectionTexture on a flat surface.
  17733. * In case the surface is not a plane, please consider relying on reflection probes.
  17734. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17735. * @param name
  17736. * @param size
  17737. * @param scene
  17738. * @param generateMipMaps
  17739. * @param type
  17740. * @param samplingMode
  17741. * @param generateDepthBuffer
  17742. */
  17743. constructor(name: string, size: number | {
  17744. width: number;
  17745. height: number;
  17746. } | {
  17747. ratio: number;
  17748. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17749. private _preparePostProcesses;
  17750. /**
  17751. * Clone the mirror texture.
  17752. * @returns the cloned texture
  17753. */
  17754. clone(): MirrorTexture;
  17755. /**
  17756. * Serialize the texture to a JSON representation you could use in Parse later on
  17757. * @returns the serialized JSON representation
  17758. */
  17759. serialize(): any;
  17760. /**
  17761. * Dispose the texture and release its associated resources.
  17762. */
  17763. dispose(): void;
  17764. }
  17765. }
  17766. declare module "babylonjs/Materials/Textures/texture" {
  17767. import { Observable } from "babylonjs/Misc/observable";
  17768. import { Nullable } from "babylonjs/types";
  17769. import { Scene } from "babylonjs/scene";
  17770. import { Matrix } from "babylonjs/Maths/math";
  17771. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17772. /**
  17773. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17774. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17775. */
  17776. export class Texture extends BaseTexture {
  17777. /** @hidden */
  17778. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  17779. /** @hidden */
  17780. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  17781. /** @hidden */
  17782. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  17783. /** nearest is mag = nearest and min = nearest and mip = linear */
  17784. static readonly NEAREST_SAMPLINGMODE: number;
  17785. /** nearest is mag = nearest and min = nearest and mip = linear */
  17786. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17787. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17788. static readonly BILINEAR_SAMPLINGMODE: number;
  17789. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17790. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17791. /** Trilinear is mag = linear and min = linear and mip = linear */
  17792. static readonly TRILINEAR_SAMPLINGMODE: number;
  17793. /** Trilinear is mag = linear and min = linear and mip = linear */
  17794. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17795. /** mag = nearest and min = nearest and mip = nearest */
  17796. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17797. /** mag = nearest and min = linear and mip = nearest */
  17798. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17799. /** mag = nearest and min = linear and mip = linear */
  17800. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17801. /** mag = nearest and min = linear and mip = none */
  17802. static readonly NEAREST_LINEAR: number;
  17803. /** mag = nearest and min = nearest and mip = none */
  17804. static readonly NEAREST_NEAREST: number;
  17805. /** mag = linear and min = nearest and mip = nearest */
  17806. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17807. /** mag = linear and min = nearest and mip = linear */
  17808. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17809. /** mag = linear and min = linear and mip = none */
  17810. static readonly LINEAR_LINEAR: number;
  17811. /** mag = linear and min = nearest and mip = none */
  17812. static readonly LINEAR_NEAREST: number;
  17813. /** Explicit coordinates mode */
  17814. static readonly EXPLICIT_MODE: number;
  17815. /** Spherical coordinates mode */
  17816. static readonly SPHERICAL_MODE: number;
  17817. /** Planar coordinates mode */
  17818. static readonly PLANAR_MODE: number;
  17819. /** Cubic coordinates mode */
  17820. static readonly CUBIC_MODE: number;
  17821. /** Projection coordinates mode */
  17822. static readonly PROJECTION_MODE: number;
  17823. /** Inverse Cubic coordinates mode */
  17824. static readonly SKYBOX_MODE: number;
  17825. /** Inverse Cubic coordinates mode */
  17826. static readonly INVCUBIC_MODE: number;
  17827. /** Equirectangular coordinates mode */
  17828. static readonly EQUIRECTANGULAR_MODE: number;
  17829. /** Equirectangular Fixed coordinates mode */
  17830. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17831. /** Equirectangular Fixed Mirrored coordinates mode */
  17832. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17833. /** Texture is not repeating outside of 0..1 UVs */
  17834. static readonly CLAMP_ADDRESSMODE: number;
  17835. /** Texture is repeating outside of 0..1 UVs */
  17836. static readonly WRAP_ADDRESSMODE: number;
  17837. /** Texture is repeating and mirrored */
  17838. static readonly MIRROR_ADDRESSMODE: number;
  17839. /**
  17840. * 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
  17841. */
  17842. static UseSerializedUrlIfAny: boolean;
  17843. /**
  17844. * Define the url of the texture.
  17845. */
  17846. url: Nullable<string>;
  17847. /**
  17848. * Define an offset on the texture to offset the u coordinates of the UVs
  17849. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17850. */
  17851. uOffset: number;
  17852. /**
  17853. * Define an offset on the texture to offset the v coordinates of the UVs
  17854. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17855. */
  17856. vOffset: number;
  17857. /**
  17858. * Define an offset on the texture to scale the u coordinates of the UVs
  17859. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17860. */
  17861. uScale: number;
  17862. /**
  17863. * Define an offset on the texture to scale the v coordinates of the UVs
  17864. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17865. */
  17866. vScale: number;
  17867. /**
  17868. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17869. * @see http://doc.babylonjs.com/how_to/more_materials
  17870. */
  17871. uAng: number;
  17872. /**
  17873. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17874. * @see http://doc.babylonjs.com/how_to/more_materials
  17875. */
  17876. vAng: number;
  17877. /**
  17878. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17879. * @see http://doc.babylonjs.com/how_to/more_materials
  17880. */
  17881. wAng: number;
  17882. /**
  17883. * Defines the center of rotation (U)
  17884. */
  17885. uRotationCenter: number;
  17886. /**
  17887. * Defines the center of rotation (V)
  17888. */
  17889. vRotationCenter: number;
  17890. /**
  17891. * Defines the center of rotation (W)
  17892. */
  17893. wRotationCenter: number;
  17894. /**
  17895. * Are mip maps generated for this texture or not.
  17896. */
  17897. readonly noMipmap: boolean;
  17898. private _noMipmap;
  17899. /** @hidden */
  17900. _invertY: boolean;
  17901. private _rowGenerationMatrix;
  17902. private _cachedTextureMatrix;
  17903. private _projectionModeMatrix;
  17904. private _t0;
  17905. private _t1;
  17906. private _t2;
  17907. private _cachedUOffset;
  17908. private _cachedVOffset;
  17909. private _cachedUScale;
  17910. private _cachedVScale;
  17911. private _cachedUAng;
  17912. private _cachedVAng;
  17913. private _cachedWAng;
  17914. private _cachedProjectionMatrixId;
  17915. private _cachedCoordinatesMode;
  17916. /** @hidden */
  17917. protected _initialSamplingMode: number;
  17918. /** @hidden */
  17919. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  17920. private _deleteBuffer;
  17921. protected _format: Nullable<number>;
  17922. private _delayedOnLoad;
  17923. private _delayedOnError;
  17924. /**
  17925. * Observable triggered once the texture has been loaded.
  17926. */
  17927. onLoadObservable: Observable<Texture>;
  17928. protected _isBlocking: boolean;
  17929. /**
  17930. * Is the texture preventing material to render while loading.
  17931. * If false, a default texture will be used instead of the loading one during the preparation step.
  17932. */
  17933. isBlocking: boolean;
  17934. /**
  17935. * Get the current sampling mode associated with the texture.
  17936. */
  17937. readonly samplingMode: number;
  17938. /**
  17939. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  17940. */
  17941. readonly invertY: boolean;
  17942. /**
  17943. * Instantiates a new texture.
  17944. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17945. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17946. * @param url define the url of the picture to load as a texture
  17947. * @param scene define the scene the texture will belong to
  17948. * @param noMipmap define if the texture will require mip maps or not
  17949. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17950. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17951. * @param onLoad define a callback triggered when the texture has been loaded
  17952. * @param onError define a callback triggered when an error occurred during the loading session
  17953. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17954. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17955. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17956. */
  17957. 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);
  17958. /**
  17959. * Update the url (and optional buffer) of this texture if url was null during construction.
  17960. * @param url the url of the texture
  17961. * @param buffer the buffer of the texture (defaults to null)
  17962. * @param onLoad callback called when the texture is loaded (defaults to null)
  17963. */
  17964. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  17965. /**
  17966. * Finish the loading sequence of a texture flagged as delayed load.
  17967. * @hidden
  17968. */
  17969. delayLoad(): void;
  17970. private _prepareRowForTextureGeneration;
  17971. /**
  17972. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  17973. * @returns the transform matrix of the texture.
  17974. */
  17975. getTextureMatrix(): Matrix;
  17976. /**
  17977. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  17978. * @returns The reflection texture transform
  17979. */
  17980. getReflectionTextureMatrix(): Matrix;
  17981. /**
  17982. * Clones the texture.
  17983. * @returns the cloned texture
  17984. */
  17985. clone(): Texture;
  17986. /**
  17987. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17988. * @returns The JSON representation of the texture
  17989. */
  17990. serialize(): any;
  17991. /**
  17992. * Get the current class name of the texture useful for serialization or dynamic coding.
  17993. * @returns "Texture"
  17994. */
  17995. getClassName(): string;
  17996. /**
  17997. * Dispose the texture and release its associated resources.
  17998. */
  17999. dispose(): void;
  18000. /**
  18001. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18002. * @param parsedTexture Define the JSON representation of the texture
  18003. * @param scene Define the scene the parsed texture should be instantiated in
  18004. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18005. * @returns The parsed texture if successful
  18006. */
  18007. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18008. /**
  18009. * Creates a texture from its base 64 representation.
  18010. * @param data Define the base64 payload without the data: prefix
  18011. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18012. * @param scene Define the scene the texture should belong to
  18013. * @param noMipmap Forces the texture to not create mip map information if true
  18014. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18015. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18016. * @param onLoad define a callback triggered when the texture has been loaded
  18017. * @param onError define a callback triggered when an error occurred during the loading session
  18018. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18019. * @returns the created texture
  18020. */
  18021. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18022. /**
  18023. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18024. * @param data Define the base64 payload without the data: prefix
  18025. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18026. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18027. * @param scene Define the scene the texture should belong to
  18028. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18029. * @param noMipmap Forces the texture to not create mip map information if true
  18030. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18031. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18032. * @param onLoad define a callback triggered when the texture has been loaded
  18033. * @param onError define a callback triggered when an error occurred during the loading session
  18034. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18035. * @returns the created texture
  18036. */
  18037. 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;
  18038. }
  18039. }
  18040. declare module "babylonjs/Materials/shaderMaterial" {
  18041. import { Scene } from "babylonjs/scene";
  18042. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  18043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18044. import { Mesh } from "babylonjs/Meshes/mesh";
  18045. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18046. import { Texture } from "babylonjs/Materials/Textures/texture";
  18047. import { Material } from "babylonjs/Materials/material";
  18048. /**
  18049. * Defines the options associated with the creation of a shader material.
  18050. */
  18051. export interface IShaderMaterialOptions {
  18052. /**
  18053. * Does the material work in alpha blend mode
  18054. */
  18055. needAlphaBlending: boolean;
  18056. /**
  18057. * Does the material work in alpha test mode
  18058. */
  18059. needAlphaTesting: boolean;
  18060. /**
  18061. * The list of attribute names used in the shader
  18062. */
  18063. attributes: string[];
  18064. /**
  18065. * The list of unifrom names used in the shader
  18066. */
  18067. uniforms: string[];
  18068. /**
  18069. * The list of UBO names used in the shader
  18070. */
  18071. uniformBuffers: string[];
  18072. /**
  18073. * The list of sampler names used in the shader
  18074. */
  18075. samplers: string[];
  18076. /**
  18077. * The list of defines used in the shader
  18078. */
  18079. defines: string[];
  18080. }
  18081. /**
  18082. * 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.
  18083. *
  18084. * This returned material effects how the mesh will look based on the code in the shaders.
  18085. *
  18086. * @see http://doc.babylonjs.com/how_to/shader_material
  18087. */
  18088. export class ShaderMaterial extends Material {
  18089. private _shaderPath;
  18090. private _options;
  18091. private _textures;
  18092. private _textureArrays;
  18093. private _floats;
  18094. private _ints;
  18095. private _floatsArrays;
  18096. private _colors3;
  18097. private _colors3Arrays;
  18098. private _colors4;
  18099. private _vectors2;
  18100. private _vectors3;
  18101. private _vectors4;
  18102. private _matrices;
  18103. private _matrices3x3;
  18104. private _matrices2x2;
  18105. private _vectors2Arrays;
  18106. private _vectors3Arrays;
  18107. private _cachedWorldViewMatrix;
  18108. private _renderId;
  18109. /**
  18110. * Instantiate a new shader material.
  18111. * 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.
  18112. * This returned material effects how the mesh will look based on the code in the shaders.
  18113. * @see http://doc.babylonjs.com/how_to/shader_material
  18114. * @param name Define the name of the material in the scene
  18115. * @param scene Define the scene the material belongs to
  18116. * @param shaderPath Defines the route to the shader code in one of three ways:
  18117. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18118. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18119. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18120. * @param options Define the options used to create the shader
  18121. */
  18122. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18123. /**
  18124. * Gets the current class name of the material e.g. "ShaderMaterial"
  18125. * Mainly use in serialization.
  18126. * @returns the class name
  18127. */
  18128. getClassName(): string;
  18129. /**
  18130. * Specifies if the material will require alpha blending
  18131. * @returns a boolean specifying if alpha blending is needed
  18132. */
  18133. needAlphaBlending(): boolean;
  18134. /**
  18135. * Specifies if this material should be rendered in alpha test mode
  18136. * @returns a boolean specifying if an alpha test is needed.
  18137. */
  18138. needAlphaTesting(): boolean;
  18139. private _checkUniform;
  18140. /**
  18141. * Set a texture in the shader.
  18142. * @param name Define the name of the uniform samplers as defined in the shader
  18143. * @param texture Define the texture to bind to this sampler
  18144. * @return the material itself allowing "fluent" like uniform updates
  18145. */
  18146. setTexture(name: string, texture: Texture): ShaderMaterial;
  18147. /**
  18148. * Set a texture array in the shader.
  18149. * @param name Define the name of the uniform sampler array as defined in the shader
  18150. * @param textures Define the list of textures to bind to this sampler
  18151. * @return the material itself allowing "fluent" like uniform updates
  18152. */
  18153. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18154. /**
  18155. * Set a float in the shader.
  18156. * @param name Define the name of the uniform as defined in the shader
  18157. * @param value Define the value to give to the uniform
  18158. * @return the material itself allowing "fluent" like uniform updates
  18159. */
  18160. setFloat(name: string, value: number): ShaderMaterial;
  18161. /**
  18162. * Set a int in the shader.
  18163. * @param name Define the name of the uniform as defined in the shader
  18164. * @param value Define the value to give to the uniform
  18165. * @return the material itself allowing "fluent" like uniform updates
  18166. */
  18167. setInt(name: string, value: number): ShaderMaterial;
  18168. /**
  18169. * Set an array of floats in the shader.
  18170. * @param name Define the name of the uniform as defined in the shader
  18171. * @param value Define the value to give to the uniform
  18172. * @return the material itself allowing "fluent" like uniform updates
  18173. */
  18174. setFloats(name: string, value: number[]): ShaderMaterial;
  18175. /**
  18176. * Set a vec3 in the shader from a Color3.
  18177. * @param name Define the name of the uniform as defined in the shader
  18178. * @param value Define the value to give to the uniform
  18179. * @return the material itself allowing "fluent" like uniform updates
  18180. */
  18181. setColor3(name: string, value: Color3): ShaderMaterial;
  18182. /**
  18183. * Set a vec3 array in the shader from a Color3 array.
  18184. * @param name Define the name of the uniform as defined in the shader
  18185. * @param value Define the value to give to the uniform
  18186. * @return the material itself allowing "fluent" like uniform updates
  18187. */
  18188. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18189. /**
  18190. * Set a vec4 in the shader from a Color4.
  18191. * @param name Define the name of the uniform as defined in the shader
  18192. * @param value Define the value to give to the uniform
  18193. * @return the material itself allowing "fluent" like uniform updates
  18194. */
  18195. setColor4(name: string, value: Color4): ShaderMaterial;
  18196. /**
  18197. * Set a vec2 in the shader from a Vector2.
  18198. * @param name Define the name of the uniform as defined in the shader
  18199. * @param value Define the value to give to the uniform
  18200. * @return the material itself allowing "fluent" like uniform updates
  18201. */
  18202. setVector2(name: string, value: Vector2): ShaderMaterial;
  18203. /**
  18204. * Set a vec3 in the shader from a Vector3.
  18205. * @param name Define the name of the uniform as defined in the shader
  18206. * @param value Define the value to give to the uniform
  18207. * @return the material itself allowing "fluent" like uniform updates
  18208. */
  18209. setVector3(name: string, value: Vector3): ShaderMaterial;
  18210. /**
  18211. * Set a vec4 in the shader from a Vector4.
  18212. * @param name Define the name of the uniform as defined in the shader
  18213. * @param value Define the value to give to the uniform
  18214. * @return the material itself allowing "fluent" like uniform updates
  18215. */
  18216. setVector4(name: string, value: Vector4): ShaderMaterial;
  18217. /**
  18218. * Set a mat4 in the shader from a Matrix.
  18219. * @param name Define the name of the uniform as defined in the shader
  18220. * @param value Define the value to give to the uniform
  18221. * @return the material itself allowing "fluent" like uniform updates
  18222. */
  18223. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18224. /**
  18225. * Set a mat3 in the shader from a Float32Array.
  18226. * @param name Define the name of the uniform as defined in the shader
  18227. * @param value Define the value to give to the uniform
  18228. * @return the material itself allowing "fluent" like uniform updates
  18229. */
  18230. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18231. /**
  18232. * Set a mat2 in the shader from a Float32Array.
  18233. * @param name Define the name of the uniform as defined in the shader
  18234. * @param value Define the value to give to the uniform
  18235. * @return the material itself allowing "fluent" like uniform updates
  18236. */
  18237. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18238. /**
  18239. * Set a vec2 array in the shader from a number array.
  18240. * @param name Define the name of the uniform as defined in the shader
  18241. * @param value Define the value to give to the uniform
  18242. * @return the material itself allowing "fluent" like uniform updates
  18243. */
  18244. setArray2(name: string, value: number[]): ShaderMaterial;
  18245. /**
  18246. * Set a vec3 array in the shader from a number array.
  18247. * @param name Define the name of the uniform as defined in the shader
  18248. * @param value Define the value to give to the uniform
  18249. * @return the material itself allowing "fluent" like uniform updates
  18250. */
  18251. setArray3(name: string, value: number[]): ShaderMaterial;
  18252. private _checkCache;
  18253. /**
  18254. * Checks if the material is ready to render the requested mesh
  18255. * @param mesh Define the mesh to render
  18256. * @param useInstances Define whether or not the material is used with instances
  18257. * @returns true if ready, otherwise false
  18258. */
  18259. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18260. /**
  18261. * Binds the world matrix to the material
  18262. * @param world defines the world transformation matrix
  18263. */
  18264. bindOnlyWorldMatrix(world: Matrix): void;
  18265. /**
  18266. * Binds the material to the mesh
  18267. * @param world defines the world transformation matrix
  18268. * @param mesh defines the mesh to bind the material to
  18269. */
  18270. bind(world: Matrix, mesh?: Mesh): void;
  18271. /**
  18272. * Gets the active textures from the material
  18273. * @returns an array of textures
  18274. */
  18275. getActiveTextures(): BaseTexture[];
  18276. /**
  18277. * Specifies if the material uses a texture
  18278. * @param texture defines the texture to check against the material
  18279. * @returns a boolean specifying if the material uses the texture
  18280. */
  18281. hasTexture(texture: BaseTexture): boolean;
  18282. /**
  18283. * Makes a duplicate of the material, and gives it a new name
  18284. * @param name defines the new name for the duplicated material
  18285. * @returns the cloned material
  18286. */
  18287. clone(name: string): ShaderMaterial;
  18288. /**
  18289. * Disposes the material
  18290. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18291. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18292. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18293. */
  18294. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18295. /**
  18296. * Serializes this material in a JSON representation
  18297. * @returns the serialized material object
  18298. */
  18299. serialize(): any;
  18300. /**
  18301. * Creates a shader material from parsed shader material data
  18302. * @param source defines the JSON represnetation of the material
  18303. * @param scene defines the hosting scene
  18304. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18305. * @returns a new material
  18306. */
  18307. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18308. }
  18309. }
  18310. declare module "babylonjs/Shaders/color.fragment" {
  18311. /** @hidden */
  18312. export var colorPixelShader: {
  18313. name: string;
  18314. shader: string;
  18315. };
  18316. }
  18317. declare module "babylonjs/Shaders/color.vertex" {
  18318. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  18319. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  18320. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  18321. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  18322. /** @hidden */
  18323. export var colorVertexShader: {
  18324. name: string;
  18325. shader: string;
  18326. };
  18327. }
  18328. declare module "babylonjs/Meshes/linesMesh" {
  18329. import { Nullable } from "babylonjs/types";
  18330. import { Scene } from "babylonjs/scene";
  18331. import { Color3 } from "babylonjs/Maths/math";
  18332. import { Node } from "babylonjs/node";
  18333. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18334. import { Mesh } from "babylonjs/Meshes/mesh";
  18335. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  18336. import { Effect } from "babylonjs/Materials/effect";
  18337. import { Material } from "babylonjs/Materials/material";
  18338. import "babylonjs/Shaders/color.fragment";
  18339. import "babylonjs/Shaders/color.vertex";
  18340. /**
  18341. * Line mesh
  18342. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  18343. */
  18344. export class LinesMesh extends Mesh {
  18345. /**
  18346. * If vertex color should be applied to the mesh
  18347. */
  18348. useVertexColor?: boolean | undefined;
  18349. /**
  18350. * If vertex alpha should be applied to the mesh
  18351. */
  18352. useVertexAlpha?: boolean | undefined;
  18353. /**
  18354. * Color of the line (Default: White)
  18355. */
  18356. color: Color3;
  18357. /**
  18358. * Alpha of the line (Default: 1)
  18359. */
  18360. alpha: number;
  18361. /**
  18362. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18363. * This margin is expressed in world space coordinates, so its value may vary.
  18364. * Default value is 0.1
  18365. */
  18366. intersectionThreshold: number;
  18367. private _colorShader;
  18368. /**
  18369. * Creates a new LinesMesh
  18370. * @param name defines the name
  18371. * @param scene defines the hosting scene
  18372. * @param parent defines the parent mesh if any
  18373. * @param source defines the optional source LinesMesh used to clone data from
  18374. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  18375. * When false, achieved by calling a clone(), also passing False.
  18376. * This will make creation of children, recursive.
  18377. * @param useVertexColor defines if this LinesMesh supports vertex color
  18378. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  18379. */
  18380. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  18381. /**
  18382. * If vertex color should be applied to the mesh
  18383. */
  18384. useVertexColor?: boolean | undefined,
  18385. /**
  18386. * If vertex alpha should be applied to the mesh
  18387. */
  18388. useVertexAlpha?: boolean | undefined);
  18389. /**
  18390. * Returns the string "LineMesh"
  18391. */
  18392. getClassName(): string;
  18393. /**
  18394. * @hidden
  18395. */
  18396. /**
  18397. * @hidden
  18398. */
  18399. material: Material;
  18400. /**
  18401. * @hidden
  18402. */
  18403. readonly checkCollisions: boolean;
  18404. /** @hidden */
  18405. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  18406. /** @hidden */
  18407. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  18408. /**
  18409. * Disposes of the line mesh
  18410. * @param doNotRecurse If children should be disposed
  18411. */
  18412. dispose(doNotRecurse?: boolean): void;
  18413. /**
  18414. * Returns a new LineMesh object cloned from the current one.
  18415. */
  18416. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  18417. /**
  18418. * Creates a new InstancedLinesMesh object from the mesh model.
  18419. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  18420. * @param name defines the name of the new instance
  18421. * @returns a new InstancedLinesMesh
  18422. */
  18423. createInstance(name: string): InstancedLinesMesh;
  18424. }
  18425. /**
  18426. * Creates an instance based on a source LinesMesh
  18427. */
  18428. export class InstancedLinesMesh extends InstancedMesh {
  18429. /**
  18430. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18431. * This margin is expressed in world space coordinates, so its value may vary.
  18432. * Initilized with the intersectionThreshold value of the source LinesMesh
  18433. */
  18434. intersectionThreshold: number;
  18435. constructor(name: string, source: LinesMesh);
  18436. /**
  18437. * Returns the string "InstancedLinesMesh".
  18438. */
  18439. getClassName(): string;
  18440. }
  18441. }
  18442. declare module "babylonjs/Meshes/groundMesh" {
  18443. import { Scene } from "babylonjs/scene";
  18444. import { Vector3 } from "babylonjs/Maths/math";
  18445. import { Mesh } from "babylonjs/Meshes/mesh";
  18446. /**
  18447. * Mesh representing the gorund
  18448. */
  18449. export class GroundMesh extends Mesh {
  18450. /** If octree should be generated */
  18451. generateOctree: boolean;
  18452. private _heightQuads;
  18453. /** @hidden */
  18454. _subdivisionsX: number;
  18455. /** @hidden */
  18456. _subdivisionsY: number;
  18457. /** @hidden */
  18458. _width: number;
  18459. /** @hidden */
  18460. _height: number;
  18461. /** @hidden */
  18462. _minX: number;
  18463. /** @hidden */
  18464. _maxX: number;
  18465. /** @hidden */
  18466. _minZ: number;
  18467. /** @hidden */
  18468. _maxZ: number;
  18469. constructor(name: string, scene: Scene);
  18470. /**
  18471. * "GroundMesh"
  18472. * @returns "GroundMesh"
  18473. */
  18474. getClassName(): string;
  18475. /**
  18476. * The minimum of x and y subdivisions
  18477. */
  18478. readonly subdivisions: number;
  18479. /**
  18480. * X subdivisions
  18481. */
  18482. readonly subdivisionsX: number;
  18483. /**
  18484. * Y subdivisions
  18485. */
  18486. readonly subdivisionsY: number;
  18487. /**
  18488. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  18489. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  18490. * @param chunksCount the number of subdivisions for x and y
  18491. * @param octreeBlocksSize (Default: 32)
  18492. */
  18493. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  18494. /**
  18495. * Returns a height (y) value in the Worl system :
  18496. * the ground altitude at the coordinates (x, z) expressed in the World system.
  18497. * @param x x coordinate
  18498. * @param z z coordinate
  18499. * @returns the ground y position if (x, z) are outside the ground surface.
  18500. */
  18501. getHeightAtCoordinates(x: number, z: number): number;
  18502. /**
  18503. * Returns a normalized vector (Vector3) orthogonal to the ground
  18504. * at the ground coordinates (x, z) expressed in the World system.
  18505. * @param x x coordinate
  18506. * @param z z coordinate
  18507. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  18508. */
  18509. getNormalAtCoordinates(x: number, z: number): Vector3;
  18510. /**
  18511. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  18512. * at the ground coordinates (x, z) expressed in the World system.
  18513. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  18514. * @param x x coordinate
  18515. * @param z z coordinate
  18516. * @param ref vector to store the result
  18517. * @returns the GroundMesh.
  18518. */
  18519. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  18520. /**
  18521. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  18522. * if the ground has been updated.
  18523. * This can be used in the render loop.
  18524. * @returns the GroundMesh.
  18525. */
  18526. updateCoordinateHeights(): GroundMesh;
  18527. private _getFacetAt;
  18528. private _initHeightQuads;
  18529. private _computeHeightQuads;
  18530. /**
  18531. * Serializes this ground mesh
  18532. * @param serializationObject object to write serialization to
  18533. */
  18534. serialize(serializationObject: any): void;
  18535. /**
  18536. * Parses a serialized ground mesh
  18537. * @param parsedMesh the serialized mesh
  18538. * @param scene the scene to create the ground mesh in
  18539. * @returns the created ground mesh
  18540. */
  18541. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  18542. }
  18543. }
  18544. declare module "babylonjs/Physics/physicsJoint" {
  18545. import { Vector3 } from "babylonjs/Maths/math";
  18546. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  18547. /**
  18548. * Interface for Physics-Joint data
  18549. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18550. */
  18551. export interface PhysicsJointData {
  18552. /**
  18553. * The main pivot of the joint
  18554. */
  18555. mainPivot?: Vector3;
  18556. /**
  18557. * The connected pivot of the joint
  18558. */
  18559. connectedPivot?: Vector3;
  18560. /**
  18561. * The main axis of the joint
  18562. */
  18563. mainAxis?: Vector3;
  18564. /**
  18565. * The connected axis of the joint
  18566. */
  18567. connectedAxis?: Vector3;
  18568. /**
  18569. * The collision of the joint
  18570. */
  18571. collision?: boolean;
  18572. /**
  18573. * Native Oimo/Cannon/Energy data
  18574. */
  18575. nativeParams?: any;
  18576. }
  18577. /**
  18578. * This is a holder class for the physics joint created by the physics plugin
  18579. * It holds a set of functions to control the underlying joint
  18580. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18581. */
  18582. export class PhysicsJoint {
  18583. /**
  18584. * The type of the physics joint
  18585. */
  18586. type: number;
  18587. /**
  18588. * The data for the physics joint
  18589. */
  18590. jointData: PhysicsJointData;
  18591. private _physicsJoint;
  18592. protected _physicsPlugin: IPhysicsEnginePlugin;
  18593. /**
  18594. * Initializes the physics joint
  18595. * @param type The type of the physics joint
  18596. * @param jointData The data for the physics joint
  18597. */
  18598. constructor(
  18599. /**
  18600. * The type of the physics joint
  18601. */
  18602. type: number,
  18603. /**
  18604. * The data for the physics joint
  18605. */
  18606. jointData: PhysicsJointData);
  18607. /**
  18608. * Gets the physics joint
  18609. */
  18610. /**
  18611. * Sets the physics joint
  18612. */
  18613. physicsJoint: any;
  18614. /**
  18615. * Sets the physics plugin
  18616. */
  18617. physicsPlugin: IPhysicsEnginePlugin;
  18618. /**
  18619. * Execute a function that is physics-plugin specific.
  18620. * @param {Function} func the function that will be executed.
  18621. * It accepts two parameters: the physics world and the physics joint
  18622. */
  18623. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  18624. /**
  18625. * Distance-Joint type
  18626. */
  18627. static DistanceJoint: number;
  18628. /**
  18629. * Hinge-Joint type
  18630. */
  18631. static HingeJoint: number;
  18632. /**
  18633. * Ball-and-Socket joint type
  18634. */
  18635. static BallAndSocketJoint: number;
  18636. /**
  18637. * Wheel-Joint type
  18638. */
  18639. static WheelJoint: number;
  18640. /**
  18641. * Slider-Joint type
  18642. */
  18643. static SliderJoint: number;
  18644. /**
  18645. * Prismatic-Joint type
  18646. */
  18647. static PrismaticJoint: number;
  18648. /**
  18649. * Universal-Joint type
  18650. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  18651. */
  18652. static UniversalJoint: number;
  18653. /**
  18654. * Hinge-Joint 2 type
  18655. */
  18656. static Hinge2Joint: number;
  18657. /**
  18658. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  18659. */
  18660. static PointToPointJoint: number;
  18661. /**
  18662. * Spring-Joint type
  18663. */
  18664. static SpringJoint: number;
  18665. /**
  18666. * Lock-Joint type
  18667. */
  18668. static LockJoint: number;
  18669. }
  18670. /**
  18671. * A class representing a physics distance joint
  18672. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18673. */
  18674. export class DistanceJoint extends PhysicsJoint {
  18675. /**
  18676. *
  18677. * @param jointData The data for the Distance-Joint
  18678. */
  18679. constructor(jointData: DistanceJointData);
  18680. /**
  18681. * Update the predefined distance.
  18682. * @param maxDistance The maximum preferred distance
  18683. * @param minDistance The minimum preferred distance
  18684. */
  18685. updateDistance(maxDistance: number, minDistance?: number): void;
  18686. }
  18687. /**
  18688. * Represents a Motor-Enabled Joint
  18689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18690. */
  18691. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  18692. /**
  18693. * Initializes the Motor-Enabled Joint
  18694. * @param type The type of the joint
  18695. * @param jointData The physica joint data for the joint
  18696. */
  18697. constructor(type: number, jointData: PhysicsJointData);
  18698. /**
  18699. * Set the motor values.
  18700. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18701. * @param force the force to apply
  18702. * @param maxForce max force for this motor.
  18703. */
  18704. setMotor(force?: number, maxForce?: number): void;
  18705. /**
  18706. * Set the motor's limits.
  18707. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18708. * @param upperLimit The upper limit of the motor
  18709. * @param lowerLimit The lower limit of the motor
  18710. */
  18711. setLimit(upperLimit: number, lowerLimit?: number): void;
  18712. }
  18713. /**
  18714. * This class represents a single physics Hinge-Joint
  18715. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18716. */
  18717. export class HingeJoint extends MotorEnabledJoint {
  18718. /**
  18719. * Initializes the Hinge-Joint
  18720. * @param jointData The joint data for the Hinge-Joint
  18721. */
  18722. constructor(jointData: PhysicsJointData);
  18723. /**
  18724. * Set the motor values.
  18725. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18726. * @param {number} force the force to apply
  18727. * @param {number} maxForce max force for this motor.
  18728. */
  18729. setMotor(force?: number, maxForce?: number): void;
  18730. /**
  18731. * Set the motor's limits.
  18732. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18733. * @param upperLimit The upper limit of the motor
  18734. * @param lowerLimit The lower limit of the motor
  18735. */
  18736. setLimit(upperLimit: number, lowerLimit?: number): void;
  18737. }
  18738. /**
  18739. * This class represents a dual hinge physics joint (same as wheel joint)
  18740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18741. */
  18742. export class Hinge2Joint extends MotorEnabledJoint {
  18743. /**
  18744. * Initializes the Hinge2-Joint
  18745. * @param jointData The joint data for the Hinge2-Joint
  18746. */
  18747. constructor(jointData: PhysicsJointData);
  18748. /**
  18749. * Set the motor values.
  18750. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18751. * @param {number} force the force to apply
  18752. * @param {number} maxForce max force for this motor.
  18753. * @param {motorIndex} the motor's index, 0 or 1.
  18754. */
  18755. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18756. /**
  18757. * Set the motor limits.
  18758. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18759. * @param {number} upperLimit the upper limit
  18760. * @param {number} lowerLimit lower limit
  18761. * @param {motorIndex} the motor's index, 0 or 1.
  18762. */
  18763. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18764. }
  18765. /**
  18766. * Interface for a motor enabled joint
  18767. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18768. */
  18769. export interface IMotorEnabledJoint {
  18770. /**
  18771. * Physics joint
  18772. */
  18773. physicsJoint: any;
  18774. /**
  18775. * Sets the motor of the motor-enabled joint
  18776. * @param force The force of the motor
  18777. * @param maxForce The maximum force of the motor
  18778. * @param motorIndex The index of the motor
  18779. */
  18780. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18781. /**
  18782. * Sets the limit of the motor
  18783. * @param upperLimit The upper limit of the motor
  18784. * @param lowerLimit The lower limit of the motor
  18785. * @param motorIndex The index of the motor
  18786. */
  18787. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18788. }
  18789. /**
  18790. * Joint data for a Distance-Joint
  18791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18792. */
  18793. export interface DistanceJointData extends PhysicsJointData {
  18794. /**
  18795. * Max distance the 2 joint objects can be apart
  18796. */
  18797. maxDistance: number;
  18798. }
  18799. /**
  18800. * Joint data from a spring joint
  18801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18802. */
  18803. export interface SpringJointData extends PhysicsJointData {
  18804. /**
  18805. * Length of the spring
  18806. */
  18807. length: number;
  18808. /**
  18809. * Stiffness of the spring
  18810. */
  18811. stiffness: number;
  18812. /**
  18813. * Damping of the spring
  18814. */
  18815. damping: number;
  18816. /** this callback will be called when applying the force to the impostors. */
  18817. forceApplicationCallback: () => void;
  18818. }
  18819. }
  18820. declare module "babylonjs/Physics/IPhysicsEngine" {
  18821. import { Nullable } from "babylonjs/types";
  18822. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  18823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18824. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  18825. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  18826. /**
  18827. * Interface used to describe a physics joint
  18828. */
  18829. export interface PhysicsImpostorJoint {
  18830. /** Defines the main impostor to which the joint is linked */
  18831. mainImpostor: PhysicsImpostor;
  18832. /** Defines the impostor that is connected to the main impostor using this joint */
  18833. connectedImpostor: PhysicsImpostor;
  18834. /** Defines the joint itself */
  18835. joint: PhysicsJoint;
  18836. }
  18837. /** @hidden */
  18838. export interface IPhysicsEnginePlugin {
  18839. world: any;
  18840. name: string;
  18841. setGravity(gravity: Vector3): void;
  18842. setTimeStep(timeStep: number): void;
  18843. getTimeStep(): number;
  18844. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  18845. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18846. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18847. generatePhysicsBody(impostor: PhysicsImpostor): void;
  18848. removePhysicsBody(impostor: PhysicsImpostor): void;
  18849. generateJoint(joint: PhysicsImpostorJoint): void;
  18850. removeJoint(joint: PhysicsImpostorJoint): void;
  18851. isSupported(): boolean;
  18852. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  18853. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  18854. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18855. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18856. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18857. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18858. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  18859. getBodyMass(impostor: PhysicsImpostor): number;
  18860. getBodyFriction(impostor: PhysicsImpostor): number;
  18861. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  18862. getBodyRestitution(impostor: PhysicsImpostor): number;
  18863. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  18864. sleepBody(impostor: PhysicsImpostor): void;
  18865. wakeUpBody(impostor: PhysicsImpostor): void;
  18866. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  18867. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  18868. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18869. getRadius(impostor: PhysicsImpostor): number;
  18870. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  18871. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  18872. dispose(): void;
  18873. }
  18874. /**
  18875. * Interface used to define a physics engine
  18876. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  18877. */
  18878. export interface IPhysicsEngine {
  18879. /**
  18880. * Gets the gravity vector used by the simulation
  18881. */
  18882. gravity: Vector3;
  18883. /**
  18884. * Sets the gravity vector used by the simulation
  18885. * @param gravity defines the gravity vector to use
  18886. */
  18887. setGravity(gravity: Vector3): void;
  18888. /**
  18889. * Set the time step of the physics engine.
  18890. * Default is 1/60.
  18891. * To slow it down, enter 1/600 for example.
  18892. * To speed it up, 1/30
  18893. * @param newTimeStep the new timestep to apply to this world.
  18894. */
  18895. setTimeStep(newTimeStep: number): void;
  18896. /**
  18897. * Get the time step of the physics engine.
  18898. * @returns the current time step
  18899. */
  18900. getTimeStep(): number;
  18901. /**
  18902. * Release all resources
  18903. */
  18904. dispose(): void;
  18905. /**
  18906. * Gets the name of the current physics plugin
  18907. * @returns the name of the plugin
  18908. */
  18909. getPhysicsPluginName(): string;
  18910. /**
  18911. * Adding a new impostor for the impostor tracking.
  18912. * This will be done by the impostor itself.
  18913. * @param impostor the impostor to add
  18914. */
  18915. addImpostor(impostor: PhysicsImpostor): void;
  18916. /**
  18917. * Remove an impostor from the engine.
  18918. * This impostor and its mesh will not longer be updated by the physics engine.
  18919. * @param impostor the impostor to remove
  18920. */
  18921. removeImpostor(impostor: PhysicsImpostor): void;
  18922. /**
  18923. * Add a joint to the physics engine
  18924. * @param mainImpostor defines the main impostor to which the joint is added.
  18925. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  18926. * @param joint defines the joint that will connect both impostors.
  18927. */
  18928. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18929. /**
  18930. * Removes a joint from the simulation
  18931. * @param mainImpostor defines the impostor used with the joint
  18932. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  18933. * @param joint defines the joint to remove
  18934. */
  18935. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18936. /**
  18937. * Gets the current plugin used to run the simulation
  18938. * @returns current plugin
  18939. */
  18940. getPhysicsPlugin(): IPhysicsEnginePlugin;
  18941. /**
  18942. * Gets the list of physic impostors
  18943. * @returns an array of PhysicsImpostor
  18944. */
  18945. getImpostors(): Array<PhysicsImpostor>;
  18946. /**
  18947. * Gets the impostor for a physics enabled object
  18948. * @param object defines the object impersonated by the impostor
  18949. * @returns the PhysicsImpostor or null if not found
  18950. */
  18951. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18952. /**
  18953. * Gets the impostor for a physics body object
  18954. * @param body defines physics body used by the impostor
  18955. * @returns the PhysicsImpostor or null if not found
  18956. */
  18957. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  18958. /**
  18959. * Called by the scene. No need to call it.
  18960. * @param delta defines the timespam between frames
  18961. */
  18962. _step(delta: number): void;
  18963. }
  18964. }
  18965. declare module "babylonjs/Physics/physicsImpostor" {
  18966. import { Nullable, IndicesArray } from "babylonjs/types";
  18967. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  18968. import { TransformNode } from "babylonjs/Meshes/transformNode";
  18969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18970. import { Scene } from "babylonjs/scene";
  18971. import { Bone } from "babylonjs/Bones/bone";
  18972. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  18973. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  18974. /**
  18975. * The interface for the physics imposter parameters
  18976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18977. */
  18978. export interface PhysicsImpostorParameters {
  18979. /**
  18980. * The mass of the physics imposter
  18981. */
  18982. mass: number;
  18983. /**
  18984. * The friction of the physics imposter
  18985. */
  18986. friction?: number;
  18987. /**
  18988. * The coefficient of restitution of the physics imposter
  18989. */
  18990. restitution?: number;
  18991. /**
  18992. * The native options of the physics imposter
  18993. */
  18994. nativeOptions?: any;
  18995. /**
  18996. * Specifies if the parent should be ignored
  18997. */
  18998. ignoreParent?: boolean;
  18999. /**
  19000. * Specifies if bi-directional transformations should be disabled
  19001. */
  19002. disableBidirectionalTransformation?: boolean;
  19003. }
  19004. /**
  19005. * Interface for a physics-enabled object
  19006. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19007. */
  19008. export interface IPhysicsEnabledObject {
  19009. /**
  19010. * The position of the physics-enabled object
  19011. */
  19012. position: Vector3;
  19013. /**
  19014. * The rotation of the physics-enabled object
  19015. */
  19016. rotationQuaternion: Nullable<Quaternion>;
  19017. /**
  19018. * The scale of the physics-enabled object
  19019. */
  19020. scaling: Vector3;
  19021. /**
  19022. * The rotation of the physics-enabled object
  19023. */
  19024. rotation?: Vector3;
  19025. /**
  19026. * The parent of the physics-enabled object
  19027. */
  19028. parent?: any;
  19029. /**
  19030. * The bounding info of the physics-enabled object
  19031. * @returns The bounding info of the physics-enabled object
  19032. */
  19033. getBoundingInfo(): BoundingInfo;
  19034. /**
  19035. * Computes the world matrix
  19036. * @param force Specifies if the world matrix should be computed by force
  19037. * @returns A world matrix
  19038. */
  19039. computeWorldMatrix(force: boolean): Matrix;
  19040. /**
  19041. * Gets the world matrix
  19042. * @returns A world matrix
  19043. */
  19044. getWorldMatrix?(): Matrix;
  19045. /**
  19046. * Gets the child meshes
  19047. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19048. * @returns An array of abstract meshes
  19049. */
  19050. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19051. /**
  19052. * Gets the vertex data
  19053. * @param kind The type of vertex data
  19054. * @returns A nullable array of numbers, or a float32 array
  19055. */
  19056. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19057. /**
  19058. * Gets the indices from the mesh
  19059. * @returns A nullable array of index arrays
  19060. */
  19061. getIndices?(): Nullable<IndicesArray>;
  19062. /**
  19063. * Gets the scene from the mesh
  19064. * @returns the indices array or null
  19065. */
  19066. getScene?(): Scene;
  19067. /**
  19068. * Gets the absolute position from the mesh
  19069. * @returns the absolute position
  19070. */
  19071. getAbsolutePosition(): Vector3;
  19072. /**
  19073. * Gets the absolute pivot point from the mesh
  19074. * @returns the absolute pivot point
  19075. */
  19076. getAbsolutePivotPoint(): Vector3;
  19077. /**
  19078. * Rotates the mesh
  19079. * @param axis The axis of rotation
  19080. * @param amount The amount of rotation
  19081. * @param space The space of the rotation
  19082. * @returns The rotation transform node
  19083. */
  19084. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19085. /**
  19086. * Translates the mesh
  19087. * @param axis The axis of translation
  19088. * @param distance The distance of translation
  19089. * @param space The space of the translation
  19090. * @returns The transform node
  19091. */
  19092. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19093. /**
  19094. * Sets the absolute position of the mesh
  19095. * @param absolutePosition The absolute position of the mesh
  19096. * @returns The transform node
  19097. */
  19098. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19099. /**
  19100. * Gets the class name of the mesh
  19101. * @returns The class name
  19102. */
  19103. getClassName(): string;
  19104. }
  19105. /**
  19106. * Represents a physics imposter
  19107. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19108. */
  19109. export class PhysicsImpostor {
  19110. /**
  19111. * The physics-enabled object used as the physics imposter
  19112. */
  19113. object: IPhysicsEnabledObject;
  19114. /**
  19115. * The type of the physics imposter
  19116. */
  19117. type: number;
  19118. private _options;
  19119. private _scene?;
  19120. /**
  19121. * The default object size of the imposter
  19122. */
  19123. static DEFAULT_OBJECT_SIZE: Vector3;
  19124. /**
  19125. * The identity quaternion of the imposter
  19126. */
  19127. static IDENTITY_QUATERNION: Quaternion;
  19128. /** @hidden */
  19129. _pluginData: any;
  19130. private _physicsEngine;
  19131. private _physicsBody;
  19132. private _bodyUpdateRequired;
  19133. private _onBeforePhysicsStepCallbacks;
  19134. private _onAfterPhysicsStepCallbacks;
  19135. /** @hidden */
  19136. _onPhysicsCollideCallbacks: Array<{
  19137. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19138. otherImpostors: Array<PhysicsImpostor>;
  19139. }>;
  19140. private _deltaPosition;
  19141. private _deltaRotation;
  19142. private _deltaRotationConjugated;
  19143. private _parent;
  19144. private _isDisposed;
  19145. private static _tmpVecs;
  19146. private static _tmpQuat;
  19147. /**
  19148. * Specifies if the physics imposter is disposed
  19149. */
  19150. readonly isDisposed: boolean;
  19151. /**
  19152. * Gets the mass of the physics imposter
  19153. */
  19154. mass: number;
  19155. /**
  19156. * Gets the coefficient of friction
  19157. */
  19158. /**
  19159. * Sets the coefficient of friction
  19160. */
  19161. friction: number;
  19162. /**
  19163. * Gets the coefficient of restitution
  19164. */
  19165. /**
  19166. * Sets the coefficient of restitution
  19167. */
  19168. restitution: number;
  19169. /**
  19170. * The unique id of the physics imposter
  19171. * set by the physics engine when adding this impostor to the array
  19172. */
  19173. uniqueId: number;
  19174. private _joints;
  19175. /**
  19176. * Initializes the physics imposter
  19177. * @param object The physics-enabled object used as the physics imposter
  19178. * @param type The type of the physics imposter
  19179. * @param _options The options for the physics imposter
  19180. * @param _scene The Babylon scene
  19181. */
  19182. constructor(
  19183. /**
  19184. * The physics-enabled object used as the physics imposter
  19185. */
  19186. object: IPhysicsEnabledObject,
  19187. /**
  19188. * The type of the physics imposter
  19189. */
  19190. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19191. /**
  19192. * This function will completly initialize this impostor.
  19193. * It will create a new body - but only if this mesh has no parent.
  19194. * If it has, this impostor will not be used other than to define the impostor
  19195. * of the child mesh.
  19196. * @hidden
  19197. */
  19198. _init(): void;
  19199. private _getPhysicsParent;
  19200. /**
  19201. * Should a new body be generated.
  19202. * @returns boolean specifying if body initialization is required
  19203. */
  19204. isBodyInitRequired(): boolean;
  19205. /**
  19206. * Sets the updated scaling
  19207. * @param updated Specifies if the scaling is updated
  19208. */
  19209. setScalingUpdated(): void;
  19210. /**
  19211. * Force a regeneration of this or the parent's impostor's body.
  19212. * Use under cautious - This will remove all joints already implemented.
  19213. */
  19214. forceUpdate(): void;
  19215. /**
  19216. * Gets the body that holds this impostor. Either its own, or its parent.
  19217. */
  19218. /**
  19219. * Set the physics body. Used mainly by the physics engine/plugin
  19220. */
  19221. physicsBody: any;
  19222. /**
  19223. * Get the parent of the physics imposter
  19224. * @returns Physics imposter or null
  19225. */
  19226. /**
  19227. * Sets the parent of the physics imposter
  19228. */
  19229. parent: Nullable<PhysicsImpostor>;
  19230. /**
  19231. * Resets the update flags
  19232. */
  19233. resetUpdateFlags(): void;
  19234. /**
  19235. * Gets the object extend size
  19236. * @returns the object extend size
  19237. */
  19238. getObjectExtendSize(): Vector3;
  19239. /**
  19240. * Gets the object center
  19241. * @returns The object center
  19242. */
  19243. getObjectCenter(): Vector3;
  19244. /**
  19245. * Get a specific parametes from the options parameter
  19246. * @param paramName The object parameter name
  19247. * @returns The object parameter
  19248. */
  19249. getParam(paramName: string): any;
  19250. /**
  19251. * Sets a specific parameter in the options given to the physics plugin
  19252. * @param paramName The parameter name
  19253. * @param value The value of the parameter
  19254. */
  19255. setParam(paramName: string, value: number): void;
  19256. /**
  19257. * Specifically change the body's mass option. Won't recreate the physics body object
  19258. * @param mass The mass of the physics imposter
  19259. */
  19260. setMass(mass: number): void;
  19261. /**
  19262. * Gets the linear velocity
  19263. * @returns linear velocity or null
  19264. */
  19265. getLinearVelocity(): Nullable<Vector3>;
  19266. /**
  19267. * Sets the linear velocity
  19268. * @param velocity linear velocity or null
  19269. */
  19270. setLinearVelocity(velocity: Nullable<Vector3>): void;
  19271. /**
  19272. * Gets the angular velocity
  19273. * @returns angular velocity or null
  19274. */
  19275. getAngularVelocity(): Nullable<Vector3>;
  19276. /**
  19277. * Sets the angular velocity
  19278. * @param velocity The velocity or null
  19279. */
  19280. setAngularVelocity(velocity: Nullable<Vector3>): void;
  19281. /**
  19282. * Execute a function with the physics plugin native code
  19283. * Provide a function the will have two variables - the world object and the physics body object
  19284. * @param func The function to execute with the physics plugin native code
  19285. */
  19286. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  19287. /**
  19288. * Register a function that will be executed before the physics world is stepping forward
  19289. * @param func The function to execute before the physics world is stepped forward
  19290. */
  19291. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19292. /**
  19293. * Unregister a function that will be executed before the physics world is stepping forward
  19294. * @param func The function to execute before the physics world is stepped forward
  19295. */
  19296. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19297. /**
  19298. * Register a function that will be executed after the physics step
  19299. * @param func The function to execute after physics step
  19300. */
  19301. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19302. /**
  19303. * Unregisters a function that will be executed after the physics step
  19304. * @param func The function to execute after physics step
  19305. */
  19306. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19307. /**
  19308. * register a function that will be executed when this impostor collides against a different body
  19309. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  19310. * @param func Callback that is executed on collision
  19311. */
  19312. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  19313. /**
  19314. * Unregisters the physics imposter on contact
  19315. * @param collideAgainst The physics object to collide against
  19316. * @param func Callback to execute on collision
  19317. */
  19318. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  19319. private _tmpQuat;
  19320. private _tmpQuat2;
  19321. /**
  19322. * Get the parent rotation
  19323. * @returns The parent rotation
  19324. */
  19325. getParentsRotation(): Quaternion;
  19326. /**
  19327. * this function is executed by the physics engine.
  19328. */
  19329. beforeStep: () => void;
  19330. /**
  19331. * this function is executed by the physics engine
  19332. */
  19333. afterStep: () => void;
  19334. /**
  19335. * Legacy collision detection event support
  19336. */
  19337. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  19338. /**
  19339. * event and body object due to cannon's event-based architecture.
  19340. */
  19341. onCollide: (e: {
  19342. body: any;
  19343. }) => void;
  19344. /**
  19345. * Apply a force
  19346. * @param force The force to apply
  19347. * @param contactPoint The contact point for the force
  19348. * @returns The physics imposter
  19349. */
  19350. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19351. /**
  19352. * Apply an impulse
  19353. * @param force The impulse force
  19354. * @param contactPoint The contact point for the impulse force
  19355. * @returns The physics imposter
  19356. */
  19357. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19358. /**
  19359. * A help function to create a joint
  19360. * @param otherImpostor A physics imposter used to create a joint
  19361. * @param jointType The type of joint
  19362. * @param jointData The data for the joint
  19363. * @returns The physics imposter
  19364. */
  19365. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  19366. /**
  19367. * Add a joint to this impostor with a different impostor
  19368. * @param otherImpostor A physics imposter used to add a joint
  19369. * @param joint The joint to add
  19370. * @returns The physics imposter
  19371. */
  19372. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  19373. /**
  19374. * Will keep this body still, in a sleep mode.
  19375. * @returns the physics imposter
  19376. */
  19377. sleep(): PhysicsImpostor;
  19378. /**
  19379. * Wake the body up.
  19380. * @returns The physics imposter
  19381. */
  19382. wakeUp(): PhysicsImpostor;
  19383. /**
  19384. * Clones the physics imposter
  19385. * @param newObject The physics imposter clones to this physics-enabled object
  19386. * @returns A nullable physics imposter
  19387. */
  19388. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19389. /**
  19390. * Disposes the physics imposter
  19391. */
  19392. dispose(): void;
  19393. /**
  19394. * Sets the delta position
  19395. * @param position The delta position amount
  19396. */
  19397. setDeltaPosition(position: Vector3): void;
  19398. /**
  19399. * Sets the delta rotation
  19400. * @param rotation The delta rotation amount
  19401. */
  19402. setDeltaRotation(rotation: Quaternion): void;
  19403. /**
  19404. * Gets the box size of the physics imposter and stores the result in the input parameter
  19405. * @param result Stores the box size
  19406. * @returns The physics imposter
  19407. */
  19408. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  19409. /**
  19410. * Gets the radius of the physics imposter
  19411. * @returns Radius of the physics imposter
  19412. */
  19413. getRadius(): number;
  19414. /**
  19415. * Sync a bone with this impostor
  19416. * @param bone The bone to sync to the impostor.
  19417. * @param boneMesh The mesh that the bone is influencing.
  19418. * @param jointPivot The pivot of the joint / bone in local space.
  19419. * @param distToJoint Optional distance from the impostor to the joint.
  19420. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19421. */
  19422. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  19423. /**
  19424. * Sync impostor to a bone
  19425. * @param bone The bone that the impostor will be synced to.
  19426. * @param boneMesh The mesh that the bone is influencing.
  19427. * @param jointPivot The pivot of the joint / bone in local space.
  19428. * @param distToJoint Optional distance from the impostor to the joint.
  19429. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19430. * @param boneAxis Optional vector3 axis the bone is aligned with
  19431. */
  19432. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  19433. /**
  19434. * No-Imposter type
  19435. */
  19436. static NoImpostor: number;
  19437. /**
  19438. * Sphere-Imposter type
  19439. */
  19440. static SphereImpostor: number;
  19441. /**
  19442. * Box-Imposter type
  19443. */
  19444. static BoxImpostor: number;
  19445. /**
  19446. * Plane-Imposter type
  19447. */
  19448. static PlaneImpostor: number;
  19449. /**
  19450. * Mesh-imposter type
  19451. */
  19452. static MeshImpostor: number;
  19453. /**
  19454. * Cylinder-Imposter type
  19455. */
  19456. static CylinderImpostor: number;
  19457. /**
  19458. * Particle-Imposter type
  19459. */
  19460. static ParticleImpostor: number;
  19461. /**
  19462. * Heightmap-Imposter type
  19463. */
  19464. static HeightmapImpostor: number;
  19465. }
  19466. }
  19467. declare module "babylonjs/Meshes/mesh" {
  19468. import { Observable } from "babylonjs/Misc/observable";
  19469. import { IAnimatable } from "babylonjs/Misc/tools";
  19470. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19471. import { Camera } from "babylonjs/Cameras/camera";
  19472. import { Scene } from "babylonjs/scene";
  19473. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  19474. import { Engine } from "babylonjs/Engines/engine";
  19475. import { Node } from "babylonjs/node";
  19476. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19477. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  19478. import { Buffer } from "babylonjs/Meshes/buffer";
  19479. import { Geometry } from "babylonjs/Meshes/geometry";
  19480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19481. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19482. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  19483. import { Effect } from "babylonjs/Materials/effect";
  19484. import { Material } from "babylonjs/Materials/material";
  19485. import { Skeleton } from "babylonjs/Bones/skeleton";
  19486. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  19487. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  19488. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19489. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  19490. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19491. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  19492. /**
  19493. * Class used to represent a specific level of detail of a mesh
  19494. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19495. */
  19496. export class MeshLODLevel {
  19497. /** Defines the distance where this level should star being displayed */
  19498. distance: number;
  19499. /** Defines the mesh to use to render this level */
  19500. mesh: Nullable<Mesh>;
  19501. /**
  19502. * Creates a new LOD level
  19503. * @param distance defines the distance where this level should star being displayed
  19504. * @param mesh defines the mesh to use to render this level
  19505. */
  19506. constructor(
  19507. /** Defines the distance where this level should star being displayed */
  19508. distance: number,
  19509. /** Defines the mesh to use to render this level */
  19510. mesh: Nullable<Mesh>);
  19511. }
  19512. /**
  19513. * @hidden
  19514. **/
  19515. export class _CreationDataStorage {
  19516. closePath?: boolean;
  19517. closeArray?: boolean;
  19518. idx: number[];
  19519. dashSize: number;
  19520. gapSize: number;
  19521. path3D: Path3D;
  19522. pathArray: Vector3[][];
  19523. arc: number;
  19524. radius: number;
  19525. cap: number;
  19526. tessellation: number;
  19527. }
  19528. /**
  19529. * @hidden
  19530. **/
  19531. class _InstanceDataStorage {
  19532. visibleInstances: any;
  19533. renderIdForInstances: number[];
  19534. batchCache: _InstancesBatch;
  19535. instancesBufferSize: number;
  19536. instancesBuffer: Nullable<Buffer>;
  19537. instancesData: Float32Array;
  19538. overridenInstanceCount: number;
  19539. }
  19540. /**
  19541. * @hidden
  19542. **/
  19543. export class _InstancesBatch {
  19544. mustReturn: boolean;
  19545. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  19546. renderSelf: boolean[];
  19547. }
  19548. /**
  19549. * Class used to represent renderable models
  19550. */
  19551. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  19552. /**
  19553. * Mesh side orientation : usually the external or front surface
  19554. */
  19555. static readonly FRONTSIDE: number;
  19556. /**
  19557. * Mesh side orientation : usually the internal or back surface
  19558. */
  19559. static readonly BACKSIDE: number;
  19560. /**
  19561. * Mesh side orientation : both internal and external or front and back surfaces
  19562. */
  19563. static readonly DOUBLESIDE: number;
  19564. /**
  19565. * Mesh side orientation : by default, `FRONTSIDE`
  19566. */
  19567. static readonly DEFAULTSIDE: number;
  19568. /**
  19569. * Mesh cap setting : no cap
  19570. */
  19571. static readonly NO_CAP: number;
  19572. /**
  19573. * Mesh cap setting : one cap at the beginning of the mesh
  19574. */
  19575. static readonly CAP_START: number;
  19576. /**
  19577. * Mesh cap setting : one cap at the end of the mesh
  19578. */
  19579. static readonly CAP_END: number;
  19580. /**
  19581. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  19582. */
  19583. static readonly CAP_ALL: number;
  19584. /**
  19585. * Gets the default side orientation.
  19586. * @param orientation the orientation to value to attempt to get
  19587. * @returns the default orientation
  19588. * @hidden
  19589. */
  19590. static _GetDefaultSideOrientation(orientation?: number): number;
  19591. private _onBeforeRenderObservable;
  19592. private _onBeforeBindObservable;
  19593. private _onAfterRenderObservable;
  19594. private _onBeforeDrawObservable;
  19595. /**
  19596. * An event triggered before rendering the mesh
  19597. */
  19598. readonly onBeforeRenderObservable: Observable<Mesh>;
  19599. /**
  19600. * An event triggered before binding the mesh
  19601. */
  19602. readonly onBeforeBindObservable: Observable<Mesh>;
  19603. /**
  19604. * An event triggered after rendering the mesh
  19605. */
  19606. readonly onAfterRenderObservable: Observable<Mesh>;
  19607. /**
  19608. * An event triggered before drawing the mesh
  19609. */
  19610. readonly onBeforeDrawObservable: Observable<Mesh>;
  19611. private _onBeforeDrawObserver;
  19612. /**
  19613. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  19614. */
  19615. onBeforeDraw: () => void;
  19616. /**
  19617. * Gets the delay loading state of the mesh (when delay loading is turned on)
  19618. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  19619. */
  19620. delayLoadState: number;
  19621. /**
  19622. * Gets the list of instances created from this mesh
  19623. * it is not supposed to be modified manually.
  19624. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  19625. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19626. */
  19627. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  19628. /**
  19629. * Gets the file containing delay loading data for this mesh
  19630. */
  19631. delayLoadingFile: string;
  19632. /** @hidden */
  19633. _binaryInfo: any;
  19634. private _LODLevels;
  19635. /**
  19636. * User defined function used to change how LOD level selection is done
  19637. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19638. */
  19639. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  19640. private _morphTargetManager;
  19641. /**
  19642. * Gets or sets the morph target manager
  19643. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19644. */
  19645. morphTargetManager: Nullable<MorphTargetManager>;
  19646. /** @hidden */
  19647. _creationDataStorage: Nullable<_CreationDataStorage>;
  19648. /** @hidden */
  19649. _geometry: Nullable<Geometry>;
  19650. /** @hidden */
  19651. _delayInfo: Array<string>;
  19652. /** @hidden */
  19653. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  19654. /** @hidden */
  19655. _instanceDataStorage: _InstanceDataStorage;
  19656. private _effectiveMaterial;
  19657. /** @hidden */
  19658. _shouldGenerateFlatShading: boolean;
  19659. private _preActivateId;
  19660. /** @hidden */
  19661. _originalBuilderSideOrientation: number;
  19662. /**
  19663. * Use this property to change the original side orientation defined at construction time
  19664. */
  19665. overrideMaterialSideOrientation: Nullable<number>;
  19666. private _areNormalsFrozen;
  19667. private _sourcePositions;
  19668. private _sourceNormals;
  19669. private _source;
  19670. private meshMap;
  19671. /**
  19672. * Gets the source mesh (the one used to clone this one from)
  19673. */
  19674. readonly source: Nullable<Mesh>;
  19675. /**
  19676. * Gets or sets a boolean indicating that this mesh does not use index buffer
  19677. */
  19678. isUnIndexed: boolean;
  19679. /**
  19680. * @constructor
  19681. * @param name The value used by scene.getMeshByName() to do a lookup.
  19682. * @param scene The scene to add this mesh to.
  19683. * @param parent The parent of this mesh, if it has one
  19684. * @param source An optional Mesh from which geometry is shared, cloned.
  19685. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19686. * When false, achieved by calling a clone(), also passing False.
  19687. * This will make creation of children, recursive.
  19688. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  19689. */
  19690. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  19691. /**
  19692. * Gets the class name
  19693. * @returns the string "Mesh".
  19694. */
  19695. getClassName(): string;
  19696. /** @hidden */
  19697. readonly _isMesh: boolean;
  19698. /**
  19699. * Returns a description of this mesh
  19700. * @param fullDetails define if full details about this mesh must be used
  19701. * @returns a descriptive string representing this mesh
  19702. */
  19703. toString(fullDetails?: boolean): string;
  19704. /** @hidden */
  19705. _unBindEffect(): void;
  19706. /**
  19707. * Gets a boolean indicating if this mesh has LOD
  19708. */
  19709. readonly hasLODLevels: boolean;
  19710. /**
  19711. * Gets the list of MeshLODLevel associated with the current mesh
  19712. * @returns an array of MeshLODLevel
  19713. */
  19714. getLODLevels(): MeshLODLevel[];
  19715. private _sortLODLevels;
  19716. /**
  19717. * Add a mesh as LOD level triggered at the given distance.
  19718. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19719. * @param distance The distance from the center of the object to show this level
  19720. * @param mesh The mesh to be added as LOD level (can be null)
  19721. * @return This mesh (for chaining)
  19722. */
  19723. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  19724. /**
  19725. * Returns the LOD level mesh at the passed distance or null if not found.
  19726. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19727. * @param distance The distance from the center of the object to show this level
  19728. * @returns a Mesh or `null`
  19729. */
  19730. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  19731. /**
  19732. * Remove a mesh from the LOD array
  19733. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19734. * @param mesh defines the mesh to be removed
  19735. * @return This mesh (for chaining)
  19736. */
  19737. removeLODLevel(mesh: Mesh): Mesh;
  19738. /**
  19739. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  19740. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19741. * @param camera defines the camera to use to compute distance
  19742. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  19743. * @return This mesh (for chaining)
  19744. */
  19745. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  19746. /**
  19747. * Gets the mesh internal Geometry object
  19748. */
  19749. readonly geometry: Nullable<Geometry>;
  19750. /**
  19751. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  19752. * @returns the total number of vertices
  19753. */
  19754. getTotalVertices(): number;
  19755. /**
  19756. * Returns the content of an associated vertex buffer
  19757. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19758. * - VertexBuffer.PositionKind
  19759. * - VertexBuffer.UVKind
  19760. * - VertexBuffer.UV2Kind
  19761. * - VertexBuffer.UV3Kind
  19762. * - VertexBuffer.UV4Kind
  19763. * - VertexBuffer.UV5Kind
  19764. * - VertexBuffer.UV6Kind
  19765. * - VertexBuffer.ColorKind
  19766. * - VertexBuffer.MatricesIndicesKind
  19767. * - VertexBuffer.MatricesIndicesExtraKind
  19768. * - VertexBuffer.MatricesWeightsKind
  19769. * - VertexBuffer.MatricesWeightsExtraKind
  19770. * @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
  19771. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  19772. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  19773. */
  19774. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19775. /**
  19776. * Returns the mesh VertexBuffer object from the requested `kind`
  19777. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19778. * - VertexBuffer.PositionKind
  19779. * - VertexBuffer.UVKind
  19780. * - VertexBuffer.UV2Kind
  19781. * - VertexBuffer.UV3Kind
  19782. * - VertexBuffer.UV4Kind
  19783. * - VertexBuffer.UV5Kind
  19784. * - VertexBuffer.UV6Kind
  19785. * - VertexBuffer.ColorKind
  19786. * - VertexBuffer.MatricesIndicesKind
  19787. * - VertexBuffer.MatricesIndicesExtraKind
  19788. * - VertexBuffer.MatricesWeightsKind
  19789. * - VertexBuffer.MatricesWeightsExtraKind
  19790. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  19791. */
  19792. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19793. /**
  19794. * Tests if a specific vertex buffer is associated with this mesh
  19795. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19796. * - VertexBuffer.PositionKind
  19797. * - VertexBuffer.UVKind
  19798. * - VertexBuffer.UV2Kind
  19799. * - VertexBuffer.UV3Kind
  19800. * - VertexBuffer.UV4Kind
  19801. * - VertexBuffer.UV5Kind
  19802. * - VertexBuffer.UV6Kind
  19803. * - VertexBuffer.ColorKind
  19804. * - VertexBuffer.MatricesIndicesKind
  19805. * - VertexBuffer.MatricesIndicesExtraKind
  19806. * - VertexBuffer.MatricesWeightsKind
  19807. * - VertexBuffer.MatricesWeightsExtraKind
  19808. * @returns a boolean
  19809. */
  19810. isVerticesDataPresent(kind: string): boolean;
  19811. /**
  19812. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  19813. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19814. * - VertexBuffer.PositionKind
  19815. * - VertexBuffer.UVKind
  19816. * - VertexBuffer.UV2Kind
  19817. * - VertexBuffer.UV3Kind
  19818. * - VertexBuffer.UV4Kind
  19819. * - VertexBuffer.UV5Kind
  19820. * - VertexBuffer.UV6Kind
  19821. * - VertexBuffer.ColorKind
  19822. * - VertexBuffer.MatricesIndicesKind
  19823. * - VertexBuffer.MatricesIndicesExtraKind
  19824. * - VertexBuffer.MatricesWeightsKind
  19825. * - VertexBuffer.MatricesWeightsExtraKind
  19826. * @returns a boolean
  19827. */
  19828. isVertexBufferUpdatable(kind: string): boolean;
  19829. /**
  19830. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  19831. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19832. * - VertexBuffer.PositionKind
  19833. * - VertexBuffer.UVKind
  19834. * - VertexBuffer.UV2Kind
  19835. * - VertexBuffer.UV3Kind
  19836. * - VertexBuffer.UV4Kind
  19837. * - VertexBuffer.UV5Kind
  19838. * - VertexBuffer.UV6Kind
  19839. * - VertexBuffer.ColorKind
  19840. * - VertexBuffer.MatricesIndicesKind
  19841. * - VertexBuffer.MatricesIndicesExtraKind
  19842. * - VertexBuffer.MatricesWeightsKind
  19843. * - VertexBuffer.MatricesWeightsExtraKind
  19844. * @returns an array of strings
  19845. */
  19846. getVerticesDataKinds(): string[];
  19847. /**
  19848. * Returns a positive integer : the total number of indices in this mesh geometry.
  19849. * @returns the numner of indices or zero if the mesh has no geometry.
  19850. */
  19851. getTotalIndices(): number;
  19852. /**
  19853. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19854. * @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.
  19855. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19856. * @returns the indices array or an empty array if the mesh has no geometry
  19857. */
  19858. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  19859. readonly isBlocked: boolean;
  19860. /**
  19861. * Determine if the current mesh is ready to be rendered
  19862. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19863. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  19864. * @returns true if all associated assets are ready (material, textures, shaders)
  19865. */
  19866. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  19867. /**
  19868. * 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.
  19869. */
  19870. readonly areNormalsFrozen: boolean;
  19871. /**
  19872. * 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.
  19873. * @returns the current mesh
  19874. */
  19875. freezeNormals(): Mesh;
  19876. /**
  19877. * 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
  19878. * @returns the current mesh
  19879. */
  19880. unfreezeNormals(): Mesh;
  19881. /**
  19882. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  19883. */
  19884. overridenInstanceCount: number;
  19885. /** @hidden */
  19886. _preActivate(): Mesh;
  19887. /** @hidden */
  19888. _preActivateForIntermediateRendering(renderId: number): Mesh;
  19889. /** @hidden */
  19890. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  19891. /**
  19892. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19893. * This means the mesh underlying bounding box and sphere are recomputed.
  19894. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19895. * @returns the current mesh
  19896. */
  19897. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  19898. /** @hidden */
  19899. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  19900. /**
  19901. * This function will subdivide the mesh into multiple submeshes
  19902. * @param count defines the expected number of submeshes
  19903. */
  19904. subdivide(count: number): void;
  19905. /**
  19906. * Copy a FloatArray into a specific associated vertex buffer
  19907. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19908. * - VertexBuffer.PositionKind
  19909. * - VertexBuffer.UVKind
  19910. * - VertexBuffer.UV2Kind
  19911. * - VertexBuffer.UV3Kind
  19912. * - VertexBuffer.UV4Kind
  19913. * - VertexBuffer.UV5Kind
  19914. * - VertexBuffer.UV6Kind
  19915. * - VertexBuffer.ColorKind
  19916. * - VertexBuffer.MatricesIndicesKind
  19917. * - VertexBuffer.MatricesIndicesExtraKind
  19918. * - VertexBuffer.MatricesWeightsKind
  19919. * - VertexBuffer.MatricesWeightsExtraKind
  19920. * @param data defines the data source
  19921. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19922. * @param stride defines the data stride size (can be null)
  19923. * @returns the current mesh
  19924. */
  19925. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19926. /**
  19927. * Flags an associated vertex buffer as updatable
  19928. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  19929. * - VertexBuffer.PositionKind
  19930. * - VertexBuffer.UVKind
  19931. * - VertexBuffer.UV2Kind
  19932. * - VertexBuffer.UV3Kind
  19933. * - VertexBuffer.UV4Kind
  19934. * - VertexBuffer.UV5Kind
  19935. * - VertexBuffer.UV6Kind
  19936. * - VertexBuffer.ColorKind
  19937. * - VertexBuffer.MatricesIndicesKind
  19938. * - VertexBuffer.MatricesIndicesExtraKind
  19939. * - VertexBuffer.MatricesWeightsKind
  19940. * - VertexBuffer.MatricesWeightsExtraKind
  19941. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19942. */
  19943. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  19944. /**
  19945. * Sets the mesh global Vertex Buffer
  19946. * @param buffer defines the buffer to use
  19947. * @returns the current mesh
  19948. */
  19949. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  19950. /**
  19951. * Update a specific associated vertex buffer
  19952. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19953. * - VertexBuffer.PositionKind
  19954. * - VertexBuffer.UVKind
  19955. * - VertexBuffer.UV2Kind
  19956. * - VertexBuffer.UV3Kind
  19957. * - VertexBuffer.UV4Kind
  19958. * - VertexBuffer.UV5Kind
  19959. * - VertexBuffer.UV6Kind
  19960. * - VertexBuffer.ColorKind
  19961. * - VertexBuffer.MatricesIndicesKind
  19962. * - VertexBuffer.MatricesIndicesExtraKind
  19963. * - VertexBuffer.MatricesWeightsKind
  19964. * - VertexBuffer.MatricesWeightsExtraKind
  19965. * @param data defines the data source
  19966. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  19967. * @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)
  19968. * @returns the current mesh
  19969. */
  19970. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19971. /**
  19972. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  19973. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  19974. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  19975. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  19976. * @returns the current mesh
  19977. */
  19978. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  19979. /**
  19980. * Creates a un-shared specific occurence of the geometry for the mesh.
  19981. * @returns the current mesh
  19982. */
  19983. makeGeometryUnique(): Mesh;
  19984. /**
  19985. * Set the index buffer of this mesh
  19986. * @param indices defines the source data
  19987. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  19988. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  19989. * @returns the current mesh
  19990. */
  19991. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  19992. /**
  19993. * Update the current index buffer
  19994. * @param indices defines the source data
  19995. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  19996. * @returns the current mesh
  19997. */
  19998. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  19999. /**
  20000. * Invert the geometry to move from a right handed system to a left handed one.
  20001. * @returns the current mesh
  20002. */
  20003. toLeftHanded(): Mesh;
  20004. /** @hidden */
  20005. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20006. /** @hidden */
  20007. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20008. /**
  20009. * Registers for this mesh a javascript function called just before the rendering process
  20010. * @param func defines the function to call before rendering this mesh
  20011. * @returns the current mesh
  20012. */
  20013. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20014. /**
  20015. * Disposes a previously registered javascript function called before the rendering
  20016. * @param func defines the function to remove
  20017. * @returns the current mesh
  20018. */
  20019. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20020. /**
  20021. * Registers for this mesh a javascript function called just after the rendering is complete
  20022. * @param func defines the function to call after rendering this mesh
  20023. * @returns the current mesh
  20024. */
  20025. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20026. /**
  20027. * Disposes a previously registered javascript function called after the rendering.
  20028. * @param func defines the function to remove
  20029. * @returns the current mesh
  20030. */
  20031. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20032. /** @hidden */
  20033. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20034. /** @hidden */
  20035. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20036. /** @hidden */
  20037. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20038. /**
  20039. * 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
  20040. * @param subMesh defines the subMesh to render
  20041. * @param enableAlphaMode defines if alpha mode can be changed
  20042. * @returns the current mesh
  20043. */
  20044. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20045. private _onBeforeDraw;
  20046. /**
  20047. * Renormalize the mesh and patch it up if there are no weights
  20048. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20049. * However in the case of zero weights then we set just a single influence to 1.
  20050. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20051. */
  20052. cleanMatrixWeights(): void;
  20053. private normalizeSkinFourWeights;
  20054. private normalizeSkinWeightsAndExtra;
  20055. /**
  20056. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20057. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20058. * the user know there was an issue with importing the mesh
  20059. * @returns a validation object with skinned, valid and report string
  20060. */
  20061. validateSkinning(): {
  20062. skinned: boolean;
  20063. valid: boolean;
  20064. report: string;
  20065. };
  20066. /** @hidden */
  20067. _checkDelayState(): Mesh;
  20068. private _queueLoad;
  20069. /**
  20070. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20071. * A mesh is in the frustum if its bounding box intersects the frustum
  20072. * @param frustumPlanes defines the frustum to test
  20073. * @returns true if the mesh is in the frustum planes
  20074. */
  20075. isInFrustum(frustumPlanes: Plane[]): boolean;
  20076. /**
  20077. * Sets the mesh material by the material or multiMaterial `id` property
  20078. * @param id is a string identifying the material or the multiMaterial
  20079. * @returns the current mesh
  20080. */
  20081. setMaterialByID(id: string): Mesh;
  20082. /**
  20083. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20084. * @returns an array of IAnimatable
  20085. */
  20086. getAnimatables(): IAnimatable[];
  20087. /**
  20088. * Modifies the mesh geometry according to the passed transformation matrix.
  20089. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20090. * The mesh normals are modified using the same transformation.
  20091. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20092. * @param transform defines the transform matrix to use
  20093. * @see http://doc.babylonjs.com/resources/baking_transformations
  20094. * @returns the current mesh
  20095. */
  20096. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20097. /**
  20098. * Modifies the mesh geometry according to its own current World Matrix.
  20099. * The mesh World Matrix is then reset.
  20100. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20101. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20102. * @see http://doc.babylonjs.com/resources/baking_transformations
  20103. * @returns the current mesh
  20104. */
  20105. bakeCurrentTransformIntoVertices(): Mesh;
  20106. /** @hidden */
  20107. readonly _positions: Nullable<Vector3[]>;
  20108. /** @hidden */
  20109. _resetPointsArrayCache(): Mesh;
  20110. /** @hidden */
  20111. _generatePointsArray(): boolean;
  20112. /**
  20113. * Returns a new Mesh object generated from the current mesh properties.
  20114. * This method must not get confused with createInstance()
  20115. * @param name is a string, the name given to the new mesh
  20116. * @param newParent can be any Node object (default `null`)
  20117. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20118. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20119. * @returns a new mesh
  20120. */
  20121. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20122. /**
  20123. * Releases resources associated with this mesh.
  20124. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20125. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20126. */
  20127. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20128. /**
  20129. * Modifies the mesh geometry according to a displacement map.
  20130. * 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.
  20131. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20132. * @param url is a string, the URL from the image file is to be downloaded.
  20133. * @param minHeight is the lower limit of the displacement.
  20134. * @param maxHeight is the upper limit of the displacement.
  20135. * @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.
  20136. * @param uvOffset is an optional vector2 used to offset UV.
  20137. * @param uvScale is an optional vector2 used to scale UV.
  20138. * @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.
  20139. * @returns the Mesh.
  20140. */
  20141. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20142. /**
  20143. * Modifies the mesh geometry according to a displacementMap buffer.
  20144. * 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.
  20145. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20146. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  20147. * @param heightMapWidth is the width of the buffer image.
  20148. * @param heightMapHeight is the height of the buffer image.
  20149. * @param minHeight is the lower limit of the displacement.
  20150. * @param maxHeight is the upper limit of the displacement.
  20151. * @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.
  20152. * @param uvOffset is an optional vector2 used to offset UV.
  20153. * @param uvScale is an optional vector2 used to scale UV.
  20154. * @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.
  20155. * @returns the Mesh.
  20156. */
  20157. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20158. /**
  20159. * Modify the mesh to get a flat shading rendering.
  20160. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20161. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20162. * @returns current mesh
  20163. */
  20164. convertToFlatShadedMesh(): Mesh;
  20165. /**
  20166. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20167. * In other words, more vertices, no more indices and a single bigger VBO.
  20168. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20169. * @returns current mesh
  20170. */
  20171. convertToUnIndexedMesh(): Mesh;
  20172. /**
  20173. * Inverses facet orientations.
  20174. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20175. * @param flipNormals will also inverts the normals
  20176. * @returns current mesh
  20177. */
  20178. flipFaces(flipNormals?: boolean): Mesh;
  20179. /** @hidden */
  20180. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  20181. /** @hidden */
  20182. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  20183. /**
  20184. * Creates a new InstancedMesh object from the mesh model.
  20185. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20186. * @param name defines the name of the new instance
  20187. * @returns a new InstancedMesh
  20188. */
  20189. createInstance(name: string): InstancedMesh;
  20190. /**
  20191. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20192. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20193. * @returns the current mesh
  20194. */
  20195. synchronizeInstances(): Mesh;
  20196. /**
  20197. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  20198. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  20199. * This should be used together with the simplification to avoid disappearing triangles.
  20200. * @param successCallback an optional success callback to be called after the optimization finished.
  20201. * @returns the current mesh
  20202. */
  20203. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  20204. /**
  20205. * Serialize current mesh
  20206. * @param serializationObject defines the object which will receive the serialization data
  20207. */
  20208. serialize(serializationObject: any): void;
  20209. /** @hidden */
  20210. _syncGeometryWithMorphTargetManager(): void;
  20211. /** @hidden */
  20212. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  20213. /**
  20214. * Returns a new Mesh object parsed from the source provided.
  20215. * @param parsedMesh is the source
  20216. * @param scene defines the hosting scene
  20217. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  20218. * @returns a new Mesh
  20219. */
  20220. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  20221. /**
  20222. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  20223. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20224. * @param name defines the name of the mesh to create
  20225. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  20226. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  20227. * @param closePath creates a seam between the first and the last points of each path of the path array
  20228. * @param offset is taken in account only if the `pathArray` is containing a single path
  20229. * @param scene defines the hosting scene
  20230. * @param updatable defines if the mesh must be flagged as updatable
  20231. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20232. * @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)
  20233. * @returns a new Mesh
  20234. */
  20235. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20236. /**
  20237. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  20238. * @param name defines the name of the mesh to create
  20239. * @param radius sets the radius size (float) of the polygon (default 0.5)
  20240. * @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
  20241. * @param scene defines the hosting scene
  20242. * @param updatable defines if the mesh must be flagged as updatable
  20243. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20244. * @returns a new Mesh
  20245. */
  20246. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20247. /**
  20248. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  20249. * @param name defines the name of the mesh to create
  20250. * @param size sets the size (float) of each box side (default 1)
  20251. * @param scene defines the hosting scene
  20252. * @param updatable defines if the mesh must be flagged as updatable
  20253. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20254. * @returns a new Mesh
  20255. */
  20256. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20257. /**
  20258. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  20259. * @param name defines the name of the mesh to create
  20260. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  20261. * @param diameter sets the diameter size (float) of the sphere (default 1)
  20262. * @param scene defines the hosting scene
  20263. * @param updatable defines if the mesh must be flagged as updatable
  20264. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20265. * @returns a new Mesh
  20266. */
  20267. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20268. /**
  20269. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  20270. * @param name defines the name of the mesh to create
  20271. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  20272. * @param diameterTop set the top cap diameter (floats, default 1)
  20273. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  20274. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  20275. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  20276. * @param scene defines the hosting scene
  20277. * @param updatable defines if the mesh must be flagged as updatable
  20278. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20279. * @returns a new Mesh
  20280. */
  20281. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  20282. /**
  20283. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  20284. * @param name defines the name of the mesh to create
  20285. * @param diameter sets the diameter size (float) of the torus (default 1)
  20286. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  20287. * @param tessellation sets the number of torus sides (postive integer, default 16)
  20288. * @param scene defines the hosting scene
  20289. * @param updatable defines if the mesh must be flagged as updatable
  20290. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20291. * @returns a new Mesh
  20292. */
  20293. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20294. /**
  20295. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  20296. * @param name defines the name of the mesh to create
  20297. * @param radius sets the global radius size (float) of the torus knot (default 2)
  20298. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  20299. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  20300. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  20301. * @param p the number of windings on X axis (positive integers, default 2)
  20302. * @param q the number of windings on Y axis (positive integers, default 3)
  20303. * @param scene defines the hosting scene
  20304. * @param updatable defines if the mesh must be flagged as updatable
  20305. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20306. * @returns a new Mesh
  20307. */
  20308. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20309. /**
  20310. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  20311. * @param name defines the name of the mesh to create
  20312. * @param points is an array successive Vector3
  20313. * @param scene defines the hosting scene
  20314. * @param updatable defines if the mesh must be flagged as updatable
  20315. * @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).
  20316. * @returns a new Mesh
  20317. */
  20318. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  20319. /**
  20320. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  20321. * @param name defines the name of the mesh to create
  20322. * @param points is an array successive Vector3
  20323. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  20324. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  20325. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  20326. * @param scene defines the hosting scene
  20327. * @param updatable defines if the mesh must be flagged as updatable
  20328. * @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)
  20329. * @returns a new Mesh
  20330. */
  20331. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  20332. /**
  20333. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  20334. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  20335. * 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.
  20336. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20337. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20338. * Remember you can only change the shape positions, not their number when updating a polygon.
  20339. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  20340. * @param name defines the name of the mesh to create
  20341. * @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
  20342. * @param scene defines the hosting scene
  20343. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20344. * @param updatable defines if the mesh must be flagged as updatable
  20345. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20346. * @param earcutInjection can be used to inject your own earcut reference
  20347. * @returns a new Mesh
  20348. */
  20349. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  20350. /**
  20351. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  20352. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  20353. * @param name defines the name of the mesh to create
  20354. * @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
  20355. * @param depth defines the height of extrusion
  20356. * @param scene defines the hosting scene
  20357. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20358. * @param updatable defines if the mesh must be flagged as updatable
  20359. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20360. * @param earcutInjection can be used to inject your own earcut reference
  20361. * @returns a new Mesh
  20362. */
  20363. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  20364. /**
  20365. * Creates an extruded shape mesh.
  20366. * 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
  20367. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20368. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20369. * @param name defines the name of the mesh to create
  20370. * @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
  20371. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20372. * @param scale is the value to scale the shape
  20373. * @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
  20374. * @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
  20375. * @param scene defines the hosting scene
  20376. * @param updatable defines if the mesh must be flagged as updatable
  20377. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20378. * @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)
  20379. * @returns a new Mesh
  20380. */
  20381. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20382. /**
  20383. * Creates an custom extruded shape mesh.
  20384. * The custom extrusion is a parametric shape.
  20385. * It has no predefined shape. Its final shape will depend on the input parameters.
  20386. * Please consider using the same method from the MeshBuilder class instead
  20387. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20388. * @param name defines the name of the mesh to create
  20389. * @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
  20390. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20391. * @param scaleFunction is a custom Javascript function called on each path point
  20392. * @param rotationFunction is a custom Javascript function called on each path point
  20393. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  20394. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  20395. * @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
  20396. * @param scene defines the hosting scene
  20397. * @param updatable defines if the mesh must be flagged as updatable
  20398. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20399. * @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)
  20400. * @returns a new Mesh
  20401. */
  20402. 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;
  20403. /**
  20404. * Creates lathe mesh.
  20405. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  20406. * Please consider using the same method from the MeshBuilder class instead
  20407. * @param name defines the name of the mesh to create
  20408. * @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
  20409. * @param radius is the radius value of the lathe
  20410. * @param tessellation is the side number of the lathe.
  20411. * @param scene defines the hosting scene
  20412. * @param updatable defines if the mesh must be flagged as updatable
  20413. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20414. * @returns a new Mesh
  20415. */
  20416. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20417. /**
  20418. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  20419. * @param name defines the name of the mesh to create
  20420. * @param size sets the size (float) of both sides of the plane at once (default 1)
  20421. * @param scene defines the hosting scene
  20422. * @param updatable defines if the mesh must be flagged as updatable
  20423. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20424. * @returns a new Mesh
  20425. */
  20426. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20427. /**
  20428. * Creates a ground mesh.
  20429. * Please consider using the same method from the MeshBuilder class instead
  20430. * @param name defines the name of the mesh to create
  20431. * @param width set the width of the ground
  20432. * @param height set the height of the ground
  20433. * @param subdivisions sets the number of subdivisions per side
  20434. * @param scene defines the hosting scene
  20435. * @param updatable defines if the mesh must be flagged as updatable
  20436. * @returns a new Mesh
  20437. */
  20438. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  20439. /**
  20440. * Creates a tiled ground mesh.
  20441. * Please consider using the same method from the MeshBuilder class instead
  20442. * @param name defines the name of the mesh to create
  20443. * @param xmin set the ground minimum X coordinate
  20444. * @param zmin set the ground minimum Y coordinate
  20445. * @param xmax set the ground maximum X coordinate
  20446. * @param zmax set the ground maximum Z coordinate
  20447. * @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
  20448. * @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
  20449. * @param scene defines the hosting scene
  20450. * @param updatable defines if the mesh must be flagged as updatable
  20451. * @returns a new Mesh
  20452. */
  20453. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  20454. w: number;
  20455. h: number;
  20456. }, precision: {
  20457. w: number;
  20458. h: number;
  20459. }, scene: Scene, updatable?: boolean): Mesh;
  20460. /**
  20461. * Creates a ground mesh from a height map.
  20462. * Please consider using the same method from the MeshBuilder class instead
  20463. * @see http://doc.babylonjs.com/babylon101/height_map
  20464. * @param name defines the name of the mesh to create
  20465. * @param url sets the URL of the height map image resource
  20466. * @param width set the ground width size
  20467. * @param height set the ground height size
  20468. * @param subdivisions sets the number of subdivision per side
  20469. * @param minHeight is the minimum altitude on the ground
  20470. * @param maxHeight is the maximum altitude on the ground
  20471. * @param scene defines the hosting scene
  20472. * @param updatable defines if the mesh must be flagged as updatable
  20473. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  20474. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  20475. * @returns a new Mesh
  20476. */
  20477. 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;
  20478. /**
  20479. * Creates a tube mesh.
  20480. * The tube is a parametric shape.
  20481. * It has no predefined shape. Its final shape will depend on the input parameters.
  20482. * Please consider using the same method from the MeshBuilder class instead
  20483. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20484. * @param name defines the name of the mesh to create
  20485. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  20486. * @param radius sets the tube radius size
  20487. * @param tessellation is the number of sides on the tubular surface
  20488. * @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
  20489. * @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
  20490. * @param scene defines the hosting scene
  20491. * @param updatable defines if the mesh must be flagged as updatable
  20492. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20493. * @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)
  20494. * @returns a new Mesh
  20495. */
  20496. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  20497. (i: number, distance: number): number;
  20498. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20499. /**
  20500. * Creates a polyhedron mesh.
  20501. * Please consider using the same method from the MeshBuilder class instead.
  20502. * * 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
  20503. * * The parameter `size` (positive float, default 1) sets the polygon size
  20504. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  20505. * * 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`
  20506. * * 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
  20507. * * 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)`)
  20508. * * 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
  20509. * * 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
  20510. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20511. * * If you create a double-sided mesh, you can choose what parts of 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
  20512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20513. * @param name defines the name of the mesh to create
  20514. * @param options defines the options used to create the mesh
  20515. * @param scene defines the hosting scene
  20516. * @returns a new Mesh
  20517. */
  20518. static CreatePolyhedron(name: string, options: {
  20519. type?: number;
  20520. size?: number;
  20521. sizeX?: number;
  20522. sizeY?: number;
  20523. sizeZ?: number;
  20524. custom?: any;
  20525. faceUV?: Vector4[];
  20526. faceColors?: Color4[];
  20527. updatable?: boolean;
  20528. sideOrientation?: number;
  20529. }, scene: Scene): Mesh;
  20530. /**
  20531. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  20532. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  20533. * * 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`)
  20534. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  20535. * * 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
  20536. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20537. * * If you create a double-sided mesh, you can choose what parts of 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
  20538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20539. * @param name defines the name of the mesh
  20540. * @param options defines the options used to create the mesh
  20541. * @param scene defines the hosting scene
  20542. * @returns a new Mesh
  20543. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  20544. */
  20545. static CreateIcoSphere(name: string, options: {
  20546. radius?: number;
  20547. flat?: boolean;
  20548. subdivisions?: number;
  20549. sideOrientation?: number;
  20550. updatable?: boolean;
  20551. }, scene: Scene): Mesh;
  20552. /**
  20553. * Creates a decal mesh.
  20554. * Please consider using the same method from the MeshBuilder class instead.
  20555. * A decal is a mesh usually applied as a model onto the surface of another mesh
  20556. * @param name defines the name of the mesh
  20557. * @param sourceMesh defines the mesh receiving the decal
  20558. * @param position sets the position of the decal in world coordinates
  20559. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  20560. * @param size sets the decal scaling
  20561. * @param angle sets the angle to rotate the decal
  20562. * @returns a new Mesh
  20563. */
  20564. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  20565. /**
  20566. * Prepare internal position array for software CPU skinning
  20567. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  20568. */
  20569. setPositionsForCPUSkinning(): Float32Array;
  20570. /**
  20571. * Prepare internal normal array for software CPU skinning
  20572. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20573. */
  20574. setNormalsForCPUSkinning(): Float32Array;
  20575. /**
  20576. * Updates the vertex buffer by applying transformation from the bones
  20577. * @param skeleton defines the skeleton to apply to current mesh
  20578. * @returns the current mesh
  20579. */
  20580. applySkeleton(skeleton: Skeleton): Mesh;
  20581. /**
  20582. * 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
  20583. * @param meshes defines the list of meshes to scan
  20584. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  20585. */
  20586. static MinMax(meshes: AbstractMesh[]): {
  20587. min: Vector3;
  20588. max: Vector3;
  20589. };
  20590. /**
  20591. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  20592. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  20593. * @returns a vector3
  20594. */
  20595. static Center(meshesOrMinMaxVector: {
  20596. min: Vector3;
  20597. max: Vector3;
  20598. } | AbstractMesh[]): Vector3;
  20599. /**
  20600. * Merge the array of meshes into a single mesh for performance reasons.
  20601. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  20602. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  20603. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  20604. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  20605. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  20606. * @returns a new mesh
  20607. */
  20608. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  20609. /** @hidden */
  20610. addInstance(instance: InstancedMesh): void;
  20611. /** @hidden */
  20612. removeInstance(instance: InstancedMesh): void;
  20613. }
  20614. }
  20615. declare module "babylonjs/Materials/material" {
  20616. import { IAnimatable } from "babylonjs/Misc/tools";
  20617. import { SmartArray } from "babylonjs/Misc/smartArray";
  20618. import { Observable } from "babylonjs/Misc/observable";
  20619. import { Nullable } from "babylonjs/types";
  20620. import { Scene } from "babylonjs/scene";
  20621. import { Matrix } from "babylonjs/Maths/math";
  20622. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20624. import { Mesh } from "babylonjs/Meshes/mesh";
  20625. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20626. import { Effect } from "babylonjs/Materials/effect";
  20627. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20628. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20629. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20630. import { Animation } from "babylonjs/Animations/animation";
  20631. /**
  20632. * Base class for the main features of a material in Babylon.js
  20633. */
  20634. export class Material implements IAnimatable {
  20635. /**
  20636. * Returns the triangle fill mode
  20637. */
  20638. static readonly TriangleFillMode: number;
  20639. /**
  20640. * Returns the wireframe mode
  20641. */
  20642. static readonly WireFrameFillMode: number;
  20643. /**
  20644. * Returns the point fill mode
  20645. */
  20646. static readonly PointFillMode: number;
  20647. /**
  20648. * Returns the point list draw mode
  20649. */
  20650. static readonly PointListDrawMode: number;
  20651. /**
  20652. * Returns the line list draw mode
  20653. */
  20654. static readonly LineListDrawMode: number;
  20655. /**
  20656. * Returns the line loop draw mode
  20657. */
  20658. static readonly LineLoopDrawMode: number;
  20659. /**
  20660. * Returns the line strip draw mode
  20661. */
  20662. static readonly LineStripDrawMode: number;
  20663. /**
  20664. * Returns the triangle strip draw mode
  20665. */
  20666. static readonly TriangleStripDrawMode: number;
  20667. /**
  20668. * Returns the triangle fan draw mode
  20669. */
  20670. static readonly TriangleFanDrawMode: number;
  20671. /**
  20672. * Stores the clock-wise side orientation
  20673. */
  20674. static readonly ClockWiseSideOrientation: number;
  20675. /**
  20676. * Stores the counter clock-wise side orientation
  20677. */
  20678. static readonly CounterClockWiseSideOrientation: number;
  20679. /**
  20680. * The dirty texture flag value
  20681. */
  20682. static readonly TextureDirtyFlag: number;
  20683. /**
  20684. * The dirty light flag value
  20685. */
  20686. static readonly LightDirtyFlag: number;
  20687. /**
  20688. * The dirty fresnel flag value
  20689. */
  20690. static readonly FresnelDirtyFlag: number;
  20691. /**
  20692. * The dirty attribute flag value
  20693. */
  20694. static readonly AttributesDirtyFlag: number;
  20695. /**
  20696. * The dirty misc flag value
  20697. */
  20698. static readonly MiscDirtyFlag: number;
  20699. /**
  20700. * The all dirty flag value
  20701. */
  20702. static readonly AllDirtyFlag: number;
  20703. /**
  20704. * The ID of the material
  20705. */
  20706. id: string;
  20707. /**
  20708. * Gets or sets the unique id of the material
  20709. */
  20710. uniqueId: number;
  20711. /**
  20712. * The name of the material
  20713. */
  20714. name: string;
  20715. /**
  20716. * Gets or sets user defined metadata
  20717. */
  20718. metadata: any;
  20719. /**
  20720. * For internal use only. Please do not use.
  20721. */
  20722. reservedDataStore: any;
  20723. /**
  20724. * Specifies if the ready state should be checked on each call
  20725. */
  20726. checkReadyOnEveryCall: boolean;
  20727. /**
  20728. * Specifies if the ready state should be checked once
  20729. */
  20730. checkReadyOnlyOnce: boolean;
  20731. /**
  20732. * The state of the material
  20733. */
  20734. state: string;
  20735. /**
  20736. * The alpha value of the material
  20737. */
  20738. protected _alpha: number;
  20739. /**
  20740. * Sets the alpha value of the material
  20741. */
  20742. /**
  20743. * Gets the alpha value of the material
  20744. */
  20745. alpha: number;
  20746. /**
  20747. * Specifies if back face culling is enabled
  20748. */
  20749. protected _backFaceCulling: boolean;
  20750. /**
  20751. * Sets the back-face culling state
  20752. */
  20753. /**
  20754. * Gets the back-face culling state
  20755. */
  20756. backFaceCulling: boolean;
  20757. /**
  20758. * Stores the value for side orientation
  20759. */
  20760. sideOrientation: number;
  20761. /**
  20762. * Callback triggered when the material is compiled
  20763. */
  20764. onCompiled: (effect: Effect) => void;
  20765. /**
  20766. * Callback triggered when an error occurs
  20767. */
  20768. onError: (effect: Effect, errors: string) => void;
  20769. /**
  20770. * Callback triggered to get the render target textures
  20771. */
  20772. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  20773. /**
  20774. * Gets a boolean indicating that current material needs to register RTT
  20775. */
  20776. readonly hasRenderTargetTextures: boolean;
  20777. /**
  20778. * Specifies if the material should be serialized
  20779. */
  20780. doNotSerialize: boolean;
  20781. /**
  20782. * @hidden
  20783. */
  20784. _storeEffectOnSubMeshes: boolean;
  20785. /**
  20786. * Stores the animations for the material
  20787. */
  20788. animations: Array<Animation>;
  20789. /**
  20790. * An event triggered when the material is disposed
  20791. */
  20792. onDisposeObservable: Observable<Material>;
  20793. /**
  20794. * An observer which watches for dispose events
  20795. */
  20796. private _onDisposeObserver;
  20797. private _onUnBindObservable;
  20798. /**
  20799. * Called during a dispose event
  20800. */
  20801. onDispose: () => void;
  20802. private _onBindObservable;
  20803. /**
  20804. * An event triggered when the material is bound
  20805. */
  20806. readonly onBindObservable: Observable<AbstractMesh>;
  20807. /**
  20808. * An observer which watches for bind events
  20809. */
  20810. private _onBindObserver;
  20811. /**
  20812. * Called during a bind event
  20813. */
  20814. onBind: (Mesh: AbstractMesh) => void;
  20815. /**
  20816. * An event triggered when the material is unbound
  20817. */
  20818. readonly onUnBindObservable: Observable<Material>;
  20819. /**
  20820. * Stores the value of the alpha mode
  20821. */
  20822. private _alphaMode;
  20823. /**
  20824. * Sets the value of the alpha mode.
  20825. *
  20826. * | Value | Type | Description |
  20827. * | --- | --- | --- |
  20828. * | 0 | ALPHA_DISABLE | |
  20829. * | 1 | ALPHA_ADD | |
  20830. * | 2 | ALPHA_COMBINE | |
  20831. * | 3 | ALPHA_SUBTRACT | |
  20832. * | 4 | ALPHA_MULTIPLY | |
  20833. * | 5 | ALPHA_MAXIMIZED | |
  20834. * | 6 | ALPHA_ONEONE | |
  20835. * | 7 | ALPHA_PREMULTIPLIED | |
  20836. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20837. * | 9 | ALPHA_INTERPOLATE | |
  20838. * | 10 | ALPHA_SCREENMODE | |
  20839. *
  20840. */
  20841. /**
  20842. * Gets the value of the alpha mode
  20843. */
  20844. alphaMode: number;
  20845. /**
  20846. * Stores the state of the need depth pre-pass value
  20847. */
  20848. private _needDepthPrePass;
  20849. /**
  20850. * Sets the need depth pre-pass value
  20851. */
  20852. /**
  20853. * Gets the depth pre-pass value
  20854. */
  20855. needDepthPrePass: boolean;
  20856. /**
  20857. * Specifies if depth writing should be disabled
  20858. */
  20859. disableDepthWrite: boolean;
  20860. /**
  20861. * Specifies if depth writing should be forced
  20862. */
  20863. forceDepthWrite: boolean;
  20864. /**
  20865. * Specifies if there should be a separate pass for culling
  20866. */
  20867. separateCullingPass: boolean;
  20868. /**
  20869. * Stores the state specifing if fog should be enabled
  20870. */
  20871. private _fogEnabled;
  20872. /**
  20873. * Sets the state for enabling fog
  20874. */
  20875. /**
  20876. * Gets the value of the fog enabled state
  20877. */
  20878. fogEnabled: boolean;
  20879. /**
  20880. * Stores the size of points
  20881. */
  20882. pointSize: number;
  20883. /**
  20884. * Stores the z offset value
  20885. */
  20886. zOffset: number;
  20887. /**
  20888. * Gets a value specifying if wireframe mode is enabled
  20889. */
  20890. /**
  20891. * Sets the state of wireframe mode
  20892. */
  20893. wireframe: boolean;
  20894. /**
  20895. * Gets the value specifying if point clouds are enabled
  20896. */
  20897. /**
  20898. * Sets the state of point cloud mode
  20899. */
  20900. pointsCloud: boolean;
  20901. /**
  20902. * Gets the material fill mode
  20903. */
  20904. /**
  20905. * Sets the material fill mode
  20906. */
  20907. fillMode: number;
  20908. /**
  20909. * @hidden
  20910. * Stores the effects for the material
  20911. */
  20912. _effect: Nullable<Effect>;
  20913. /**
  20914. * @hidden
  20915. * Specifies if the material was previously ready
  20916. */
  20917. _wasPreviouslyReady: boolean;
  20918. /**
  20919. * Specifies if uniform buffers should be used
  20920. */
  20921. private _useUBO;
  20922. /**
  20923. * Stores a reference to the scene
  20924. */
  20925. private _scene;
  20926. /**
  20927. * Stores the fill mode state
  20928. */
  20929. private _fillMode;
  20930. /**
  20931. * Specifies if the depth write state should be cached
  20932. */
  20933. private _cachedDepthWriteState;
  20934. /**
  20935. * Stores the uniform buffer
  20936. */
  20937. protected _uniformBuffer: UniformBuffer;
  20938. /** @hidden */
  20939. _indexInSceneMaterialArray: number;
  20940. /** @hidden */
  20941. meshMap: Nullable<{
  20942. [id: string]: AbstractMesh | undefined;
  20943. }>;
  20944. /**
  20945. * Creates a material instance
  20946. * @param name defines the name of the material
  20947. * @param scene defines the scene to reference
  20948. * @param doNotAdd specifies if the material should be added to the scene
  20949. */
  20950. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20951. /**
  20952. * Returns a string representation of the current material
  20953. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20954. * @returns a string with material information
  20955. */
  20956. toString(fullDetails?: boolean): string;
  20957. /**
  20958. * Gets the class name of the material
  20959. * @returns a string with the class name of the material
  20960. */
  20961. getClassName(): string;
  20962. /**
  20963. * Specifies if updates for the material been locked
  20964. */
  20965. readonly isFrozen: boolean;
  20966. /**
  20967. * Locks updates for the material
  20968. */
  20969. freeze(): void;
  20970. /**
  20971. * Unlocks updates for the material
  20972. */
  20973. unfreeze(): void;
  20974. /**
  20975. * Specifies if the material is ready to be used
  20976. * @param mesh defines the mesh to check
  20977. * @param useInstances specifies if instances should be used
  20978. * @returns a boolean indicating if the material is ready to be used
  20979. */
  20980. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20981. /**
  20982. * Specifies that the submesh is ready to be used
  20983. * @param mesh defines the mesh to check
  20984. * @param subMesh defines which submesh to check
  20985. * @param useInstances specifies that instances should be used
  20986. * @returns a boolean indicating that the submesh is ready or not
  20987. */
  20988. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20989. /**
  20990. * Returns the material effect
  20991. * @returns the effect associated with the material
  20992. */
  20993. getEffect(): Nullable<Effect>;
  20994. /**
  20995. * Returns the current scene
  20996. * @returns a Scene
  20997. */
  20998. getScene(): Scene;
  20999. /**
  21000. * Specifies if the material will require alpha blending
  21001. * @returns a boolean specifying if alpha blending is needed
  21002. */
  21003. needAlphaBlending(): boolean;
  21004. /**
  21005. * Specifies if the mesh will require alpha blending
  21006. * @param mesh defines the mesh to check
  21007. * @returns a boolean specifying if alpha blending is needed for the mesh
  21008. */
  21009. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21010. /**
  21011. * Specifies if this material should be rendered in alpha test mode
  21012. * @returns a boolean specifying if an alpha test is needed.
  21013. */
  21014. needAlphaTesting(): boolean;
  21015. /**
  21016. * Gets the texture used for the alpha test
  21017. * @returns the texture to use for alpha testing
  21018. */
  21019. getAlphaTestTexture(): Nullable<BaseTexture>;
  21020. /**
  21021. * Marks the material to indicate that it needs to be re-calculated
  21022. */
  21023. markDirty(): void;
  21024. /** @hidden */
  21025. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21026. /**
  21027. * Binds the material to the mesh
  21028. * @param world defines the world transformation matrix
  21029. * @param mesh defines the mesh to bind the material to
  21030. */
  21031. bind(world: Matrix, mesh?: Mesh): void;
  21032. /**
  21033. * Binds the submesh to the material
  21034. * @param world defines the world transformation matrix
  21035. * @param mesh defines the mesh containing the submesh
  21036. * @param subMesh defines the submesh to bind the material to
  21037. */
  21038. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21039. /**
  21040. * Binds the world matrix to the material
  21041. * @param world defines the world transformation matrix
  21042. */
  21043. bindOnlyWorldMatrix(world: Matrix): void;
  21044. /**
  21045. * Binds the scene's uniform buffer to the effect.
  21046. * @param effect defines the effect to bind to the scene uniform buffer
  21047. * @param sceneUbo defines the uniform buffer storing scene data
  21048. */
  21049. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21050. /**
  21051. * Binds the view matrix to the effect
  21052. * @param effect defines the effect to bind the view matrix to
  21053. */
  21054. bindView(effect: Effect): void;
  21055. /**
  21056. * Binds the view projection matrix to the effect
  21057. * @param effect defines the effect to bind the view projection matrix to
  21058. */
  21059. bindViewProjection(effect: Effect): void;
  21060. /**
  21061. * Specifies if material alpha testing should be turned on for the mesh
  21062. * @param mesh defines the mesh to check
  21063. */
  21064. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21065. /**
  21066. * Processes to execute after binding the material to a mesh
  21067. * @param mesh defines the rendered mesh
  21068. */
  21069. protected _afterBind(mesh?: Mesh): void;
  21070. /**
  21071. * Unbinds the material from the mesh
  21072. */
  21073. unbind(): void;
  21074. /**
  21075. * Gets the active textures from the material
  21076. * @returns an array of textures
  21077. */
  21078. getActiveTextures(): BaseTexture[];
  21079. /**
  21080. * Specifies if the material uses a texture
  21081. * @param texture defines the texture to check against the material
  21082. * @returns a boolean specifying if the material uses the texture
  21083. */
  21084. hasTexture(texture: BaseTexture): boolean;
  21085. /**
  21086. * Makes a duplicate of the material, and gives it a new name
  21087. * @param name defines the new name for the duplicated material
  21088. * @returns the cloned material
  21089. */
  21090. clone(name: string): Nullable<Material>;
  21091. /**
  21092. * Gets the meshes bound to the material
  21093. * @returns an array of meshes bound to the material
  21094. */
  21095. getBindedMeshes(): AbstractMesh[];
  21096. /**
  21097. * Force shader compilation
  21098. * @param mesh defines the mesh associated with this material
  21099. * @param onCompiled defines a function to execute once the material is compiled
  21100. * @param options defines the options to configure the compilation
  21101. */
  21102. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21103. clipPlane: boolean;
  21104. }>): void;
  21105. /**
  21106. * Force shader compilation
  21107. * @param mesh defines the mesh that will use this material
  21108. * @param options defines additional options for compiling the shaders
  21109. * @returns a promise that resolves when the compilation completes
  21110. */
  21111. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21112. clipPlane: boolean;
  21113. }>): Promise<void>;
  21114. private static readonly _ImageProcessingDirtyCallBack;
  21115. private static readonly _TextureDirtyCallBack;
  21116. private static readonly _FresnelDirtyCallBack;
  21117. private static readonly _MiscDirtyCallBack;
  21118. private static readonly _LightsDirtyCallBack;
  21119. private static readonly _AttributeDirtyCallBack;
  21120. private static _FresnelAndMiscDirtyCallBack;
  21121. private static _TextureAndMiscDirtyCallBack;
  21122. private static readonly _DirtyCallbackArray;
  21123. private static readonly _RunDirtyCallBacks;
  21124. /**
  21125. * Marks a define in the material to indicate that it needs to be re-computed
  21126. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21127. */
  21128. markAsDirty(flag: number): void;
  21129. /**
  21130. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21131. * @param func defines a function which checks material defines against the submeshes
  21132. */
  21133. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21134. /**
  21135. * Indicates that image processing needs to be re-calculated for all submeshes
  21136. */
  21137. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21138. /**
  21139. * Indicates that textures need to be re-calculated for all submeshes
  21140. */
  21141. protected _markAllSubMeshesAsTexturesDirty(): void;
  21142. /**
  21143. * Indicates that fresnel needs to be re-calculated for all submeshes
  21144. */
  21145. protected _markAllSubMeshesAsFresnelDirty(): void;
  21146. /**
  21147. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21148. */
  21149. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21150. /**
  21151. * Indicates that lights need to be re-calculated for all submeshes
  21152. */
  21153. protected _markAllSubMeshesAsLightsDirty(): void;
  21154. /**
  21155. * Indicates that attributes need to be re-calculated for all submeshes
  21156. */
  21157. protected _markAllSubMeshesAsAttributesDirty(): void;
  21158. /**
  21159. * Indicates that misc needs to be re-calculated for all submeshes
  21160. */
  21161. protected _markAllSubMeshesAsMiscDirty(): void;
  21162. /**
  21163. * Indicates that textures and misc need to be re-calculated for all submeshes
  21164. */
  21165. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21166. /**
  21167. * Disposes the material
  21168. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21169. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21170. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21171. */
  21172. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21173. /** @hidden */
  21174. private releaseVertexArrayObject;
  21175. /**
  21176. * Serializes this material
  21177. * @returns the serialized material object
  21178. */
  21179. serialize(): any;
  21180. /**
  21181. * Creates a material from parsed material data
  21182. * @param parsedMaterial defines parsed material data
  21183. * @param scene defines the hosting scene
  21184. * @param rootUrl defines the root URL to use to load textures
  21185. * @returns a new material
  21186. */
  21187. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  21188. }
  21189. }
  21190. declare module "babylonjs/Materials/multiMaterial" {
  21191. import { Nullable } from "babylonjs/types";
  21192. import { Scene } from "babylonjs/scene";
  21193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21194. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21195. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21196. import { Material } from "babylonjs/Materials/material";
  21197. /**
  21198. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21199. * separate meshes. This can be use to improve performances.
  21200. * @see http://doc.babylonjs.com/how_to/multi_materials
  21201. */
  21202. export class MultiMaterial extends Material {
  21203. private _subMaterials;
  21204. /**
  21205. * Gets or Sets the list of Materials used within the multi material.
  21206. * They need to be ordered according to the submeshes order in the associated mesh
  21207. */
  21208. subMaterials: Nullable<Material>[];
  21209. /**
  21210. * Function used to align with Node.getChildren()
  21211. * @returns the list of Materials used within the multi material
  21212. */
  21213. getChildren(): Nullable<Material>[];
  21214. /**
  21215. * Instantiates a new Multi Material
  21216. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21217. * separate meshes. This can be use to improve performances.
  21218. * @see http://doc.babylonjs.com/how_to/multi_materials
  21219. * @param name Define the name in the scene
  21220. * @param scene Define the scene the material belongs to
  21221. */
  21222. constructor(name: string, scene: Scene);
  21223. private _hookArray;
  21224. /**
  21225. * Get one of the submaterial by its index in the submaterials array
  21226. * @param index The index to look the sub material at
  21227. * @returns The Material if the index has been defined
  21228. */
  21229. getSubMaterial(index: number): Nullable<Material>;
  21230. /**
  21231. * Get the list of active textures for the whole sub materials list.
  21232. * @returns All the textures that will be used during the rendering
  21233. */
  21234. getActiveTextures(): BaseTexture[];
  21235. /**
  21236. * Gets the current class name of the material e.g. "MultiMaterial"
  21237. * Mainly use in serialization.
  21238. * @returns the class name
  21239. */
  21240. getClassName(): string;
  21241. /**
  21242. * Checks if the material is ready to render the requested sub mesh
  21243. * @param mesh Define the mesh the submesh belongs to
  21244. * @param subMesh Define the sub mesh to look readyness for
  21245. * @param useInstances Define whether or not the material is used with instances
  21246. * @returns true if ready, otherwise false
  21247. */
  21248. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21249. /**
  21250. * Clones the current material and its related sub materials
  21251. * @param name Define the name of the newly cloned material
  21252. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21253. * @returns the cloned material
  21254. */
  21255. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21256. /**
  21257. * Serializes the materials into a JSON representation.
  21258. * @returns the JSON representation
  21259. */
  21260. serialize(): any;
  21261. /**
  21262. * Dispose the material and release its associated resources
  21263. * @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)
  21264. * @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)
  21265. * @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)
  21266. */
  21267. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21268. /**
  21269. * Creates a MultiMaterial from parsed MultiMaterial data.
  21270. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21271. * @param scene defines the hosting scene
  21272. * @returns a new MultiMaterial
  21273. */
  21274. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21275. }
  21276. }
  21277. declare module "babylonjs/Meshes/subMesh" {
  21278. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  21279. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  21280. import { Engine } from "babylonjs/Engines/engine";
  21281. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21282. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21283. import { Effect } from "babylonjs/Materials/effect";
  21284. import { Collider } from "babylonjs/Collisions/collider";
  21285. import { Material } from "babylonjs/Materials/material";
  21286. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21288. import { Mesh } from "babylonjs/Meshes/mesh";
  21289. import { Ray } from "babylonjs/Culling/ray";
  21290. /**
  21291. * Base class for submeshes
  21292. */
  21293. export class BaseSubMesh {
  21294. /** @hidden */
  21295. _materialDefines: Nullable<MaterialDefines>;
  21296. /** @hidden */
  21297. _materialEffect: Nullable<Effect>;
  21298. /**
  21299. * Gets associated effect
  21300. */
  21301. readonly effect: Nullable<Effect>;
  21302. /**
  21303. * Sets associated effect (effect used to render this submesh)
  21304. * @param effect defines the effect to associate with
  21305. * @param defines defines the set of defines used to compile this effect
  21306. */
  21307. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21308. }
  21309. /**
  21310. * Defines a subdivision inside a mesh
  21311. */
  21312. export class SubMesh extends BaseSubMesh implements ICullable {
  21313. /** the material index to use */
  21314. materialIndex: number;
  21315. /** vertex index start */
  21316. verticesStart: number;
  21317. /** vertices count */
  21318. verticesCount: number;
  21319. /** index start */
  21320. indexStart: number;
  21321. /** indices count */
  21322. indexCount: number;
  21323. /** @hidden */
  21324. _linesIndexCount: number;
  21325. private _mesh;
  21326. private _renderingMesh;
  21327. private _boundingInfo;
  21328. private _linesIndexBuffer;
  21329. /** @hidden */
  21330. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21331. /** @hidden */
  21332. _trianglePlanes: Plane[];
  21333. /** @hidden */
  21334. _lastColliderTransformMatrix: Matrix;
  21335. /** @hidden */
  21336. _renderId: number;
  21337. /** @hidden */
  21338. _alphaIndex: number;
  21339. /** @hidden */
  21340. _distanceToCamera: number;
  21341. /** @hidden */
  21342. _id: number;
  21343. private _currentMaterial;
  21344. /**
  21345. * Add a new submesh to a mesh
  21346. * @param materialIndex defines the material index to use
  21347. * @param verticesStart defines vertex index start
  21348. * @param verticesCount defines vertices count
  21349. * @param indexStart defines index start
  21350. * @param indexCount defines indices count
  21351. * @param mesh defines the parent mesh
  21352. * @param renderingMesh defines an optional rendering mesh
  21353. * @param createBoundingBox defines if bounding box should be created for this submesh
  21354. * @returns the new submesh
  21355. */
  21356. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21357. /**
  21358. * Creates a new submesh
  21359. * @param materialIndex defines the material index to use
  21360. * @param verticesStart defines vertex index start
  21361. * @param verticesCount defines vertices count
  21362. * @param indexStart defines index start
  21363. * @param indexCount defines indices count
  21364. * @param mesh defines the parent mesh
  21365. * @param renderingMesh defines an optional rendering mesh
  21366. * @param createBoundingBox defines if bounding box should be created for this submesh
  21367. */
  21368. constructor(
  21369. /** the material index to use */
  21370. materialIndex: number,
  21371. /** vertex index start */
  21372. verticesStart: number,
  21373. /** vertices count */
  21374. verticesCount: number,
  21375. /** index start */
  21376. indexStart: number,
  21377. /** indices count */
  21378. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21379. /**
  21380. * Returns true if this submesh covers the entire parent mesh
  21381. * @ignorenaming
  21382. */
  21383. readonly IsGlobal: boolean;
  21384. /**
  21385. * Returns the submesh BoudingInfo object
  21386. * @returns current bounding info (or mesh's one if the submesh is global)
  21387. */
  21388. getBoundingInfo(): BoundingInfo;
  21389. /**
  21390. * Sets the submesh BoundingInfo
  21391. * @param boundingInfo defines the new bounding info to use
  21392. * @returns the SubMesh
  21393. */
  21394. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21395. /**
  21396. * Returns the mesh of the current submesh
  21397. * @return the parent mesh
  21398. */
  21399. getMesh(): AbstractMesh;
  21400. /**
  21401. * Returns the rendering mesh of the submesh
  21402. * @returns the rendering mesh (could be different from parent mesh)
  21403. */
  21404. getRenderingMesh(): Mesh;
  21405. /**
  21406. * Returns the submesh material
  21407. * @returns null or the current material
  21408. */
  21409. getMaterial(): Nullable<Material>;
  21410. /**
  21411. * Sets a new updated BoundingInfo object to the submesh
  21412. * @returns the SubMesh
  21413. */
  21414. refreshBoundingInfo(): SubMesh;
  21415. /** @hidden */
  21416. _checkCollision(collider: Collider): boolean;
  21417. /**
  21418. * Updates the submesh BoundingInfo
  21419. * @param world defines the world matrix to use to update the bounding info
  21420. * @returns the submesh
  21421. */
  21422. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21423. /**
  21424. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21425. * @param frustumPlanes defines the frustum planes
  21426. * @returns true if the submesh is intersecting with the frustum
  21427. */
  21428. isInFrustum(frustumPlanes: Plane[]): boolean;
  21429. /**
  21430. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21431. * @param frustumPlanes defines the frustum planes
  21432. * @returns true if the submesh is inside the frustum
  21433. */
  21434. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21435. /**
  21436. * Renders the submesh
  21437. * @param enableAlphaMode defines if alpha needs to be used
  21438. * @returns the submesh
  21439. */
  21440. render(enableAlphaMode: boolean): SubMesh;
  21441. /**
  21442. * @hidden
  21443. */
  21444. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  21445. /**
  21446. * Checks if the submesh intersects with a ray
  21447. * @param ray defines the ray to test
  21448. * @returns true is the passed ray intersects the submesh bounding box
  21449. */
  21450. canIntersects(ray: Ray): boolean;
  21451. /**
  21452. * Intersects current submesh with a ray
  21453. * @param ray defines the ray to test
  21454. * @param positions defines mesh's positions array
  21455. * @param indices defines mesh's indices array
  21456. * @param fastCheck defines if only bounding info should be used
  21457. * @returns intersection info or null if no intersection
  21458. */
  21459. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  21460. /** @hidden */
  21461. private _intersectLines;
  21462. /** @hidden */
  21463. private _intersectTriangles;
  21464. /** @hidden */
  21465. _rebuild(): void;
  21466. /**
  21467. * Creates a new submesh from the passed mesh
  21468. * @param newMesh defines the new hosting mesh
  21469. * @param newRenderingMesh defines an optional rendering mesh
  21470. * @returns the new submesh
  21471. */
  21472. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21473. /**
  21474. * Release associated resources
  21475. */
  21476. dispose(): void;
  21477. /**
  21478. * Gets the class name
  21479. * @returns the string "SubMesh".
  21480. */
  21481. getClassName(): string;
  21482. /**
  21483. * Creates a new submesh from indices data
  21484. * @param materialIndex the index of the main mesh material
  21485. * @param startIndex the index where to start the copy in the mesh indices array
  21486. * @param indexCount the number of indices to copy then from the startIndex
  21487. * @param mesh the main mesh to create the submesh from
  21488. * @param renderingMesh the optional rendering mesh
  21489. * @returns a new submesh
  21490. */
  21491. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21492. }
  21493. }
  21494. declare module "babylonjs/Meshes/geometry" {
  21495. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21496. import { Scene } from "babylonjs/scene";
  21497. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  21498. import { Engine } from "babylonjs/Engines/engine";
  21499. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21500. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21501. import { Effect } from "babylonjs/Materials/effect";
  21502. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21503. import { Mesh } from "babylonjs/Meshes/mesh";
  21504. /**
  21505. * Class used to store geometry data (vertex buffers + index buffer)
  21506. */
  21507. export class Geometry implements IGetSetVerticesData {
  21508. /**
  21509. * Gets or sets the ID of the geometry
  21510. */
  21511. id: string;
  21512. /**
  21513. * Gets or sets the unique ID of the geometry
  21514. */
  21515. uniqueId: number;
  21516. /**
  21517. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21518. */
  21519. delayLoadState: number;
  21520. /**
  21521. * Gets the file containing the data to load when running in delay load state
  21522. */
  21523. delayLoadingFile: Nullable<string>;
  21524. /**
  21525. * Callback called when the geometry is updated
  21526. */
  21527. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21528. private _scene;
  21529. private _engine;
  21530. private _meshes;
  21531. private _totalVertices;
  21532. /** @hidden */
  21533. _indices: IndicesArray;
  21534. /** @hidden */
  21535. _vertexBuffers: {
  21536. [key: string]: VertexBuffer;
  21537. };
  21538. private _isDisposed;
  21539. private _extend;
  21540. private _boundingBias;
  21541. /** @hidden */
  21542. _delayInfo: Array<string>;
  21543. private _indexBuffer;
  21544. private _indexBufferIsUpdatable;
  21545. /** @hidden */
  21546. _boundingInfo: Nullable<BoundingInfo>;
  21547. /** @hidden */
  21548. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21549. /** @hidden */
  21550. _softwareSkinningFrameId: number;
  21551. private _vertexArrayObjects;
  21552. private _updatable;
  21553. /** @hidden */
  21554. _positions: Nullable<Vector3[]>;
  21555. /**
  21556. * 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
  21557. */
  21558. /**
  21559. * 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
  21560. */
  21561. boundingBias: Vector2;
  21562. /**
  21563. * Static function used to attach a new empty geometry to a mesh
  21564. * @param mesh defines the mesh to attach the geometry to
  21565. * @returns the new Geometry
  21566. */
  21567. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21568. /**
  21569. * Creates a new geometry
  21570. * @param id defines the unique ID
  21571. * @param scene defines the hosting scene
  21572. * @param vertexData defines the VertexData used to get geometry data
  21573. * @param updatable defines if geometry must be updatable (false by default)
  21574. * @param mesh defines the mesh that will be associated with the geometry
  21575. */
  21576. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21577. /**
  21578. * Gets the current extend of the geometry
  21579. */
  21580. readonly extend: {
  21581. minimum: Vector3;
  21582. maximum: Vector3;
  21583. };
  21584. /**
  21585. * Gets the hosting scene
  21586. * @returns the hosting Scene
  21587. */
  21588. getScene(): Scene;
  21589. /**
  21590. * Gets the hosting engine
  21591. * @returns the hosting Engine
  21592. */
  21593. getEngine(): Engine;
  21594. /**
  21595. * Defines if the geometry is ready to use
  21596. * @returns true if the geometry is ready to be used
  21597. */
  21598. isReady(): boolean;
  21599. /**
  21600. * Gets a value indicating that the geometry should not be serialized
  21601. */
  21602. readonly doNotSerialize: boolean;
  21603. /** @hidden */
  21604. _rebuild(): void;
  21605. /**
  21606. * Affects all geometry data in one call
  21607. * @param vertexData defines the geometry data
  21608. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21609. */
  21610. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21611. /**
  21612. * Set specific vertex data
  21613. * @param kind defines the data kind (Position, normal, etc...)
  21614. * @param data defines the vertex data to use
  21615. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21616. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21617. */
  21618. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21619. /**
  21620. * Removes a specific vertex data
  21621. * @param kind defines the data kind (Position, normal, etc...)
  21622. */
  21623. removeVerticesData(kind: string): void;
  21624. /**
  21625. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21626. * @param buffer defines the vertex buffer to use
  21627. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21628. */
  21629. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21630. /**
  21631. * Update a specific vertex buffer
  21632. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  21633. * It will do nothing if the buffer is not updatable
  21634. * @param kind defines the data kind (Position, normal, etc...)
  21635. * @param data defines the data to use
  21636. * @param offset defines the offset in the target buffer where to store the data
  21637. * @param useBytes set to true if the offset is in bytes
  21638. */
  21639. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21640. /**
  21641. * Update a specific vertex buffer
  21642. * This function will create a new buffer if the current one is not updatable
  21643. * @param kind defines the data kind (Position, normal, etc...)
  21644. * @param data defines the data to use
  21645. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21646. */
  21647. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21648. private _updateBoundingInfo;
  21649. /** @hidden */
  21650. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  21651. /**
  21652. * Gets total number of vertices
  21653. * @returns the total number of vertices
  21654. */
  21655. getTotalVertices(): number;
  21656. /**
  21657. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21658. * @param kind defines the data kind (Position, normal, etc...)
  21659. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21660. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21661. * @returns a float array containing vertex data
  21662. */
  21663. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21664. /**
  21665. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21666. * @param kind defines the data kind (Position, normal, etc...)
  21667. * @returns true if the vertex buffer with the specified kind is updatable
  21668. */
  21669. isVertexBufferUpdatable(kind: string): boolean;
  21670. /**
  21671. * Gets a specific vertex buffer
  21672. * @param kind defines the data kind (Position, normal, etc...)
  21673. * @returns a VertexBuffer
  21674. */
  21675. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21676. /**
  21677. * Returns all vertex buffers
  21678. * @return an object holding all vertex buffers indexed by kind
  21679. */
  21680. getVertexBuffers(): Nullable<{
  21681. [key: string]: VertexBuffer;
  21682. }>;
  21683. /**
  21684. * Gets a boolean indicating if specific vertex buffer is present
  21685. * @param kind defines the data kind (Position, normal, etc...)
  21686. * @returns true if data is present
  21687. */
  21688. isVerticesDataPresent(kind: string): boolean;
  21689. /**
  21690. * Gets a list of all attached data kinds (Position, normal, etc...)
  21691. * @returns a list of string containing all kinds
  21692. */
  21693. getVerticesDataKinds(): string[];
  21694. /**
  21695. * Update index buffer
  21696. * @param indices defines the indices to store in the index buffer
  21697. * @param offset defines the offset in the target buffer where to store the data
  21698. */
  21699. updateIndices(indices: IndicesArray, offset?: number): void;
  21700. /**
  21701. * Creates a new index buffer
  21702. * @param indices defines the indices to store in the index buffer
  21703. * @param totalVertices defines the total number of vertices (could be null)
  21704. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21705. */
  21706. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21707. /**
  21708. * Return the total number of indices
  21709. * @returns the total number of indices
  21710. */
  21711. getTotalIndices(): number;
  21712. /**
  21713. * Gets the index buffer array
  21714. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21715. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21716. * @returns the index buffer array
  21717. */
  21718. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21719. /**
  21720. * Gets the index buffer
  21721. * @return the index buffer
  21722. */
  21723. getIndexBuffer(): Nullable<WebGLBuffer>;
  21724. /** @hidden */
  21725. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21726. /**
  21727. * Release the associated resources for a specific mesh
  21728. * @param mesh defines the source mesh
  21729. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21730. */
  21731. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21732. /**
  21733. * Apply current geometry to a given mesh
  21734. * @param mesh defines the mesh to apply geometry to
  21735. */
  21736. applyToMesh(mesh: Mesh): void;
  21737. private _updateExtend;
  21738. private _applyToMesh;
  21739. private notifyUpdate;
  21740. /**
  21741. * Load the geometry if it was flagged as delay loaded
  21742. * @param scene defines the hosting scene
  21743. * @param onLoaded defines a callback called when the geometry is loaded
  21744. */
  21745. load(scene: Scene, onLoaded?: () => void): void;
  21746. private _queueLoad;
  21747. /**
  21748. * Invert the geometry to move from a right handed system to a left handed one.
  21749. */
  21750. toLeftHanded(): void;
  21751. /** @hidden */
  21752. _resetPointsArrayCache(): void;
  21753. /** @hidden */
  21754. _generatePointsArray(): boolean;
  21755. /**
  21756. * Gets a value indicating if the geometry is disposed
  21757. * @returns true if the geometry was disposed
  21758. */
  21759. isDisposed(): boolean;
  21760. private _disposeVertexArrayObjects;
  21761. /**
  21762. * Free all associated resources
  21763. */
  21764. dispose(): void;
  21765. /**
  21766. * Clone the current geometry into a new geometry
  21767. * @param id defines the unique ID of the new geometry
  21768. * @returns a new geometry object
  21769. */
  21770. copy(id: string): Geometry;
  21771. /**
  21772. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21773. * @return a JSON representation of the current geometry data (without the vertices data)
  21774. */
  21775. serialize(): any;
  21776. private toNumberArray;
  21777. /**
  21778. * Serialize all vertices data into a JSON oject
  21779. * @returns a JSON representation of the current geometry data
  21780. */
  21781. serializeVerticeData(): any;
  21782. /**
  21783. * Extracts a clone of a mesh geometry
  21784. * @param mesh defines the source mesh
  21785. * @param id defines the unique ID of the new geometry object
  21786. * @returns the new geometry object
  21787. */
  21788. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21789. /**
  21790. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21791. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21792. * Be aware Math.random() could cause collisions, but:
  21793. * "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"
  21794. * @returns a string containing a new GUID
  21795. */
  21796. static RandomId(): string;
  21797. /** @hidden */
  21798. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21799. private static _CleanMatricesWeights;
  21800. /**
  21801. * Create a new geometry from persisted data (Using .babylon file format)
  21802. * @param parsedVertexData defines the persisted data
  21803. * @param scene defines the hosting scene
  21804. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21805. * @returns the new geometry object
  21806. */
  21807. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21808. }
  21809. }
  21810. declare module "babylonjs/Meshes/mesh.vertexData" {
  21811. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21812. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  21813. import { Geometry } from "babylonjs/Meshes/geometry";
  21814. import { Mesh } from "babylonjs/Meshes/mesh";
  21815. /**
  21816. * Define an interface for all classes that will get and set the data on vertices
  21817. */
  21818. export interface IGetSetVerticesData {
  21819. /**
  21820. * Gets a boolean indicating if specific vertex data is present
  21821. * @param kind defines the vertex data kind to use
  21822. * @returns true is data kind is present
  21823. */
  21824. isVerticesDataPresent(kind: string): boolean;
  21825. /**
  21826. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21827. * @param kind defines the data kind (Position, normal, etc...)
  21828. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21829. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21830. * @returns a float array containing vertex data
  21831. */
  21832. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21833. /**
  21834. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21835. * @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.
  21836. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21837. * @returns the indices array or an empty array if the mesh has no geometry
  21838. */
  21839. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21840. /**
  21841. * Set specific vertex data
  21842. * @param kind defines the data kind (Position, normal, etc...)
  21843. * @param data defines the vertex data to use
  21844. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21845. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21846. */
  21847. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21848. /**
  21849. * Update a specific associated vertex buffer
  21850. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21851. * - VertexBuffer.PositionKind
  21852. * - VertexBuffer.UVKind
  21853. * - VertexBuffer.UV2Kind
  21854. * - VertexBuffer.UV3Kind
  21855. * - VertexBuffer.UV4Kind
  21856. * - VertexBuffer.UV5Kind
  21857. * - VertexBuffer.UV6Kind
  21858. * - VertexBuffer.ColorKind
  21859. * - VertexBuffer.MatricesIndicesKind
  21860. * - VertexBuffer.MatricesIndicesExtraKind
  21861. * - VertexBuffer.MatricesWeightsKind
  21862. * - VertexBuffer.MatricesWeightsExtraKind
  21863. * @param data defines the data source
  21864. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21865. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  21866. */
  21867. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21868. /**
  21869. * Creates a new index buffer
  21870. * @param indices defines the indices to store in the index buffer
  21871. * @param totalVertices defines the total number of vertices (could be null)
  21872. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21873. */
  21874. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21875. }
  21876. /**
  21877. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21878. */
  21879. export class VertexData {
  21880. /**
  21881. * Mesh side orientation : usually the external or front surface
  21882. */
  21883. static readonly FRONTSIDE: number;
  21884. /**
  21885. * Mesh side orientation : usually the internal or back surface
  21886. */
  21887. static readonly BACKSIDE: number;
  21888. /**
  21889. * Mesh side orientation : both internal and external or front and back surfaces
  21890. */
  21891. static readonly DOUBLESIDE: number;
  21892. /**
  21893. * Mesh side orientation : by default, `FRONTSIDE`
  21894. */
  21895. static readonly DEFAULTSIDE: number;
  21896. /**
  21897. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21898. */
  21899. positions: Nullable<FloatArray>;
  21900. /**
  21901. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21902. */
  21903. normals: Nullable<FloatArray>;
  21904. /**
  21905. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21906. */
  21907. tangents: Nullable<FloatArray>;
  21908. /**
  21909. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21910. */
  21911. uvs: Nullable<FloatArray>;
  21912. /**
  21913. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21914. */
  21915. uvs2: Nullable<FloatArray>;
  21916. /**
  21917. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21918. */
  21919. uvs3: Nullable<FloatArray>;
  21920. /**
  21921. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21922. */
  21923. uvs4: Nullable<FloatArray>;
  21924. /**
  21925. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21926. */
  21927. uvs5: Nullable<FloatArray>;
  21928. /**
  21929. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21930. */
  21931. uvs6: Nullable<FloatArray>;
  21932. /**
  21933. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21934. */
  21935. colors: Nullable<FloatArray>;
  21936. /**
  21937. * 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).
  21938. */
  21939. matricesIndices: Nullable<FloatArray>;
  21940. /**
  21941. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21942. */
  21943. matricesWeights: Nullable<FloatArray>;
  21944. /**
  21945. * An array extending the number of possible indices
  21946. */
  21947. matricesIndicesExtra: Nullable<FloatArray>;
  21948. /**
  21949. * An array extending the number of possible weights when the number of indices is extended
  21950. */
  21951. matricesWeightsExtra: Nullable<FloatArray>;
  21952. /**
  21953. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21954. */
  21955. indices: Nullable<IndicesArray>;
  21956. /**
  21957. * Uses the passed data array to set the set the values for the specified kind of data
  21958. * @param data a linear array of floating numbers
  21959. * @param kind the type of data that is being set, eg positions, colors etc
  21960. */
  21961. set(data: FloatArray, kind: string): void;
  21962. /**
  21963. * Associates the vertexData to the passed Mesh.
  21964. * Sets it as updatable or not (default `false`)
  21965. * @param mesh the mesh the vertexData is applied to
  21966. * @param updatable when used and having the value true allows new data to update the vertexData
  21967. * @returns the VertexData
  21968. */
  21969. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21970. /**
  21971. * Associates the vertexData to the passed Geometry.
  21972. * Sets it as updatable or not (default `false`)
  21973. * @param geometry the geometry the vertexData is applied to
  21974. * @param updatable when used and having the value true allows new data to update the vertexData
  21975. * @returns VertexData
  21976. */
  21977. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21978. /**
  21979. * Updates the associated mesh
  21980. * @param mesh the mesh to be updated
  21981. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21982. * @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
  21983. * @returns VertexData
  21984. */
  21985. updateMesh(mesh: Mesh): VertexData;
  21986. /**
  21987. * Updates the associated geometry
  21988. * @param geometry the geometry to be updated
  21989. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21990. * @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
  21991. * @returns VertexData.
  21992. */
  21993. updateGeometry(geometry: Geometry): VertexData;
  21994. private _applyTo;
  21995. private _update;
  21996. /**
  21997. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21998. * @param matrix the transforming matrix
  21999. * @returns the VertexData
  22000. */
  22001. transform(matrix: Matrix): VertexData;
  22002. /**
  22003. * Merges the passed VertexData into the current one
  22004. * @param other the VertexData to be merged into the current one
  22005. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22006. * @returns the modified VertexData
  22007. */
  22008. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22009. private _mergeElement;
  22010. private _validate;
  22011. /**
  22012. * Serializes the VertexData
  22013. * @returns a serialized object
  22014. */
  22015. serialize(): any;
  22016. /**
  22017. * Extracts the vertexData from a mesh
  22018. * @param mesh the mesh from which to extract the VertexData
  22019. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22020. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22021. * @returns the object VertexData associated to the passed mesh
  22022. */
  22023. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22024. /**
  22025. * Extracts the vertexData from the geometry
  22026. * @param geometry the geometry from which to extract the VertexData
  22027. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22028. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22029. * @returns the object VertexData associated to the passed mesh
  22030. */
  22031. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22032. private static _ExtractFrom;
  22033. /**
  22034. * Creates the VertexData for a Ribbon
  22035. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22036. * * pathArray array of paths, each of which an array of successive Vector3
  22037. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22038. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22039. * * 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
  22040. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22041. * * 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)
  22042. * * 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)
  22043. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22044. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22045. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22046. * @returns the VertexData of the ribbon
  22047. */
  22048. static CreateRibbon(options: {
  22049. pathArray: Vector3[][];
  22050. closeArray?: boolean;
  22051. closePath?: boolean;
  22052. offset?: number;
  22053. sideOrientation?: number;
  22054. frontUVs?: Vector4;
  22055. backUVs?: Vector4;
  22056. invertUV?: boolean;
  22057. uvs?: Vector2[];
  22058. colors?: Color4[];
  22059. }): VertexData;
  22060. /**
  22061. * Creates the VertexData for a box
  22062. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22063. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22064. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22065. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22066. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22067. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22068. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22069. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22070. * * 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)
  22071. * * 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)
  22072. * @returns the VertexData of the box
  22073. */
  22074. static CreateBox(options: {
  22075. size?: number;
  22076. width?: number;
  22077. height?: number;
  22078. depth?: number;
  22079. faceUV?: Vector4[];
  22080. faceColors?: Color4[];
  22081. sideOrientation?: number;
  22082. frontUVs?: Vector4;
  22083. backUVs?: Vector4;
  22084. }): VertexData;
  22085. /**
  22086. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22087. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22088. * * segments sets the number of horizontal strips optional, default 32
  22089. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22090. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22091. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22092. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22093. * * 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
  22094. * * 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
  22095. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22096. * * 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)
  22097. * * 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)
  22098. * @returns the VertexData of the ellipsoid
  22099. */
  22100. static CreateSphere(options: {
  22101. segments?: number;
  22102. diameter?: number;
  22103. diameterX?: number;
  22104. diameterY?: number;
  22105. diameterZ?: number;
  22106. arc?: number;
  22107. slice?: number;
  22108. sideOrientation?: number;
  22109. frontUVs?: Vector4;
  22110. backUVs?: Vector4;
  22111. }): VertexData;
  22112. /**
  22113. * Creates the VertexData for a cylinder, cone or prism
  22114. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22115. * * height sets the height (y direction) of the cylinder, optional, default 2
  22116. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22117. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22118. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22119. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22120. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22121. * * 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
  22122. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22123. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22124. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22125. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22126. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22127. * * 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)
  22128. * * 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)
  22129. * @returns the VertexData of the cylinder, cone or prism
  22130. */
  22131. static CreateCylinder(options: {
  22132. height?: number;
  22133. diameterTop?: number;
  22134. diameterBottom?: number;
  22135. diameter?: number;
  22136. tessellation?: number;
  22137. subdivisions?: number;
  22138. arc?: number;
  22139. faceColors?: Color4[];
  22140. faceUV?: Vector4[];
  22141. hasRings?: boolean;
  22142. enclose?: boolean;
  22143. sideOrientation?: number;
  22144. frontUVs?: Vector4;
  22145. backUVs?: Vector4;
  22146. }): VertexData;
  22147. /**
  22148. * Creates the VertexData for a torus
  22149. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22150. * * diameter the diameter of the torus, optional default 1
  22151. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22152. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22153. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22154. * * 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)
  22155. * * 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)
  22156. * @returns the VertexData of the torus
  22157. */
  22158. static CreateTorus(options: {
  22159. diameter?: number;
  22160. thickness?: number;
  22161. tessellation?: number;
  22162. sideOrientation?: number;
  22163. frontUVs?: Vector4;
  22164. backUVs?: Vector4;
  22165. }): VertexData;
  22166. /**
  22167. * Creates the VertexData of the LineSystem
  22168. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22169. * - lines an array of lines, each line being an array of successive Vector3
  22170. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22171. * @returns the VertexData of the LineSystem
  22172. */
  22173. static CreateLineSystem(options: {
  22174. lines: Vector3[][];
  22175. colors?: Nullable<Color4[][]>;
  22176. }): VertexData;
  22177. /**
  22178. * Create the VertexData for a DashedLines
  22179. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22180. * - points an array successive Vector3
  22181. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22182. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22183. * - dashNb the intended total number of dashes, optional, default 200
  22184. * @returns the VertexData for the DashedLines
  22185. */
  22186. static CreateDashedLines(options: {
  22187. points: Vector3[];
  22188. dashSize?: number;
  22189. gapSize?: number;
  22190. dashNb?: number;
  22191. }): VertexData;
  22192. /**
  22193. * Creates the VertexData for a Ground
  22194. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22195. * - width the width (x direction) of the ground, optional, default 1
  22196. * - height the height (z direction) of the ground, optional, default 1
  22197. * - subdivisions the number of subdivisions per side, optional, default 1
  22198. * @returns the VertexData of the Ground
  22199. */
  22200. static CreateGround(options: {
  22201. width?: number;
  22202. height?: number;
  22203. subdivisions?: number;
  22204. subdivisionsX?: number;
  22205. subdivisionsY?: number;
  22206. }): VertexData;
  22207. /**
  22208. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22209. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22210. * * xmin the ground minimum X coordinate, optional, default -1
  22211. * * zmin the ground minimum Z coordinate, optional, default -1
  22212. * * xmax the ground maximum X coordinate, optional, default 1
  22213. * * zmax the ground maximum Z coordinate, optional, default 1
  22214. * * 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}
  22215. * * 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}
  22216. * @returns the VertexData of the TiledGround
  22217. */
  22218. static CreateTiledGround(options: {
  22219. xmin: number;
  22220. zmin: number;
  22221. xmax: number;
  22222. zmax: number;
  22223. subdivisions?: {
  22224. w: number;
  22225. h: number;
  22226. };
  22227. precision?: {
  22228. w: number;
  22229. h: number;
  22230. };
  22231. }): VertexData;
  22232. /**
  22233. * Creates the VertexData of the Ground designed from a heightmap
  22234. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22235. * * width the width (x direction) of the ground
  22236. * * height the height (z direction) of the ground
  22237. * * subdivisions the number of subdivisions per side
  22238. * * minHeight the minimum altitude on the ground, optional, default 0
  22239. * * maxHeight the maximum altitude on the ground, optional default 1
  22240. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22241. * * buffer the array holding the image color data
  22242. * * bufferWidth the width of image
  22243. * * bufferHeight the height of image
  22244. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22245. * @returns the VertexData of the Ground designed from a heightmap
  22246. */
  22247. static CreateGroundFromHeightMap(options: {
  22248. width: number;
  22249. height: number;
  22250. subdivisions: number;
  22251. minHeight: number;
  22252. maxHeight: number;
  22253. colorFilter: Color3;
  22254. buffer: Uint8Array;
  22255. bufferWidth: number;
  22256. bufferHeight: number;
  22257. alphaFilter: number;
  22258. }): VertexData;
  22259. /**
  22260. * Creates the VertexData for a Plane
  22261. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22262. * * size sets the width and height of the plane to the value of size, optional default 1
  22263. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22264. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22265. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22266. * * 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)
  22267. * * 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)
  22268. * @returns the VertexData of the box
  22269. */
  22270. static CreatePlane(options: {
  22271. size?: number;
  22272. width?: number;
  22273. height?: number;
  22274. sideOrientation?: number;
  22275. frontUVs?: Vector4;
  22276. backUVs?: Vector4;
  22277. }): VertexData;
  22278. /**
  22279. * Creates the VertexData of the Disc or regular Polygon
  22280. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22281. * * radius the radius of the disc, optional default 0.5
  22282. * * tessellation the number of polygon sides, optional, default 64
  22283. * * 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
  22284. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22285. * * 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)
  22286. * * 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)
  22287. * @returns the VertexData of the box
  22288. */
  22289. static CreateDisc(options: {
  22290. radius?: number;
  22291. tessellation?: number;
  22292. arc?: number;
  22293. sideOrientation?: number;
  22294. frontUVs?: Vector4;
  22295. backUVs?: Vector4;
  22296. }): VertexData;
  22297. /**
  22298. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22299. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22300. * @param polygon a mesh built from polygonTriangulation.build()
  22301. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22302. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22303. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22304. * @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)
  22305. * @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)
  22306. * @returns the VertexData of the Polygon
  22307. */
  22308. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22309. /**
  22310. * Creates the VertexData of the IcoSphere
  22311. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22312. * * radius the radius of the IcoSphere, optional default 1
  22313. * * radiusX allows stretching in the x direction, optional, default radius
  22314. * * radiusY allows stretching in the y direction, optional, default radius
  22315. * * radiusZ allows stretching in the z direction, optional, default radius
  22316. * * flat when true creates a flat shaded mesh, optional, default true
  22317. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22318. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22319. * * 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)
  22320. * * 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)
  22321. * @returns the VertexData of the IcoSphere
  22322. */
  22323. static CreateIcoSphere(options: {
  22324. radius?: number;
  22325. radiusX?: number;
  22326. radiusY?: number;
  22327. radiusZ?: number;
  22328. flat?: boolean;
  22329. subdivisions?: number;
  22330. sideOrientation?: number;
  22331. frontUVs?: Vector4;
  22332. backUVs?: Vector4;
  22333. }): VertexData;
  22334. /**
  22335. * Creates the VertexData for a Polyhedron
  22336. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22337. * * type provided types are:
  22338. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22339. * * 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)
  22340. * * size the size of the IcoSphere, optional default 1
  22341. * * sizeX allows stretching in the x direction, optional, default size
  22342. * * sizeY allows stretching in the y direction, optional, default size
  22343. * * sizeZ allows stretching in the z direction, optional, default size
  22344. * * 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
  22345. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22346. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22347. * * flat when true creates a flat shaded mesh, optional, default true
  22348. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22349. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22350. * * 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)
  22351. * * 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)
  22352. * @returns the VertexData of the Polyhedron
  22353. */
  22354. static CreatePolyhedron(options: {
  22355. type?: number;
  22356. size?: number;
  22357. sizeX?: number;
  22358. sizeY?: number;
  22359. sizeZ?: number;
  22360. custom?: any;
  22361. faceUV?: Vector4[];
  22362. faceColors?: Color4[];
  22363. flat?: boolean;
  22364. sideOrientation?: number;
  22365. frontUVs?: Vector4;
  22366. backUVs?: Vector4;
  22367. }): VertexData;
  22368. /**
  22369. * Creates the VertexData for a TorusKnot
  22370. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22371. * * radius the radius of the torus knot, optional, default 2
  22372. * * tube the thickness of the tube, optional, default 0.5
  22373. * * radialSegments the number of sides on each tube segments, optional, default 32
  22374. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22375. * * p the number of windings around the z axis, optional, default 2
  22376. * * q the number of windings around the x axis, optional, default 3
  22377. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22378. * * 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)
  22379. * * 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)
  22380. * @returns the VertexData of the Torus Knot
  22381. */
  22382. static CreateTorusKnot(options: {
  22383. radius?: number;
  22384. tube?: number;
  22385. radialSegments?: number;
  22386. tubularSegments?: number;
  22387. p?: number;
  22388. q?: number;
  22389. sideOrientation?: number;
  22390. frontUVs?: Vector4;
  22391. backUVs?: Vector4;
  22392. }): VertexData;
  22393. /**
  22394. * Compute normals for given positions and indices
  22395. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22396. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22397. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22398. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22399. * * facetNormals : optional array of facet normals (vector3)
  22400. * * facetPositions : optional array of facet positions (vector3)
  22401. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22402. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22403. * * bInfo : optional bounding info, required for facetPartitioning computation
  22404. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22405. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22406. * * useRightHandedSystem: optional boolean to for right handed system computation
  22407. * * depthSort : optional boolean to enable the facet depth sort computation
  22408. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22409. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22410. */
  22411. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22412. facetNormals?: any;
  22413. facetPositions?: any;
  22414. facetPartitioning?: any;
  22415. ratio?: number;
  22416. bInfo?: any;
  22417. bbSize?: Vector3;
  22418. subDiv?: any;
  22419. useRightHandedSystem?: boolean;
  22420. depthSort?: boolean;
  22421. distanceTo?: Vector3;
  22422. depthSortedFacets?: any;
  22423. }): void;
  22424. /** @hidden */
  22425. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22426. /**
  22427. * Applies VertexData created from the imported parameters to the geometry
  22428. * @param parsedVertexData the parsed data from an imported file
  22429. * @param geometry the geometry to apply the VertexData to
  22430. */
  22431. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22432. }
  22433. }
  22434. declare module "babylonjs/Meshes/Builders/discBuilder" {
  22435. import { Nullable } from "babylonjs/types";
  22436. import { Scene } from "babylonjs/scene";
  22437. import { Vector4 } from "babylonjs/Maths/math";
  22438. import { Mesh } from "babylonjs/Meshes/mesh";
  22439. /**
  22440. * Class containing static functions to help procedurally build meshes
  22441. */
  22442. export class DiscBuilder {
  22443. /**
  22444. * Creates a plane polygonal mesh. By default, this is a disc
  22445. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22446. * * 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
  22447. * * 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
  22448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22449. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22451. * @param name defines the name of the mesh
  22452. * @param options defines the options used to create the mesh
  22453. * @param scene defines the hosting scene
  22454. * @returns the plane polygonal mesh
  22455. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22456. */
  22457. static CreateDisc(name: string, options: {
  22458. radius?: number;
  22459. tessellation?: number;
  22460. arc?: number;
  22461. updatable?: boolean;
  22462. sideOrientation?: number;
  22463. frontUVs?: Vector4;
  22464. backUVs?: Vector4;
  22465. }, scene?: Nullable<Scene>): Mesh;
  22466. }
  22467. }
  22468. declare module "babylonjs/Particles/solidParticleSystem" {
  22469. import { Vector3 } from "babylonjs/Maths/math";
  22470. import { Mesh } from "babylonjs/Meshes/mesh";
  22471. import { Scene, IDisposable } from "babylonjs/scene";
  22472. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  22473. /**
  22474. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  22475. *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.
  22476. * The SPS is also a particle system. It provides some methods to manage the particles.
  22477. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  22478. *
  22479. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  22480. */
  22481. export class SolidParticleSystem implements IDisposable {
  22482. /**
  22483. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  22484. * Example : var p = SPS.particles[i];
  22485. */
  22486. particles: SolidParticle[];
  22487. /**
  22488. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  22489. */
  22490. nbParticles: number;
  22491. /**
  22492. * If the particles must ever face the camera (default false). Useful for planar particles.
  22493. */
  22494. billboard: boolean;
  22495. /**
  22496. * Recompute normals when adding a shape
  22497. */
  22498. recomputeNormals: boolean;
  22499. /**
  22500. * This a counter ofr your own usage. It's not set by any SPS functions.
  22501. */
  22502. counter: number;
  22503. /**
  22504. * The SPS name. This name is also given to the underlying mesh.
  22505. */
  22506. name: string;
  22507. /**
  22508. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  22509. */
  22510. mesh: Mesh;
  22511. /**
  22512. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  22513. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  22514. */
  22515. vars: any;
  22516. /**
  22517. * This array is populated when the SPS is set as 'pickable'.
  22518. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  22519. * Each element of this array is an object `{idx: int, faceId: int}`.
  22520. * `idx` is the picked particle index in the `SPS.particles` array
  22521. * `faceId` is the picked face index counted within this particle.
  22522. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  22523. */
  22524. pickedParticles: {
  22525. idx: number;
  22526. faceId: number;
  22527. }[];
  22528. /**
  22529. * This array is populated when `enableDepthSort` is set to true.
  22530. * Each element of this array is an instance of the class DepthSortedParticle.
  22531. */
  22532. depthSortedParticles: DepthSortedParticle[];
  22533. /**
  22534. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  22535. * @hidden
  22536. */
  22537. _bSphereOnly: boolean;
  22538. /**
  22539. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  22540. * @hidden
  22541. */
  22542. _bSphereRadiusFactor: number;
  22543. private _scene;
  22544. private _positions;
  22545. private _indices;
  22546. private _normals;
  22547. private _colors;
  22548. private _uvs;
  22549. private _indices32;
  22550. private _positions32;
  22551. private _normals32;
  22552. private _fixedNormal32;
  22553. private _colors32;
  22554. private _uvs32;
  22555. private _index;
  22556. private _updatable;
  22557. private _pickable;
  22558. private _isVisibilityBoxLocked;
  22559. private _alwaysVisible;
  22560. private _depthSort;
  22561. private _shapeCounter;
  22562. private _copy;
  22563. private _color;
  22564. private _computeParticleColor;
  22565. private _computeParticleTexture;
  22566. private _computeParticleRotation;
  22567. private _computeParticleVertex;
  22568. private _computeBoundingBox;
  22569. private _depthSortParticles;
  22570. private _camera;
  22571. private _mustUnrotateFixedNormals;
  22572. private _particlesIntersect;
  22573. private _needs32Bits;
  22574. /**
  22575. * Creates a SPS (Solid Particle System) object.
  22576. * @param name (String) is the SPS name, this will be the underlying mesh name.
  22577. * @param scene (Scene) is the scene in which the SPS is added.
  22578. * @param options defines the options of the sps e.g.
  22579. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  22580. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  22581. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  22582. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  22583. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  22584. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  22585. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  22586. */
  22587. constructor(name: string, scene: Scene, options?: {
  22588. updatable?: boolean;
  22589. isPickable?: boolean;
  22590. enableDepthSort?: boolean;
  22591. particleIntersection?: boolean;
  22592. boundingSphereOnly?: boolean;
  22593. bSphereRadiusFactor?: number;
  22594. });
  22595. /**
  22596. * Builds the SPS underlying mesh. Returns a standard Mesh.
  22597. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  22598. * @returns the created mesh
  22599. */
  22600. buildMesh(): Mesh;
  22601. /**
  22602. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  22603. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  22604. * Thus the particles generated from `digest()` have their property `position` set yet.
  22605. * @param mesh ( Mesh ) is the mesh to be digested
  22606. * @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
  22607. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  22608. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  22609. * @returns the current SPS
  22610. */
  22611. digest(mesh: Mesh, options?: {
  22612. facetNb?: number;
  22613. number?: number;
  22614. delta?: number;
  22615. }): SolidParticleSystem;
  22616. private _unrotateFixedNormals;
  22617. private _resetCopy;
  22618. private _meshBuilder;
  22619. private _posToShape;
  22620. private _uvsToShapeUV;
  22621. private _addParticle;
  22622. /**
  22623. * Adds some particles to the SPS from the model shape. Returns the shape id.
  22624. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  22625. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  22626. * @param nb (positive integer) the number of particles to be created from this model
  22627. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  22628. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  22629. * @returns the number of shapes in the system
  22630. */
  22631. addShape(mesh: Mesh, nb: number, options?: {
  22632. positionFunction?: any;
  22633. vertexFunction?: any;
  22634. }): number;
  22635. private _rebuildParticle;
  22636. /**
  22637. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  22638. * @returns the SPS.
  22639. */
  22640. rebuildMesh(): SolidParticleSystem;
  22641. /**
  22642. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  22643. * This method calls `updateParticle()` for each particle of the SPS.
  22644. * For an animated SPS, it is usually called within the render loop.
  22645. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  22646. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  22647. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  22648. * @returns the SPS.
  22649. */
  22650. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  22651. /**
  22652. * Disposes the SPS.
  22653. */
  22654. dispose(): void;
  22655. /**
  22656. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  22657. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22658. * @returns the SPS.
  22659. */
  22660. refreshVisibleSize(): SolidParticleSystem;
  22661. /**
  22662. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  22663. * @param size the size (float) of the visibility box
  22664. * note : this doesn't lock the SPS mesh bounding box.
  22665. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22666. */
  22667. setVisibilityBox(size: number): void;
  22668. /**
  22669. * Gets whether the SPS as always visible or not
  22670. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22671. */
  22672. /**
  22673. * Sets the SPS as always visible or not
  22674. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22675. */
  22676. isAlwaysVisible: boolean;
  22677. /**
  22678. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22679. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22680. */
  22681. /**
  22682. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22683. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22684. */
  22685. isVisibilityBoxLocked: boolean;
  22686. /**
  22687. * Tells to `setParticles()` to compute the particle rotations or not.
  22688. * Default value : true. The SPS is faster when it's set to false.
  22689. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22690. */
  22691. /**
  22692. * Gets if `setParticles()` computes the particle rotations or not.
  22693. * Default value : true. The SPS is faster when it's set to false.
  22694. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22695. */
  22696. computeParticleRotation: boolean;
  22697. /**
  22698. * Tells to `setParticles()` to compute the particle colors or not.
  22699. * Default value : true. The SPS is faster when it's set to false.
  22700. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22701. */
  22702. /**
  22703. * Gets if `setParticles()` computes the particle colors or not.
  22704. * Default value : true. The SPS is faster when it's set to false.
  22705. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22706. */
  22707. computeParticleColor: boolean;
  22708. /**
  22709. * Gets if `setParticles()` computes the particle textures or not.
  22710. * Default value : true. The SPS is faster when it's set to false.
  22711. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  22712. */
  22713. computeParticleTexture: boolean;
  22714. /**
  22715. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  22716. * Default value : false. The SPS is faster when it's set to false.
  22717. * Note : the particle custom vertex positions aren't stored values.
  22718. */
  22719. /**
  22720. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  22721. * Default value : false. The SPS is faster when it's set to false.
  22722. * Note : the particle custom vertex positions aren't stored values.
  22723. */
  22724. computeParticleVertex: boolean;
  22725. /**
  22726. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  22727. */
  22728. /**
  22729. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  22730. */
  22731. computeBoundingBox: boolean;
  22732. /**
  22733. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  22734. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22735. * Default : `true`
  22736. */
  22737. /**
  22738. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  22739. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22740. * Default : `true`
  22741. */
  22742. depthSortParticles: boolean;
  22743. /**
  22744. * This function does nothing. It may be overwritten to set all the particle first values.
  22745. * The SPS doesn't call this function, you may have to call it by your own.
  22746. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22747. */
  22748. initParticles(): void;
  22749. /**
  22750. * This function does nothing. It may be overwritten to recycle a particle.
  22751. * The SPS doesn't call this function, you may have to call it by your own.
  22752. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22753. * @param particle The particle to recycle
  22754. * @returns the recycled particle
  22755. */
  22756. recycleParticle(particle: SolidParticle): SolidParticle;
  22757. /**
  22758. * Updates a particle : this function should be overwritten by the user.
  22759. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  22760. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22761. * @example : just set a particle position or velocity and recycle conditions
  22762. * @param particle The particle to update
  22763. * @returns the updated particle
  22764. */
  22765. updateParticle(particle: SolidParticle): SolidParticle;
  22766. /**
  22767. * Updates a vertex of a particle : it can be overwritten by the user.
  22768. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  22769. * @param particle the current particle
  22770. * @param vertex the current index of the current particle
  22771. * @param pt the index of the current vertex in the particle shape
  22772. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  22773. * @example : just set a vertex particle position
  22774. * @returns the updated vertex
  22775. */
  22776. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  22777. /**
  22778. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  22779. * This does nothing and may be overwritten by the user.
  22780. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22781. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22782. * @param update the boolean update value actually passed to setParticles()
  22783. */
  22784. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22785. /**
  22786. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  22787. * This will be passed three parameters.
  22788. * This does nothing and may be overwritten by the user.
  22789. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22790. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22791. * @param update the boolean update value actually passed to setParticles()
  22792. */
  22793. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22794. }
  22795. }
  22796. declare module "babylonjs/Particles/solidParticle" {
  22797. import { Nullable } from "babylonjs/types";
  22798. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  22799. import { Mesh } from "babylonjs/Meshes/mesh";
  22800. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22801. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  22802. /**
  22803. * Represents one particle of a solid particle system.
  22804. */
  22805. export class SolidParticle {
  22806. /**
  22807. * particle global index
  22808. */
  22809. idx: number;
  22810. /**
  22811. * The color of the particle
  22812. */
  22813. color: Nullable<Color4>;
  22814. /**
  22815. * The world space position of the particle.
  22816. */
  22817. position: Vector3;
  22818. /**
  22819. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  22820. */
  22821. rotation: Vector3;
  22822. /**
  22823. * The world space rotation quaternion of the particle.
  22824. */
  22825. rotationQuaternion: Nullable<Quaternion>;
  22826. /**
  22827. * The scaling of the particle.
  22828. */
  22829. scaling: Vector3;
  22830. /**
  22831. * The uvs of the particle.
  22832. */
  22833. uvs: Vector4;
  22834. /**
  22835. * The current speed of the particle.
  22836. */
  22837. velocity: Vector3;
  22838. /**
  22839. * The pivot point in the particle local space.
  22840. */
  22841. pivot: Vector3;
  22842. /**
  22843. * Must the particle be translated from its pivot point in its local space ?
  22844. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  22845. * Default : false
  22846. */
  22847. translateFromPivot: boolean;
  22848. /**
  22849. * Is the particle active or not ?
  22850. */
  22851. alive: boolean;
  22852. /**
  22853. * Is the particle visible or not ?
  22854. */
  22855. isVisible: boolean;
  22856. /**
  22857. * Index of this particle in the global "positions" array (Internal use)
  22858. * @hidden
  22859. */
  22860. _pos: number;
  22861. /**
  22862. * @hidden Index of this particle in the global "indices" array (Internal use)
  22863. */
  22864. _ind: number;
  22865. /**
  22866. * @hidden ModelShape of this particle (Internal use)
  22867. */
  22868. _model: ModelShape;
  22869. /**
  22870. * ModelShape id of this particle
  22871. */
  22872. shapeId: number;
  22873. /**
  22874. * Index of the particle in its shape id (Internal use)
  22875. */
  22876. idxInShape: number;
  22877. /**
  22878. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  22879. */
  22880. _modelBoundingInfo: BoundingInfo;
  22881. /**
  22882. * @hidden Particle BoundingInfo object (Internal use)
  22883. */
  22884. _boundingInfo: BoundingInfo;
  22885. /**
  22886. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  22887. */
  22888. _sps: SolidParticleSystem;
  22889. /**
  22890. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  22891. */
  22892. _stillInvisible: boolean;
  22893. /**
  22894. * @hidden Last computed particle rotation matrix
  22895. */
  22896. _rotationMatrix: number[];
  22897. /**
  22898. * Parent particle Id, if any.
  22899. * Default null.
  22900. */
  22901. parentId: Nullable<number>;
  22902. /**
  22903. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  22904. * The possible values are :
  22905. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  22906. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22907. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  22908. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  22909. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22910. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  22911. * */
  22912. cullingStrategy: number;
  22913. /**
  22914. * @hidden Internal global position in the SPS.
  22915. */
  22916. _globalPosition: Vector3;
  22917. /**
  22918. * Creates a Solid Particle object.
  22919. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  22920. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  22921. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  22922. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  22923. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  22924. * @param shapeId (integer) is the model shape identifier in the SPS.
  22925. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  22926. * @param sps defines the sps it is associated to
  22927. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  22928. */
  22929. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  22930. /**
  22931. * Legacy support, changed scale to scaling
  22932. */
  22933. /**
  22934. * Legacy support, changed scale to scaling
  22935. */
  22936. scale: Vector3;
  22937. /**
  22938. * Legacy support, changed quaternion to rotationQuaternion
  22939. */
  22940. /**
  22941. * Legacy support, changed quaternion to rotationQuaternion
  22942. */
  22943. quaternion: Nullable<Quaternion>;
  22944. /**
  22945. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  22946. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  22947. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  22948. * @returns true if it intersects
  22949. */
  22950. intersectsMesh(target: Mesh | SolidParticle): boolean;
  22951. /**
  22952. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  22953. * A particle is in the frustum if its bounding box intersects the frustum
  22954. * @param frustumPlanes defines the frustum to test
  22955. * @returns true if the particle is in the frustum planes
  22956. */
  22957. isInFrustum(frustumPlanes: Plane[]): boolean;
  22958. /**
  22959. * get the rotation matrix of the particle
  22960. * @hidden
  22961. */
  22962. getRotationMatrix(m: Matrix): void;
  22963. }
  22964. /**
  22965. * Represents the shape of the model used by one particle of a solid particle system.
  22966. * SPS internal tool, don't use it manually.
  22967. */
  22968. export class ModelShape {
  22969. /**
  22970. * The shape id
  22971. * @hidden
  22972. */
  22973. shapeID: number;
  22974. /**
  22975. * flat array of model positions (internal use)
  22976. * @hidden
  22977. */
  22978. _shape: Vector3[];
  22979. /**
  22980. * flat array of model UVs (internal use)
  22981. * @hidden
  22982. */
  22983. _shapeUV: number[];
  22984. /**
  22985. * length of the shape in the model indices array (internal use)
  22986. * @hidden
  22987. */
  22988. _indicesLength: number;
  22989. /**
  22990. * Custom position function (internal use)
  22991. * @hidden
  22992. */
  22993. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  22994. /**
  22995. * Custom vertex function (internal use)
  22996. * @hidden
  22997. */
  22998. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  22999. /**
  23000. * 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.
  23001. * SPS internal tool, don't use it manually.
  23002. * @hidden
  23003. */
  23004. 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>);
  23005. }
  23006. /**
  23007. * Represents a Depth Sorted Particle in the solid particle system.
  23008. */
  23009. export class DepthSortedParticle {
  23010. /**
  23011. * Index of the particle in the "indices" array
  23012. */
  23013. ind: number;
  23014. /**
  23015. * Length of the particle shape in the "indices" array
  23016. */
  23017. indicesLength: number;
  23018. /**
  23019. * Squared distance from the particle to the camera
  23020. */
  23021. sqDistance: number;
  23022. }
  23023. }
  23024. declare module "babylonjs/Meshes/abstractMesh" {
  23025. import { Observable } from "babylonjs/Misc/observable";
  23026. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23027. import { Camera } from "babylonjs/Cameras/camera";
  23028. import { Scene, IDisposable } from "babylonjs/scene";
  23029. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23030. import { Node } from "babylonjs/node";
  23031. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23032. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23033. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23034. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23035. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23036. import { Material } from "babylonjs/Materials/material";
  23037. import { Light } from "babylonjs/Lights/light";
  23038. import { Skeleton } from "babylonjs/Bones/skeleton";
  23039. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23040. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23041. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23042. import { Ray } from "babylonjs/Culling/ray";
  23043. import { Collider } from "babylonjs/Collisions/collider";
  23044. /**
  23045. * Class used to store all common mesh properties
  23046. */
  23047. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23048. /** No occlusion */
  23049. static OCCLUSION_TYPE_NONE: number;
  23050. /** Occlusion set to optimisitic */
  23051. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23052. /** Occlusion set to strict */
  23053. static OCCLUSION_TYPE_STRICT: number;
  23054. /** Use an accurante occlusion algorithm */
  23055. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23056. /** Use a conservative occlusion algorithm */
  23057. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23058. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23059. * Test order :
  23060. * Is the bounding sphere outside the frustum ?
  23061. * If not, are the bounding box vertices outside the frustum ?
  23062. * It not, then the cullable object is in the frustum.
  23063. */
  23064. static readonly CULLINGSTRATEGY_STANDARD: number;
  23065. /** Culling strategy : Bounding Sphere Only.
  23066. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23067. * It's also less accurate than the standard because some not visible objects can still be selected.
  23068. * Test : is the bounding sphere outside the frustum ?
  23069. * If not, then the cullable object is in the frustum.
  23070. */
  23071. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23072. /** Culling strategy : Optimistic Inclusion.
  23073. * This in an inclusion test first, then the standard exclusion test.
  23074. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23075. * 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.
  23076. * Anyway, it's as accurate as the standard strategy.
  23077. * Test :
  23078. * Is the cullable object bounding sphere center in the frustum ?
  23079. * If not, apply the default culling strategy.
  23080. */
  23081. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23082. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23083. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23084. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23085. * 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.
  23086. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23087. * Test :
  23088. * Is the cullable object bounding sphere center in the frustum ?
  23089. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23090. */
  23091. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23092. /**
  23093. * No billboard
  23094. */
  23095. static readonly BILLBOARDMODE_NONE: number;
  23096. /** Billboard on X axis */
  23097. static readonly BILLBOARDMODE_X: number;
  23098. /** Billboard on Y axis */
  23099. static readonly BILLBOARDMODE_Y: number;
  23100. /** Billboard on Z axis */
  23101. static readonly BILLBOARDMODE_Z: number;
  23102. /** Billboard on all axes */
  23103. static readonly BILLBOARDMODE_ALL: number;
  23104. private _facetData;
  23105. /**
  23106. * The culling strategy to use to check whether the mesh must be rendered or not.
  23107. * This value can be changed at any time and will be used on the next render mesh selection.
  23108. * The possible values are :
  23109. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23110. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23111. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23112. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23113. * Please read each static variable documentation to get details about the culling process.
  23114. * */
  23115. cullingStrategy: number;
  23116. /**
  23117. * Gets the number of facets in the mesh
  23118. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23119. */
  23120. readonly facetNb: number;
  23121. /**
  23122. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23123. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23124. */
  23125. partitioningSubdivisions: number;
  23126. /**
  23127. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23128. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23129. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23130. */
  23131. partitioningBBoxRatio: number;
  23132. /**
  23133. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23134. * Works only for updatable meshes.
  23135. * Doesn't work with multi-materials
  23136. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23137. */
  23138. mustDepthSortFacets: boolean;
  23139. /**
  23140. * The location (Vector3) where the facet depth sort must be computed from.
  23141. * By default, the active camera position.
  23142. * Used only when facet depth sort is enabled
  23143. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23144. */
  23145. facetDepthSortFrom: Vector3;
  23146. /**
  23147. * gets a boolean indicating if facetData is enabled
  23148. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23149. */
  23150. readonly isFacetDataEnabled: boolean;
  23151. /** @hidden */
  23152. _updateNonUniformScalingState(value: boolean): boolean;
  23153. /**
  23154. * An event triggered when this mesh collides with another one
  23155. */
  23156. onCollideObservable: Observable<AbstractMesh>;
  23157. private _onCollideObserver;
  23158. /** Set a function to call when this mesh collides with another one */
  23159. onCollide: () => void;
  23160. /**
  23161. * An event triggered when the collision's position changes
  23162. */
  23163. onCollisionPositionChangeObservable: Observable<Vector3>;
  23164. private _onCollisionPositionChangeObserver;
  23165. /** Set a function to call when the collision's position changes */
  23166. onCollisionPositionChange: () => void;
  23167. /**
  23168. * An event triggered when material is changed
  23169. */
  23170. onMaterialChangedObservable: Observable<AbstractMesh>;
  23171. /**
  23172. * Gets or sets the orientation for POV movement & rotation
  23173. */
  23174. definedFacingForward: boolean;
  23175. /** @hidden */
  23176. _occlusionQuery: Nullable<WebGLQuery>;
  23177. private _visibility;
  23178. /**
  23179. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23180. */
  23181. /**
  23182. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23183. */
  23184. visibility: number;
  23185. /** Gets or sets the alpha index used to sort transparent meshes
  23186. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23187. */
  23188. alphaIndex: number;
  23189. /**
  23190. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23191. */
  23192. isVisible: boolean;
  23193. /**
  23194. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23195. */
  23196. isPickable: boolean;
  23197. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23198. showSubMeshesBoundingBox: boolean;
  23199. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23200. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23201. */
  23202. isBlocker: boolean;
  23203. /**
  23204. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23205. */
  23206. enablePointerMoveEvents: boolean;
  23207. /**
  23208. * Specifies the rendering group id for this mesh (0 by default)
  23209. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23210. */
  23211. renderingGroupId: number;
  23212. private _material;
  23213. /** Gets or sets current material */
  23214. material: Nullable<Material>;
  23215. private _receiveShadows;
  23216. /**
  23217. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23218. * @see http://doc.babylonjs.com/babylon101/shadows
  23219. */
  23220. receiveShadows: boolean;
  23221. /** Defines color to use when rendering outline */
  23222. outlineColor: Color3;
  23223. /** Define width to use when rendering outline */
  23224. outlineWidth: number;
  23225. /** Defines color to use when rendering overlay */
  23226. overlayColor: Color3;
  23227. /** Defines alpha to use when rendering overlay */
  23228. overlayAlpha: number;
  23229. private _hasVertexAlpha;
  23230. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23231. hasVertexAlpha: boolean;
  23232. private _useVertexColors;
  23233. /** 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) */
  23234. useVertexColors: boolean;
  23235. private _computeBonesUsingShaders;
  23236. /**
  23237. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23238. */
  23239. computeBonesUsingShaders: boolean;
  23240. private _numBoneInfluencers;
  23241. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23242. numBoneInfluencers: number;
  23243. private _applyFog;
  23244. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  23245. applyFog: boolean;
  23246. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  23247. useOctreeForRenderingSelection: boolean;
  23248. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  23249. useOctreeForPicking: boolean;
  23250. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  23251. useOctreeForCollisions: boolean;
  23252. private _layerMask;
  23253. /**
  23254. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  23255. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  23256. */
  23257. layerMask: number;
  23258. /**
  23259. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  23260. */
  23261. alwaysSelectAsActiveMesh: boolean;
  23262. /**
  23263. * Gets or sets the current action manager
  23264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  23265. */
  23266. actionManager: Nullable<AbstractActionManager>;
  23267. private _checkCollisions;
  23268. private _collisionMask;
  23269. private _collisionGroup;
  23270. /**
  23271. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  23272. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23273. */
  23274. ellipsoid: Vector3;
  23275. /**
  23276. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  23277. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23278. */
  23279. ellipsoidOffset: Vector3;
  23280. private _collider;
  23281. private _oldPositionForCollisions;
  23282. private _diffPositionForCollisions;
  23283. /**
  23284. * Gets or sets a collision mask used to mask collisions (default is -1).
  23285. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23286. */
  23287. collisionMask: number;
  23288. /**
  23289. * Gets or sets the current collision group mask (-1 by default).
  23290. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23291. */
  23292. collisionGroup: number;
  23293. /**
  23294. * Defines edge width used when edgesRenderer is enabled
  23295. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23296. */
  23297. edgesWidth: number;
  23298. /**
  23299. * Defines edge color used when edgesRenderer is enabled
  23300. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23301. */
  23302. edgesColor: Color4;
  23303. /** @hidden */
  23304. _edgesRenderer: Nullable<IEdgesRenderer>;
  23305. /** @hidden */
  23306. _masterMesh: Nullable<AbstractMesh>;
  23307. /** @hidden */
  23308. _boundingInfo: Nullable<BoundingInfo>;
  23309. /** @hidden */
  23310. _renderId: number;
  23311. /**
  23312. * Gets or sets the list of subMeshes
  23313. * @see http://doc.babylonjs.com/how_to/multi_materials
  23314. */
  23315. subMeshes: SubMesh[];
  23316. /** @hidden */
  23317. _intersectionsInProgress: AbstractMesh[];
  23318. /** @hidden */
  23319. _unIndexed: boolean;
  23320. /** @hidden */
  23321. _lightSources: Light[];
  23322. /** @hidden */
  23323. readonly _positions: Nullable<Vector3[]>;
  23324. /** @hidden */
  23325. _waitingActions: any;
  23326. /** @hidden */
  23327. _waitingFreezeWorldMatrix: Nullable<boolean>;
  23328. private _skeleton;
  23329. /** @hidden */
  23330. _bonesTransformMatrices: Nullable<Float32Array>;
  23331. /**
  23332. * Gets or sets a skeleton to apply skining transformations
  23333. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23334. */
  23335. skeleton: Nullable<Skeleton>;
  23336. /**
  23337. * An event triggered when the mesh is rebuilt.
  23338. */
  23339. onRebuildObservable: Observable<AbstractMesh>;
  23340. /**
  23341. * Creates a new AbstractMesh
  23342. * @param name defines the name of the mesh
  23343. * @param scene defines the hosting scene
  23344. */
  23345. constructor(name: string, scene?: Nullable<Scene>);
  23346. /**
  23347. * Returns the string "AbstractMesh"
  23348. * @returns "AbstractMesh"
  23349. */
  23350. getClassName(): string;
  23351. /**
  23352. * Gets a string representation of the current mesh
  23353. * @param fullDetails defines a boolean indicating if full details must be included
  23354. * @returns a string representation of the current mesh
  23355. */
  23356. toString(fullDetails?: boolean): string;
  23357. /** @hidden */
  23358. _rebuild(): void;
  23359. /** @hidden */
  23360. _resyncLightSources(): void;
  23361. /** @hidden */
  23362. _resyncLighSource(light: Light): void;
  23363. /** @hidden */
  23364. _unBindEffect(): void;
  23365. /** @hidden */
  23366. _removeLightSource(light: Light): void;
  23367. private _markSubMeshesAsDirty;
  23368. /** @hidden */
  23369. _markSubMeshesAsLightDirty(): void;
  23370. /** @hidden */
  23371. _markSubMeshesAsAttributesDirty(): void;
  23372. /** @hidden */
  23373. _markSubMeshesAsMiscDirty(): void;
  23374. /**
  23375. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  23376. */
  23377. scaling: Vector3;
  23378. /**
  23379. * Returns true if the mesh is blocked. Implemented by child classes
  23380. */
  23381. readonly isBlocked: boolean;
  23382. /**
  23383. * Returns the mesh itself by default. Implemented by child classes
  23384. * @param camera defines the camera to use to pick the right LOD level
  23385. * @returns the currentAbstractMesh
  23386. */
  23387. getLOD(camera: Camera): Nullable<AbstractMesh>;
  23388. /**
  23389. * Returns 0 by default. Implemented by child classes
  23390. * @returns an integer
  23391. */
  23392. getTotalVertices(): number;
  23393. /**
  23394. * Returns a positive integer : the total number of indices in this mesh geometry.
  23395. * @returns the numner of indices or zero if the mesh has no geometry.
  23396. */
  23397. getTotalIndices(): number;
  23398. /**
  23399. * Returns null by default. Implemented by child classes
  23400. * @returns null
  23401. */
  23402. getIndices(): Nullable<IndicesArray>;
  23403. /**
  23404. * Returns the array of the requested vertex data kind. Implemented by child classes
  23405. * @param kind defines the vertex data kind to use
  23406. * @returns null
  23407. */
  23408. getVerticesData(kind: string): Nullable<FloatArray>;
  23409. /**
  23410. * Sets the vertex data of the mesh geometry for the requested `kind`.
  23411. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  23412. * Note that a new underlying VertexBuffer object is created each call.
  23413. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  23414. * @param kind defines vertex data kind:
  23415. * * VertexBuffer.PositionKind
  23416. * * VertexBuffer.UVKind
  23417. * * VertexBuffer.UV2Kind
  23418. * * VertexBuffer.UV3Kind
  23419. * * VertexBuffer.UV4Kind
  23420. * * VertexBuffer.UV5Kind
  23421. * * VertexBuffer.UV6Kind
  23422. * * VertexBuffer.ColorKind
  23423. * * VertexBuffer.MatricesIndicesKind
  23424. * * VertexBuffer.MatricesIndicesExtraKind
  23425. * * VertexBuffer.MatricesWeightsKind
  23426. * * VertexBuffer.MatricesWeightsExtraKind
  23427. * @param data defines the data source
  23428. * @param updatable defines if the data must be flagged as updatable (or static)
  23429. * @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
  23430. * @returns the current mesh
  23431. */
  23432. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23433. /**
  23434. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  23435. * If the mesh has no geometry, it is simply returned as it is.
  23436. * @param kind defines vertex data kind:
  23437. * * VertexBuffer.PositionKind
  23438. * * VertexBuffer.UVKind
  23439. * * VertexBuffer.UV2Kind
  23440. * * VertexBuffer.UV3Kind
  23441. * * VertexBuffer.UV4Kind
  23442. * * VertexBuffer.UV5Kind
  23443. * * VertexBuffer.UV6Kind
  23444. * * VertexBuffer.ColorKind
  23445. * * VertexBuffer.MatricesIndicesKind
  23446. * * VertexBuffer.MatricesIndicesExtraKind
  23447. * * VertexBuffer.MatricesWeightsKind
  23448. * * VertexBuffer.MatricesWeightsExtraKind
  23449. * @param data defines the data source
  23450. * @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
  23451. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  23452. * @returns the current mesh
  23453. */
  23454. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23455. /**
  23456. * Sets the mesh indices,
  23457. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  23458. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  23459. * @param totalVertices Defines the total number of vertices
  23460. * @returns the current mesh
  23461. */
  23462. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  23463. /**
  23464. * Gets a boolean indicating if specific vertex data is present
  23465. * @param kind defines the vertex data kind to use
  23466. * @returns true is data kind is present
  23467. */
  23468. isVerticesDataPresent(kind: string): boolean;
  23469. /**
  23470. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  23471. * @returns a BoundingInfo
  23472. */
  23473. getBoundingInfo(): BoundingInfo;
  23474. /**
  23475. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  23476. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  23477. * @returns the current mesh
  23478. */
  23479. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  23480. /**
  23481. * Overwrite the current bounding info
  23482. * @param boundingInfo defines the new bounding info
  23483. * @returns the current mesh
  23484. */
  23485. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  23486. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  23487. readonly useBones: boolean;
  23488. /** @hidden */
  23489. _preActivate(): void;
  23490. /** @hidden */
  23491. _preActivateForIntermediateRendering(renderId: number): void;
  23492. /** @hidden */
  23493. _activate(renderId: number): void;
  23494. /**
  23495. * Gets the current world matrix
  23496. * @returns a Matrix
  23497. */
  23498. getWorldMatrix(): Matrix;
  23499. /** @hidden */
  23500. _getWorldMatrixDeterminant(): number;
  23501. /**
  23502. * Perform relative position change from the point of view of behind the front of the mesh.
  23503. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23504. * Supports definition of mesh facing forward or backward
  23505. * @param amountRight defines the distance on the right axis
  23506. * @param amountUp defines the distance on the up axis
  23507. * @param amountForward defines the distance on the forward axis
  23508. * @returns the current mesh
  23509. */
  23510. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  23511. /**
  23512. * Calculate relative position change from the point of view of behind the front of the mesh.
  23513. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23514. * Supports definition of mesh facing forward or backward
  23515. * @param amountRight defines the distance on the right axis
  23516. * @param amountUp defines the distance on the up axis
  23517. * @param amountForward defines the distance on the forward axis
  23518. * @returns the new displacement vector
  23519. */
  23520. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  23521. /**
  23522. * Perform relative rotation change from the point of view of behind the front of the mesh.
  23523. * Supports definition of mesh facing forward or backward
  23524. * @param flipBack defines the flip
  23525. * @param twirlClockwise defines the twirl
  23526. * @param tiltRight defines the tilt
  23527. * @returns the current mesh
  23528. */
  23529. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  23530. /**
  23531. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  23532. * Supports definition of mesh facing forward or backward.
  23533. * @param flipBack defines the flip
  23534. * @param twirlClockwise defines the twirl
  23535. * @param tiltRight defines the tilt
  23536. * @returns the new rotation vector
  23537. */
  23538. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  23539. /**
  23540. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  23541. * @param includeDescendants Include bounding info from descendants as well (true by default)
  23542. * @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
  23543. * @returns the new bounding vectors
  23544. */
  23545. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  23546. min: Vector3;
  23547. max: Vector3;
  23548. };
  23549. /**
  23550. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23551. * This means the mesh underlying bounding box and sphere are recomputed.
  23552. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23553. * @returns the current mesh
  23554. */
  23555. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  23556. /** @hidden */
  23557. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  23558. /** @hidden */
  23559. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  23560. /** @hidden */
  23561. _updateBoundingInfo(): AbstractMesh;
  23562. /** @hidden */
  23563. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  23564. /** @hidden */
  23565. protected _afterComputeWorldMatrix(): void;
  23566. /**
  23567. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23568. * A mesh is in the frustum if its bounding box intersects the frustum
  23569. * @param frustumPlanes defines the frustum to test
  23570. * @returns true if the mesh is in the frustum planes
  23571. */
  23572. isInFrustum(frustumPlanes: Plane[]): boolean;
  23573. /**
  23574. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  23575. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  23576. * @param frustumPlanes defines the frustum to test
  23577. * @returns true if the mesh is completely in the frustum planes
  23578. */
  23579. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23580. /**
  23581. * True if the mesh intersects another mesh or a SolidParticle object
  23582. * @param mesh defines a target mesh or SolidParticle to test
  23583. * @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)
  23584. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  23585. * @returns true if there is an intersection
  23586. */
  23587. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  23588. /**
  23589. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  23590. * @param point defines the point to test
  23591. * @returns true if there is an intersection
  23592. */
  23593. intersectsPoint(point: Vector3): boolean;
  23594. /**
  23595. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  23596. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23597. */
  23598. checkCollisions: boolean;
  23599. /**
  23600. * Gets Collider object used to compute collisions (not physics)
  23601. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23602. */
  23603. readonly collider: Collider;
  23604. /**
  23605. * Move the mesh using collision engine
  23606. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23607. * @param displacement defines the requested displacement vector
  23608. * @returns the current mesh
  23609. */
  23610. moveWithCollisions(displacement: Vector3): AbstractMesh;
  23611. private _onCollisionPositionChange;
  23612. /** @hidden */
  23613. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  23614. /** @hidden */
  23615. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  23616. /** @hidden */
  23617. _checkCollision(collider: Collider): AbstractMesh;
  23618. /** @hidden */
  23619. _generatePointsArray(): boolean;
  23620. /**
  23621. * Checks if the passed Ray intersects with the mesh
  23622. * @param ray defines the ray to use
  23623. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  23624. * @returns the picking info
  23625. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  23626. */
  23627. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  23628. /**
  23629. * Clones the current mesh
  23630. * @param name defines the mesh name
  23631. * @param newParent defines the new mesh parent
  23632. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  23633. * @returns the new mesh
  23634. */
  23635. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  23636. /**
  23637. * Disposes all the submeshes of the current meshnp
  23638. * @returns the current mesh
  23639. */
  23640. releaseSubMeshes(): AbstractMesh;
  23641. /**
  23642. * Releases resources associated with this abstract mesh.
  23643. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23644. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23645. */
  23646. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23647. /**
  23648. * Adds the passed mesh as a child to the current mesh
  23649. * @param mesh defines the child mesh
  23650. * @returns the current mesh
  23651. */
  23652. addChild(mesh: AbstractMesh): AbstractMesh;
  23653. /**
  23654. * Removes the passed mesh from the current mesh children list
  23655. * @param mesh defines the child mesh
  23656. * @returns the current mesh
  23657. */
  23658. removeChild(mesh: AbstractMesh): AbstractMesh;
  23659. /** @hidden */
  23660. private _initFacetData;
  23661. /**
  23662. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  23663. * This method can be called within the render loop.
  23664. * 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
  23665. * @returns the current mesh
  23666. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23667. */
  23668. updateFacetData(): AbstractMesh;
  23669. /**
  23670. * Returns the facetLocalNormals array.
  23671. * The normals are expressed in the mesh local spac
  23672. * @returns an array of Vector3
  23673. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23674. */
  23675. getFacetLocalNormals(): Vector3[];
  23676. /**
  23677. * Returns the facetLocalPositions array.
  23678. * The facet positions are expressed in the mesh local space
  23679. * @returns an array of Vector3
  23680. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23681. */
  23682. getFacetLocalPositions(): Vector3[];
  23683. /**
  23684. * Returns the facetLocalPartioning array
  23685. * @returns an array of array of numbers
  23686. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23687. */
  23688. getFacetLocalPartitioning(): number[][];
  23689. /**
  23690. * Returns the i-th facet position in the world system.
  23691. * This method allocates a new Vector3 per call
  23692. * @param i defines the facet index
  23693. * @returns a new Vector3
  23694. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23695. */
  23696. getFacetPosition(i: number): Vector3;
  23697. /**
  23698. * Sets the reference Vector3 with the i-th facet position in the world system
  23699. * @param i defines the facet index
  23700. * @param ref defines the target vector
  23701. * @returns the current mesh
  23702. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23703. */
  23704. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  23705. /**
  23706. * Returns the i-th facet normal in the world system.
  23707. * This method allocates a new Vector3 per call
  23708. * @param i defines the facet index
  23709. * @returns a new Vector3
  23710. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23711. */
  23712. getFacetNormal(i: number): Vector3;
  23713. /**
  23714. * Sets the reference Vector3 with the i-th facet normal in the world system
  23715. * @param i defines the facet index
  23716. * @param ref defines the target vector
  23717. * @returns the current mesh
  23718. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23719. */
  23720. getFacetNormalToRef(i: number, ref: Vector3): this;
  23721. /**
  23722. * 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)
  23723. * @param x defines x coordinate
  23724. * @param y defines y coordinate
  23725. * @param z defines z coordinate
  23726. * @returns the array of facet indexes
  23727. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23728. */
  23729. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  23730. /**
  23731. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  23732. * @param projected sets as the (x,y,z) world projection on the facet
  23733. * @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
  23734. * @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
  23735. * @param x defines x coordinate
  23736. * @param y defines y coordinate
  23737. * @param z defines z coordinate
  23738. * @returns the face index if found (or null instead)
  23739. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23740. */
  23741. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23742. /**
  23743. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  23744. * @param projected sets as the (x,y,z) local projection on the facet
  23745. * @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
  23746. * @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
  23747. * @param x defines x coordinate
  23748. * @param y defines y coordinate
  23749. * @param z defines z coordinate
  23750. * @returns the face index if found (or null instead)
  23751. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23752. */
  23753. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23754. /**
  23755. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  23756. * @returns the parameters
  23757. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23758. */
  23759. getFacetDataParameters(): any;
  23760. /**
  23761. * Disables the feature FacetData and frees the related memory
  23762. * @returns the current mesh
  23763. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23764. */
  23765. disableFacetData(): AbstractMesh;
  23766. /**
  23767. * Updates the AbstractMesh indices array
  23768. * @param indices defines the data source
  23769. * @returns the current mesh
  23770. */
  23771. updateIndices(indices: IndicesArray): AbstractMesh;
  23772. /**
  23773. * Creates new normals data for the mesh
  23774. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  23775. * @returns the current mesh
  23776. */
  23777. createNormals(updatable: boolean): AbstractMesh;
  23778. /**
  23779. * Align the mesh with a normal
  23780. * @param normal defines the normal to use
  23781. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  23782. * @returns the current mesh
  23783. */
  23784. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  23785. /** @hidden */
  23786. _checkOcclusionQuery(): boolean;
  23787. }
  23788. }
  23789. declare module "babylonjs/Bones/skeleton" {
  23790. import { Bone } from "babylonjs/Bones/bone";
  23791. import { IAnimatable } from "babylonjs/Misc/tools";
  23792. import { Observable } from "babylonjs/Misc/observable";
  23793. import { Vector3, Matrix } from "babylonjs/Maths/math";
  23794. import { Scene } from "babylonjs/scene";
  23795. import { Nullable } from "babylonjs/types";
  23796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23797. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  23798. import { Animatable } from "babylonjs/Animations/animatable";
  23799. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23800. import { Animation } from "babylonjs/Animations/animation";
  23801. import { AnimationRange } from "babylonjs/Animations/animationRange";
  23802. /**
  23803. * Class used to handle skinning animations
  23804. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23805. */
  23806. export class Skeleton implements IAnimatable {
  23807. /** defines the skeleton name */
  23808. name: string;
  23809. /** defines the skeleton Id */
  23810. id: string;
  23811. /**
  23812. * Defines the list of child bones
  23813. */
  23814. bones: Bone[];
  23815. /**
  23816. * Defines an estimate of the dimension of the skeleton at rest
  23817. */
  23818. dimensionsAtRest: Vector3;
  23819. /**
  23820. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  23821. */
  23822. needInitialSkinMatrix: boolean;
  23823. /**
  23824. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  23825. */
  23826. overrideMesh: Nullable<AbstractMesh>;
  23827. /**
  23828. * Gets the list of animations attached to this skeleton
  23829. */
  23830. animations: Array<Animation>;
  23831. private _scene;
  23832. private _isDirty;
  23833. private _transformMatrices;
  23834. private _transformMatrixTexture;
  23835. private _meshesWithPoseMatrix;
  23836. private _animatables;
  23837. private _identity;
  23838. private _synchronizedWithMesh;
  23839. private _ranges;
  23840. private _lastAbsoluteTransformsUpdateId;
  23841. private _canUseTextureForBones;
  23842. /** @hidden */
  23843. _numBonesWithLinkedTransformNode: number;
  23844. /**
  23845. * Specifies if the skeleton should be serialized
  23846. */
  23847. doNotSerialize: boolean;
  23848. /**
  23849. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  23850. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  23851. */
  23852. useTextureToStoreBoneMatrices: boolean;
  23853. private _animationPropertiesOverride;
  23854. /**
  23855. * Gets or sets the animation properties override
  23856. */
  23857. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23858. /**
  23859. * An observable triggered before computing the skeleton's matrices
  23860. */
  23861. onBeforeComputeObservable: Observable<Skeleton>;
  23862. /**
  23863. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  23864. */
  23865. readonly isUsingTextureForMatrices: boolean;
  23866. /**
  23867. * Creates a new skeleton
  23868. * @param name defines the skeleton name
  23869. * @param id defines the skeleton Id
  23870. * @param scene defines the hosting scene
  23871. */
  23872. constructor(
  23873. /** defines the skeleton name */
  23874. name: string,
  23875. /** defines the skeleton Id */
  23876. id: string, scene: Scene);
  23877. /**
  23878. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  23879. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  23880. * @returns a Float32Array containing matrices data
  23881. */
  23882. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  23883. /**
  23884. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  23885. * @returns a raw texture containing the data
  23886. */
  23887. getTransformMatrixTexture(): Nullable<RawTexture>;
  23888. /**
  23889. * Gets the current hosting scene
  23890. * @returns a scene object
  23891. */
  23892. getScene(): Scene;
  23893. /**
  23894. * Gets a string representing the current skeleton data
  23895. * @param fullDetails defines a boolean indicating if we want a verbose version
  23896. * @returns a string representing the current skeleton data
  23897. */
  23898. toString(fullDetails?: boolean): string;
  23899. /**
  23900. * Get bone's index searching by name
  23901. * @param name defines bone's name to search for
  23902. * @return the indice of the bone. Returns -1 if not found
  23903. */
  23904. getBoneIndexByName(name: string): number;
  23905. /**
  23906. * Creater a new animation range
  23907. * @param name defines the name of the range
  23908. * @param from defines the start key
  23909. * @param to defines the end key
  23910. */
  23911. createAnimationRange(name: string, from: number, to: number): void;
  23912. /**
  23913. * Delete a specific animation range
  23914. * @param name defines the name of the range
  23915. * @param deleteFrames defines if frames must be removed as well
  23916. */
  23917. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  23918. /**
  23919. * Gets a specific animation range
  23920. * @param name defines the name of the range to look for
  23921. * @returns the requested animation range or null if not found
  23922. */
  23923. getAnimationRange(name: string): Nullable<AnimationRange>;
  23924. /**
  23925. * Gets the list of all animation ranges defined on this skeleton
  23926. * @returns an array
  23927. */
  23928. getAnimationRanges(): Nullable<AnimationRange>[];
  23929. /**
  23930. * Copy animation range from a source skeleton.
  23931. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  23932. * @param source defines the source skeleton
  23933. * @param name defines the name of the range to copy
  23934. * @param rescaleAsRequired defines if rescaling must be applied if required
  23935. * @returns true if operation was successful
  23936. */
  23937. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  23938. /**
  23939. * Forces the skeleton to go to rest pose
  23940. */
  23941. returnToRest(): void;
  23942. private _getHighestAnimationFrame;
  23943. /**
  23944. * Begin a specific animation range
  23945. * @param name defines the name of the range to start
  23946. * @param loop defines if looping must be turned on (false by default)
  23947. * @param speedRatio defines the speed ratio to apply (1 by default)
  23948. * @param onAnimationEnd defines a callback which will be called when animation will end
  23949. * @returns a new animatable
  23950. */
  23951. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  23952. /** @hidden */
  23953. _markAsDirty(): void;
  23954. /** @hidden */
  23955. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  23956. /** @hidden */
  23957. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  23958. private _computeTransformMatrices;
  23959. /**
  23960. * Build all resources required to render a skeleton
  23961. */
  23962. prepare(): void;
  23963. /**
  23964. * Gets the list of animatables currently running for this skeleton
  23965. * @returns an array of animatables
  23966. */
  23967. getAnimatables(): IAnimatable[];
  23968. /**
  23969. * Clone the current skeleton
  23970. * @param name defines the name of the new skeleton
  23971. * @param id defines the id of the enw skeleton
  23972. * @returns the new skeleton
  23973. */
  23974. clone(name: string, id: string): Skeleton;
  23975. /**
  23976. * Enable animation blending for this skeleton
  23977. * @param blendingSpeed defines the blending speed to apply
  23978. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  23979. */
  23980. enableBlending(blendingSpeed?: number): void;
  23981. /**
  23982. * Releases all resources associated with the current skeleton
  23983. */
  23984. dispose(): void;
  23985. /**
  23986. * Serialize the skeleton in a JSON object
  23987. * @returns a JSON object
  23988. */
  23989. serialize(): any;
  23990. /**
  23991. * Creates a new skeleton from serialized data
  23992. * @param parsedSkeleton defines the serialized data
  23993. * @param scene defines the hosting scene
  23994. * @returns a new skeleton
  23995. */
  23996. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  23997. /**
  23998. * Compute all node absolute transforms
  23999. * @param forceUpdate defines if computation must be done even if cache is up to date
  24000. */
  24001. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  24002. /**
  24003. * Gets the root pose matrix
  24004. * @returns a matrix
  24005. */
  24006. getPoseMatrix(): Nullable<Matrix>;
  24007. /**
  24008. * Sorts bones per internal index
  24009. */
  24010. sortBones(): void;
  24011. private _sortBones;
  24012. }
  24013. }
  24014. declare module "babylonjs/Bones/bone" {
  24015. import { Skeleton } from "babylonjs/Bones/skeleton";
  24016. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  24017. import { Nullable } from "babylonjs/types";
  24018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24019. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24020. import { Node } from "babylonjs/node";
  24021. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24022. /**
  24023. * Class used to store bone information
  24024. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24025. */
  24026. export class Bone extends Node {
  24027. /**
  24028. * defines the bone name
  24029. */
  24030. name: string;
  24031. private static _tmpVecs;
  24032. private static _tmpQuat;
  24033. private static _tmpMats;
  24034. /**
  24035. * Gets the list of child bones
  24036. */
  24037. children: Bone[];
  24038. /** Gets the animations associated with this bone */
  24039. animations: import("babylonjs/Animations/animation").Animation[];
  24040. /**
  24041. * Gets or sets bone length
  24042. */
  24043. length: number;
  24044. /**
  24045. * @hidden Internal only
  24046. * Set this value to map this bone to a different index in the transform matrices
  24047. * Set this value to -1 to exclude the bone from the transform matrices
  24048. */
  24049. _index: Nullable<number>;
  24050. private _skeleton;
  24051. private _localMatrix;
  24052. private _restPose;
  24053. private _baseMatrix;
  24054. private _absoluteTransform;
  24055. private _invertedAbsoluteTransform;
  24056. private _parent;
  24057. private _scalingDeterminant;
  24058. private _worldTransform;
  24059. private _localScaling;
  24060. private _localRotation;
  24061. private _localPosition;
  24062. private _needToDecompose;
  24063. private _needToCompose;
  24064. /** @hidden */
  24065. _linkedTransformNode: Nullable<TransformNode>;
  24066. /** @hidden */
  24067. /** @hidden */
  24068. _matrix: Matrix;
  24069. /**
  24070. * Create a new bone
  24071. * @param name defines the bone name
  24072. * @param skeleton defines the parent skeleton
  24073. * @param parentBone defines the parent (can be null if the bone is the root)
  24074. * @param localMatrix defines the local matrix
  24075. * @param restPose defines the rest pose matrix
  24076. * @param baseMatrix defines the base matrix
  24077. * @param index defines index of the bone in the hiearchy
  24078. */
  24079. constructor(
  24080. /**
  24081. * defines the bone name
  24082. */
  24083. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  24084. /**
  24085. * Gets the parent skeleton
  24086. * @returns a skeleton
  24087. */
  24088. getSkeleton(): Skeleton;
  24089. /**
  24090. * Gets parent bone
  24091. * @returns a bone or null if the bone is the root of the bone hierarchy
  24092. */
  24093. getParent(): Nullable<Bone>;
  24094. /**
  24095. * Sets the parent bone
  24096. * @param parent defines the parent (can be null if the bone is the root)
  24097. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  24098. */
  24099. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  24100. /**
  24101. * Gets the local matrix
  24102. * @returns a matrix
  24103. */
  24104. getLocalMatrix(): Matrix;
  24105. /**
  24106. * Gets the base matrix (initial matrix which remains unchanged)
  24107. * @returns a matrix
  24108. */
  24109. getBaseMatrix(): Matrix;
  24110. /**
  24111. * Gets the rest pose matrix
  24112. * @returns a matrix
  24113. */
  24114. getRestPose(): Matrix;
  24115. /**
  24116. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  24117. */
  24118. getWorldMatrix(): Matrix;
  24119. /**
  24120. * Sets the local matrix to rest pose matrix
  24121. */
  24122. returnToRest(): void;
  24123. /**
  24124. * Gets the inverse of the absolute transform matrix.
  24125. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  24126. * @returns a matrix
  24127. */
  24128. getInvertedAbsoluteTransform(): Matrix;
  24129. /**
  24130. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  24131. * @returns a matrix
  24132. */
  24133. getAbsoluteTransform(): Matrix;
  24134. /**
  24135. * Links with the given transform node.
  24136. * The local matrix of this bone is copied from the transform node every frame.
  24137. * @param transformNode defines the transform node to link to
  24138. */
  24139. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  24140. /** Gets or sets current position (in local space) */
  24141. position: Vector3;
  24142. /** Gets or sets current rotation (in local space) */
  24143. rotation: Vector3;
  24144. /** Gets or sets current rotation quaternion (in local space) */
  24145. rotationQuaternion: Quaternion;
  24146. /** Gets or sets current scaling (in local space) */
  24147. scaling: Vector3;
  24148. /**
  24149. * Gets the animation properties override
  24150. */
  24151. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24152. private _decompose;
  24153. private _compose;
  24154. /**
  24155. * Update the base and local matrices
  24156. * @param matrix defines the new base or local matrix
  24157. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  24158. * @param updateLocalMatrix defines if the local matrix should be updated
  24159. */
  24160. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  24161. /** @hidden */
  24162. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  24163. /**
  24164. * Flag the bone as dirty (Forcing it to update everything)
  24165. */
  24166. markAsDirty(): void;
  24167. private _markAsDirtyAndCompose;
  24168. private _markAsDirtyAndDecompose;
  24169. /**
  24170. * Translate the bone in local or world space
  24171. * @param vec The amount to translate the bone
  24172. * @param space The space that the translation is in
  24173. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24174. */
  24175. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  24176. /**
  24177. * Set the postion of the bone in local or world space
  24178. * @param position The position to set the bone
  24179. * @param space The space that the position is in
  24180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24181. */
  24182. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  24183. /**
  24184. * Set the absolute position of the bone (world space)
  24185. * @param position The position to set the bone
  24186. * @param mesh The mesh that this bone is attached to
  24187. */
  24188. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  24189. /**
  24190. * Scale the bone on the x, y and z axes (in local space)
  24191. * @param x The amount to scale the bone on the x axis
  24192. * @param y The amount to scale the bone on the y axis
  24193. * @param z The amount to scale the bone on the z axis
  24194. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  24195. */
  24196. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  24197. /**
  24198. * Set the bone scaling in local space
  24199. * @param scale defines the scaling vector
  24200. */
  24201. setScale(scale: Vector3): void;
  24202. /**
  24203. * Gets the current scaling in local space
  24204. * @returns the current scaling vector
  24205. */
  24206. getScale(): Vector3;
  24207. /**
  24208. * Gets the current scaling in local space and stores it in a target vector
  24209. * @param result defines the target vector
  24210. */
  24211. getScaleToRef(result: Vector3): void;
  24212. /**
  24213. * Set the yaw, pitch, and roll of the bone in local or world space
  24214. * @param yaw The rotation of the bone on the y axis
  24215. * @param pitch The rotation of the bone on the x axis
  24216. * @param roll The rotation of the bone on the z axis
  24217. * @param space The space that the axes of rotation are in
  24218. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24219. */
  24220. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  24221. /**
  24222. * Add a rotation to the bone on an axis in local or world space
  24223. * @param axis The axis to rotate the bone on
  24224. * @param amount The amount to rotate the bone
  24225. * @param space The space that the axis is in
  24226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24227. */
  24228. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  24229. /**
  24230. * Set the rotation of the bone to a particular axis angle in local or world space
  24231. * @param axis The axis to rotate the bone on
  24232. * @param angle The angle that the bone should be rotated to
  24233. * @param space The space that the axis is in
  24234. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24235. */
  24236. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  24237. /**
  24238. * Set the euler rotation of the bone in local of world space
  24239. * @param rotation The euler rotation that the bone should be set to
  24240. * @param space The space that the rotation is in
  24241. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24242. */
  24243. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  24244. /**
  24245. * Set the quaternion rotation of the bone in local of world space
  24246. * @param quat The quaternion rotation that the bone should be set to
  24247. * @param space The space that the rotation is in
  24248. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24249. */
  24250. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  24251. /**
  24252. * Set the rotation matrix of the bone in local of world space
  24253. * @param rotMat The rotation matrix that the bone should be set to
  24254. * @param space The space that the rotation is in
  24255. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24256. */
  24257. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  24258. private _rotateWithMatrix;
  24259. private _getNegativeRotationToRef;
  24260. /**
  24261. * Get the position of the bone in local or world space
  24262. * @param space The space that the returned position is in
  24263. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24264. * @returns The position of the bone
  24265. */
  24266. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  24267. /**
  24268. * Copy the position of the bone to a vector3 in local or world space
  24269. * @param space The space that the returned position is in
  24270. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24271. * @param result The vector3 to copy the position to
  24272. */
  24273. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  24274. /**
  24275. * Get the absolute position of the bone (world space)
  24276. * @param mesh The mesh that this bone is attached to
  24277. * @returns The absolute position of the bone
  24278. */
  24279. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  24280. /**
  24281. * Copy the absolute position of the bone (world space) to the result param
  24282. * @param mesh The mesh that this bone is attached to
  24283. * @param result The vector3 to copy the absolute position to
  24284. */
  24285. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  24286. /**
  24287. * Compute the absolute transforms of this bone and its children
  24288. */
  24289. computeAbsoluteTransforms(): void;
  24290. /**
  24291. * Get the world direction from an axis that is in the local space of the bone
  24292. * @param localAxis The local direction that is used to compute the world direction
  24293. * @param mesh The mesh that this bone is attached to
  24294. * @returns The world direction
  24295. */
  24296. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  24297. /**
  24298. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  24299. * @param localAxis The local direction that is used to compute the world direction
  24300. * @param mesh The mesh that this bone is attached to
  24301. * @param result The vector3 that the world direction will be copied to
  24302. */
  24303. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  24304. /**
  24305. * Get the euler rotation of the bone in local or world space
  24306. * @param space The space that the rotation should be in
  24307. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24308. * @returns The euler rotation
  24309. */
  24310. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  24311. /**
  24312. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  24313. * @param space The space that the rotation should be in
  24314. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24315. * @param result The vector3 that the rotation should be copied to
  24316. */
  24317. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  24318. /**
  24319. * Get the quaternion rotation of the bone in either local or world space
  24320. * @param space The space that the rotation should be in
  24321. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24322. * @returns The quaternion rotation
  24323. */
  24324. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  24325. /**
  24326. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  24327. * @param space The space that the rotation should be in
  24328. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24329. * @param result The quaternion that the rotation should be copied to
  24330. */
  24331. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  24332. /**
  24333. * Get the rotation matrix of the bone in local or world space
  24334. * @param space The space that the rotation should be in
  24335. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24336. * @returns The rotation matrix
  24337. */
  24338. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  24339. /**
  24340. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  24341. * @param space The space that the rotation should be in
  24342. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24343. * @param result The quaternion that the rotation should be copied to
  24344. */
  24345. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  24346. /**
  24347. * Get the world position of a point that is in the local space of the bone
  24348. * @param position The local position
  24349. * @param mesh The mesh that this bone is attached to
  24350. * @returns The world position
  24351. */
  24352. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  24353. /**
  24354. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  24355. * @param position The local position
  24356. * @param mesh The mesh that this bone is attached to
  24357. * @param result The vector3 that the world position should be copied to
  24358. */
  24359. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  24360. /**
  24361. * Get the local position of a point that is in world space
  24362. * @param position The world position
  24363. * @param mesh The mesh that this bone is attached to
  24364. * @returns The local position
  24365. */
  24366. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  24367. /**
  24368. * Get the local position of a point that is in world space and copy it to the result param
  24369. * @param position The world position
  24370. * @param mesh The mesh that this bone is attached to
  24371. * @param result The vector3 that the local position should be copied to
  24372. */
  24373. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  24374. }
  24375. }
  24376. declare module "babylonjs/Animations/animatable" {
  24377. import { Animation } from "babylonjs/Animations/animation";
  24378. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  24379. import { Nullable } from "babylonjs/types";
  24380. import { Observable } from "babylonjs/Misc/observable";
  24381. import { Scene } from "babylonjs/scene";
  24382. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  24383. import { Node } from "babylonjs/node";
  24384. /**
  24385. * Class used to store an actual running animation
  24386. */
  24387. export class Animatable {
  24388. /** defines the target object */
  24389. target: any;
  24390. /** defines the starting frame number (default is 0) */
  24391. fromFrame: number;
  24392. /** defines the ending frame number (default is 100) */
  24393. toFrame: number;
  24394. /** defines if the animation must loop (default is false) */
  24395. loopAnimation: boolean;
  24396. /** defines a callback to call when animation ends if it is not looping */
  24397. onAnimationEnd?: (() => void) | null | undefined;
  24398. /** defines a callback to call when animation loops */
  24399. onAnimationLoop?: (() => void) | null | undefined;
  24400. private _localDelayOffset;
  24401. private _pausedDelay;
  24402. private _runtimeAnimations;
  24403. private _paused;
  24404. private _scene;
  24405. private _speedRatio;
  24406. private _weight;
  24407. private _syncRoot;
  24408. /**
  24409. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  24410. * This will only apply for non looping animation (default is true)
  24411. */
  24412. disposeOnEnd: boolean;
  24413. /**
  24414. * Gets a boolean indicating if the animation has started
  24415. */
  24416. animationStarted: boolean;
  24417. /**
  24418. * Observer raised when the animation ends
  24419. */
  24420. onAnimationEndObservable: Observable<Animatable>;
  24421. /**
  24422. * Observer raised when the animation loops
  24423. */
  24424. onAnimationLoopObservable: Observable<Animatable>;
  24425. /**
  24426. * Gets the root Animatable used to synchronize and normalize animations
  24427. */
  24428. readonly syncRoot: Animatable;
  24429. /**
  24430. * Gets the current frame of the first RuntimeAnimation
  24431. * Used to synchronize Animatables
  24432. */
  24433. readonly masterFrame: number;
  24434. /**
  24435. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  24436. */
  24437. weight: number;
  24438. /**
  24439. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  24440. */
  24441. speedRatio: number;
  24442. /**
  24443. * Creates a new Animatable
  24444. * @param scene defines the hosting scene
  24445. * @param target defines the target object
  24446. * @param fromFrame defines the starting frame number (default is 0)
  24447. * @param toFrame defines the ending frame number (default is 100)
  24448. * @param loopAnimation defines if the animation must loop (default is false)
  24449. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  24450. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  24451. * @param animations defines a group of animation to add to the new Animatable
  24452. * @param onAnimationLoop defines a callback to call when animation loops
  24453. */
  24454. constructor(scene: Scene,
  24455. /** defines the target object */
  24456. target: any,
  24457. /** defines the starting frame number (default is 0) */
  24458. fromFrame?: number,
  24459. /** defines the ending frame number (default is 100) */
  24460. toFrame?: number,
  24461. /** defines if the animation must loop (default is false) */
  24462. loopAnimation?: boolean, speedRatio?: number,
  24463. /** defines a callback to call when animation ends if it is not looping */
  24464. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  24465. /** defines a callback to call when animation loops */
  24466. onAnimationLoop?: (() => void) | null | undefined);
  24467. /**
  24468. * Synchronize and normalize current Animatable with a source Animatable
  24469. * This is useful when using animation weights and when animations are not of the same length
  24470. * @param root defines the root Animatable to synchronize with
  24471. * @returns the current Animatable
  24472. */
  24473. syncWith(root: Animatable): Animatable;
  24474. /**
  24475. * Gets the list of runtime animations
  24476. * @returns an array of RuntimeAnimation
  24477. */
  24478. getAnimations(): RuntimeAnimation[];
  24479. /**
  24480. * Adds more animations to the current animatable
  24481. * @param target defines the target of the animations
  24482. * @param animations defines the new animations to add
  24483. */
  24484. appendAnimations(target: any, animations: Animation[]): void;
  24485. /**
  24486. * Gets the source animation for a specific property
  24487. * @param property defines the propertyu to look for
  24488. * @returns null or the source animation for the given property
  24489. */
  24490. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  24491. /**
  24492. * Gets the runtime animation for a specific property
  24493. * @param property defines the propertyu to look for
  24494. * @returns null or the runtime animation for the given property
  24495. */
  24496. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  24497. /**
  24498. * Resets the animatable to its original state
  24499. */
  24500. reset(): void;
  24501. /**
  24502. * Allows the animatable to blend with current running animations
  24503. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  24504. * @param blendingSpeed defines the blending speed to use
  24505. */
  24506. enableBlending(blendingSpeed: number): void;
  24507. /**
  24508. * Disable animation blending
  24509. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  24510. */
  24511. disableBlending(): void;
  24512. /**
  24513. * Jump directly to a given frame
  24514. * @param frame defines the frame to jump to
  24515. */
  24516. goToFrame(frame: number): void;
  24517. /**
  24518. * Pause the animation
  24519. */
  24520. pause(): void;
  24521. /**
  24522. * Restart the animation
  24523. */
  24524. restart(): void;
  24525. private _raiseOnAnimationEnd;
  24526. /**
  24527. * Stop and delete the current animation
  24528. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  24529. * @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)
  24530. */
  24531. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  24532. /**
  24533. * Wait asynchronously for the animation to end
  24534. * @returns a promise which will be fullfilled when the animation ends
  24535. */
  24536. waitAsync(): Promise<Animatable>;
  24537. /** @hidden */
  24538. _animate(delay: number): boolean;
  24539. }
  24540. module "babylonjs/scene" {
  24541. interface Scene {
  24542. /** @hidden */
  24543. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  24544. /** @hidden */
  24545. _processLateAnimationBindingsForMatrices(holder: {
  24546. totalWeight: number;
  24547. animations: RuntimeAnimation[];
  24548. originalValue: Matrix;
  24549. }): any;
  24550. /** @hidden */
  24551. _processLateAnimationBindingsForQuaternions(holder: {
  24552. totalWeight: number;
  24553. animations: RuntimeAnimation[];
  24554. originalValue: Quaternion;
  24555. }, refQuaternion: Quaternion): Quaternion;
  24556. /** @hidden */
  24557. _processLateAnimationBindings(): void;
  24558. /**
  24559. * Will start the animation sequence of a given target
  24560. * @param target defines the target
  24561. * @param from defines from which frame should animation start
  24562. * @param to defines until which frame should animation run.
  24563. * @param weight defines the weight to apply to the animation (1.0 by default)
  24564. * @param loop defines if the animation loops
  24565. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24566. * @param onAnimationEnd defines the function to be executed when the animation ends
  24567. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  24568. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  24569. * @param onAnimationLoop defines the callback to call when an animation loops
  24570. * @returns the animatable object created for this animation
  24571. */
  24572. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  24573. /**
  24574. * Will start the animation sequence of a given target
  24575. * @param target defines the target
  24576. * @param from defines from which frame should animation start
  24577. * @param to defines until which frame should animation run.
  24578. * @param loop defines if the animation loops
  24579. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24580. * @param onAnimationEnd defines the function to be executed when the animation ends
  24581. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  24582. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  24583. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  24584. * @param onAnimationLoop defines the callback to call when an animation loops
  24585. * @returns the animatable object created for this animation
  24586. */
  24587. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  24588. /**
  24589. * Will start the animation sequence of a given target and its hierarchy
  24590. * @param target defines the target
  24591. * @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.
  24592. * @param from defines from which frame should animation start
  24593. * @param to defines until which frame should animation run.
  24594. * @param loop defines if the animation loops
  24595. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24596. * @param onAnimationEnd defines the function to be executed when the animation ends
  24597. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  24598. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  24599. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  24600. * @param onAnimationLoop defines the callback to call when an animation loops
  24601. * @returns the list of created animatables
  24602. */
  24603. 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[];
  24604. /**
  24605. * Begin a new animation on a given node
  24606. * @param target defines the target where the animation will take place
  24607. * @param animations defines the list of animations to start
  24608. * @param from defines the initial value
  24609. * @param to defines the final value
  24610. * @param loop defines if you want animation to loop (off by default)
  24611. * @param speedRatio defines the speed ratio to apply to all animations
  24612. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24613. * @param onAnimationLoop defines the callback to call when an animation loops
  24614. * @returns the list of created animatables
  24615. */
  24616. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  24617. /**
  24618. * Begin a new animation on a given node and its hierarchy
  24619. * @param target defines the root node where the animation will take place
  24620. * @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.
  24621. * @param animations defines the list of animations to start
  24622. * @param from defines the initial value
  24623. * @param to defines the final value
  24624. * @param loop defines if you want animation to loop (off by default)
  24625. * @param speedRatio defines the speed ratio to apply to all animations
  24626. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24627. * @param onAnimationLoop defines the callback to call when an animation loops
  24628. * @returns the list of animatables created for all nodes
  24629. */
  24630. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  24631. /**
  24632. * Gets the animatable associated with a specific target
  24633. * @param target defines the target of the animatable
  24634. * @returns the required animatable if found
  24635. */
  24636. getAnimatableByTarget(target: any): Nullable<Animatable>;
  24637. /**
  24638. * Gets all animatables associated with a given target
  24639. * @param target defines the target to look animatables for
  24640. * @returns an array of Animatables
  24641. */
  24642. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  24643. /**
  24644. * Will stop the animation of the given target
  24645. * @param target - the target
  24646. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  24647. * @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)
  24648. */
  24649. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  24650. /**
  24651. * Stops and removes all animations that have been applied to the scene
  24652. */
  24653. stopAllAnimations(): void;
  24654. }
  24655. }
  24656. module "babylonjs/Bones/bone" {
  24657. interface Bone {
  24658. /**
  24659. * Copy an animation range from another bone
  24660. * @param source defines the source bone
  24661. * @param rangeName defines the range name to copy
  24662. * @param frameOffset defines the frame offset
  24663. * @param rescaleAsRequired defines if rescaling must be applied if required
  24664. * @param skelDimensionsRatio defines the scaling ratio
  24665. * @returns true if operation was successful
  24666. */
  24667. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  24668. }
  24669. }
  24670. }
  24671. declare module "babylonjs/node" {
  24672. import { Scene } from "babylonjs/scene";
  24673. import { Nullable } from "babylonjs/types";
  24674. import { Matrix } from "babylonjs/Maths/math";
  24675. import { Engine } from "babylonjs/Engines/engine";
  24676. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24677. import { Observable } from "babylonjs/Misc/observable";
  24678. import { Animatable } from "babylonjs/Animations/animatable";
  24679. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24680. import { Animation } from "babylonjs/Animations/animation";
  24681. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24682. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24683. /**
  24684. * Defines how a node can be built from a string name.
  24685. */
  24686. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24687. /**
  24688. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24689. */
  24690. export class Node implements IBehaviorAware<Node> {
  24691. /** @hidden */
  24692. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  24693. private static _NodeConstructors;
  24694. /**
  24695. * Add a new node constructor
  24696. * @param type defines the type name of the node to construct
  24697. * @param constructorFunc defines the constructor function
  24698. */
  24699. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24700. /**
  24701. * Returns a node constructor based on type name
  24702. * @param type defines the type name
  24703. * @param name defines the new node name
  24704. * @param scene defines the hosting scene
  24705. * @param options defines optional options to transmit to constructors
  24706. * @returns the new constructor or null
  24707. */
  24708. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24709. /**
  24710. * Gets or sets the name of the node
  24711. */
  24712. name: string;
  24713. /**
  24714. * Gets or sets the id of the node
  24715. */
  24716. id: string;
  24717. /**
  24718. * Gets or sets the unique id of the node
  24719. */
  24720. uniqueId: number;
  24721. /**
  24722. * Gets or sets a string used to store user defined state for the node
  24723. */
  24724. state: string;
  24725. /**
  24726. * Gets or sets an object used to store user defined information for the node
  24727. */
  24728. metadata: any;
  24729. /**
  24730. * For internal use only. Please do not use.
  24731. */
  24732. reservedDataStore: any;
  24733. /**
  24734. * Gets or sets a boolean used to define if the node must be serialized
  24735. */
  24736. doNotSerialize: boolean;
  24737. /** @hidden */
  24738. _isDisposed: boolean;
  24739. /**
  24740. * Gets a list of Animations associated with the node
  24741. */
  24742. animations: import("babylonjs/Animations/animation").Animation[];
  24743. protected _ranges: {
  24744. [name: string]: Nullable<AnimationRange>;
  24745. };
  24746. /**
  24747. * Callback raised when the node is ready to be used
  24748. */
  24749. onReady: (node: Node) => void;
  24750. private _isEnabled;
  24751. private _isParentEnabled;
  24752. private _isReady;
  24753. /** @hidden */
  24754. _currentRenderId: number;
  24755. private _parentRenderId;
  24756. protected _childRenderId: number;
  24757. /** @hidden */
  24758. _waitingParentId: Nullable<string>;
  24759. /** @hidden */
  24760. _scene: Scene;
  24761. /** @hidden */
  24762. _cache: any;
  24763. private _parentNode;
  24764. private _children;
  24765. /** @hidden */
  24766. _worldMatrix: Matrix;
  24767. /** @hidden */
  24768. _worldMatrixDeterminant: number;
  24769. /** @hidden */
  24770. private _sceneRootNodesIndex;
  24771. /**
  24772. * Gets a boolean indicating if the node has been disposed
  24773. * @returns true if the node was disposed
  24774. */
  24775. isDisposed(): boolean;
  24776. /**
  24777. * Gets or sets the parent of the node
  24778. */
  24779. parent: Nullable<Node>;
  24780. private addToSceneRootNodes;
  24781. private removeFromSceneRootNodes;
  24782. private _animationPropertiesOverride;
  24783. /**
  24784. * Gets or sets the animation properties override
  24785. */
  24786. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24787. /**
  24788. * Gets a string idenfifying the name of the class
  24789. * @returns "Node" string
  24790. */
  24791. getClassName(): string;
  24792. /** @hidden */
  24793. readonly _isNode: boolean;
  24794. /**
  24795. * An event triggered when the mesh is disposed
  24796. */
  24797. onDisposeObservable: Observable<Node>;
  24798. private _onDisposeObserver;
  24799. /**
  24800. * Sets a callback that will be raised when the node will be disposed
  24801. */
  24802. onDispose: () => void;
  24803. /**
  24804. * Creates a new Node
  24805. * @param name the name and id to be given to this node
  24806. * @param scene the scene this node will be added to
  24807. * @param addToRootNodes the node will be added to scene.rootNodes
  24808. */
  24809. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24810. /**
  24811. * Gets the scene of the node
  24812. * @returns a scene
  24813. */
  24814. getScene(): Scene;
  24815. /**
  24816. * Gets the engine of the node
  24817. * @returns a Engine
  24818. */
  24819. getEngine(): Engine;
  24820. private _behaviors;
  24821. /**
  24822. * Attach a behavior to the node
  24823. * @see http://doc.babylonjs.com/features/behaviour
  24824. * @param behavior defines the behavior to attach
  24825. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24826. * @returns the current Node
  24827. */
  24828. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24829. /**
  24830. * Remove an attached behavior
  24831. * @see http://doc.babylonjs.com/features/behaviour
  24832. * @param behavior defines the behavior to attach
  24833. * @returns the current Node
  24834. */
  24835. removeBehavior(behavior: Behavior<Node>): Node;
  24836. /**
  24837. * Gets the list of attached behaviors
  24838. * @see http://doc.babylonjs.com/features/behaviour
  24839. */
  24840. readonly behaviors: Behavior<Node>[];
  24841. /**
  24842. * Gets an attached behavior by name
  24843. * @param name defines the name of the behavior to look for
  24844. * @see http://doc.babylonjs.com/features/behaviour
  24845. * @returns null if behavior was not found else the requested behavior
  24846. */
  24847. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24848. /**
  24849. * Returns the latest update of the World matrix
  24850. * @returns a Matrix
  24851. */
  24852. getWorldMatrix(): Matrix;
  24853. /** @hidden */
  24854. _getWorldMatrixDeterminant(): number;
  24855. /**
  24856. * Returns directly the latest state of the mesh World matrix.
  24857. * A Matrix is returned.
  24858. */
  24859. readonly worldMatrixFromCache: Matrix;
  24860. /** @hidden */
  24861. _initCache(): void;
  24862. /** @hidden */
  24863. updateCache(force?: boolean): void;
  24864. /** @hidden */
  24865. _updateCache(ignoreParentClass?: boolean): void;
  24866. /** @hidden */
  24867. _isSynchronized(): boolean;
  24868. /** @hidden */
  24869. _markSyncedWithParent(): void;
  24870. /** @hidden */
  24871. isSynchronizedWithParent(): boolean;
  24872. /** @hidden */
  24873. isSynchronized(): boolean;
  24874. /**
  24875. * Is this node ready to be used/rendered
  24876. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24877. * @return true if the node is ready
  24878. */
  24879. isReady(completeCheck?: boolean): boolean;
  24880. /**
  24881. * Is this node enabled?
  24882. * 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
  24883. * @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
  24884. * @return whether this node (and its parent) is enabled
  24885. */
  24886. isEnabled(checkAncestors?: boolean): boolean;
  24887. /** @hidden */
  24888. protected _syncParentEnabledState(): void;
  24889. /**
  24890. * Set the enabled state of this node
  24891. * @param value defines the new enabled state
  24892. */
  24893. setEnabled(value: boolean): void;
  24894. /**
  24895. * Is this node a descendant of the given node?
  24896. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24897. * @param ancestor defines the parent node to inspect
  24898. * @returns a boolean indicating if this node is a descendant of the given node
  24899. */
  24900. isDescendantOf(ancestor: Node): boolean;
  24901. /** @hidden */
  24902. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24903. /**
  24904. * Will return all nodes that have this node as ascendant
  24905. * @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
  24906. * @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
  24907. * @return all children nodes of all types
  24908. */
  24909. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24910. /**
  24911. * Get all child-meshes of this node
  24912. * @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
  24913. * @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
  24914. * @returns an array of AbstractMesh
  24915. */
  24916. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24917. /**
  24918. * Get all direct children of this node
  24919. * @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
  24920. * @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)
  24921. * @returns an array of Node
  24922. */
  24923. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24924. /** @hidden */
  24925. _setReady(state: boolean): void;
  24926. /**
  24927. * Get an animation by name
  24928. * @param name defines the name of the animation to look for
  24929. * @returns null if not found else the requested animation
  24930. */
  24931. getAnimationByName(name: string): Nullable<Animation>;
  24932. /**
  24933. * Creates an animation range for this node
  24934. * @param name defines the name of the range
  24935. * @param from defines the starting key
  24936. * @param to defines the end key
  24937. */
  24938. createAnimationRange(name: string, from: number, to: number): void;
  24939. /**
  24940. * Delete a specific animation range
  24941. * @param name defines the name of the range to delete
  24942. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24943. */
  24944. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24945. /**
  24946. * Get an animation range by name
  24947. * @param name defines the name of the animation range to look for
  24948. * @returns null if not found else the requested animation range
  24949. */
  24950. getAnimationRange(name: string): Nullable<AnimationRange>;
  24951. /**
  24952. * Will start the animation sequence
  24953. * @param name defines the range frames for animation sequence
  24954. * @param loop defines if the animation should loop (false by default)
  24955. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24956. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24957. * @returns the object created for this animation. If range does not exist, it will return null
  24958. */
  24959. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24960. /**
  24961. * Serialize animation ranges into a JSON compatible object
  24962. * @returns serialization object
  24963. */
  24964. serializeAnimationRanges(): any;
  24965. /**
  24966. * Computes the world matrix of the node
  24967. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24968. * @returns the world matrix
  24969. */
  24970. computeWorldMatrix(force?: boolean): Matrix;
  24971. /**
  24972. * Releases resources associated with this node.
  24973. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24974. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24975. */
  24976. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24977. /**
  24978. * Parse animation range data from a serialization object and store them into a given node
  24979. * @param node defines where to store the animation ranges
  24980. * @param parsedNode defines the serialization object to read data from
  24981. * @param scene defines the hosting scene
  24982. */
  24983. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  24984. }
  24985. }
  24986. declare module "babylonjs/Animations/animation" {
  24987. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  24988. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  24989. import { Nullable } from "babylonjs/types";
  24990. import { Scene } from "babylonjs/scene";
  24991. import { IAnimatable } from "babylonjs/Misc/tools";
  24992. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  24993. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24994. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  24995. import { Node } from "babylonjs/node";
  24996. import { Animatable } from "babylonjs/Animations/animatable";
  24997. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  24998. /**
  24999. * Class used to store any kind of animation
  25000. */
  25001. export class Animation {
  25002. /**Name of the animation */
  25003. name: string;
  25004. /**Property to animate */
  25005. targetProperty: string;
  25006. /**The frames per second of the animation */
  25007. framePerSecond: number;
  25008. /**The data type of the animation */
  25009. dataType: number;
  25010. /**The loop mode of the animation */
  25011. loopMode?: number | undefined;
  25012. /**Specifies if blending should be enabled */
  25013. enableBlending?: boolean | undefined;
  25014. /**
  25015. * Use matrix interpolation instead of using direct key value when animating matrices
  25016. */
  25017. static AllowMatricesInterpolation: boolean;
  25018. /**
  25019. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25020. */
  25021. static AllowMatrixDecomposeForInterpolation: boolean;
  25022. /**
  25023. * Stores the key frames of the animation
  25024. */
  25025. private _keys;
  25026. /**
  25027. * Stores the easing function of the animation
  25028. */
  25029. private _easingFunction;
  25030. /**
  25031. * @hidden Internal use only
  25032. */
  25033. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25034. /**
  25035. * The set of event that will be linked to this animation
  25036. */
  25037. private _events;
  25038. /**
  25039. * Stores an array of target property paths
  25040. */
  25041. targetPropertyPath: string[];
  25042. /**
  25043. * Stores the blending speed of the animation
  25044. */
  25045. blendingSpeed: number;
  25046. /**
  25047. * Stores the animation ranges for the animation
  25048. */
  25049. private _ranges;
  25050. /**
  25051. * @hidden Internal use
  25052. */
  25053. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25054. /**
  25055. * Sets up an animation
  25056. * @param property The property to animate
  25057. * @param animationType The animation type to apply
  25058. * @param framePerSecond The frames per second of the animation
  25059. * @param easingFunction The easing function used in the animation
  25060. * @returns The created animation
  25061. */
  25062. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25063. /**
  25064. * Create and start an animation on a node
  25065. * @param name defines the name of the global animation that will be run on all nodes
  25066. * @param node defines the root node where the animation will take place
  25067. * @param targetProperty defines property to animate
  25068. * @param framePerSecond defines the number of frame per second yo use
  25069. * @param totalFrame defines the number of frames in total
  25070. * @param from defines the initial value
  25071. * @param to defines the final value
  25072. * @param loopMode defines which loop mode you want to use (off by default)
  25073. * @param easingFunction defines the easing function to use (linear by default)
  25074. * @param onAnimationEnd defines the callback to call when animation end
  25075. * @returns the animatable created for this animation
  25076. */
  25077. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25078. /**
  25079. * Create and start an animation on a node and its descendants
  25080. * @param name defines the name of the global animation that will be run on all nodes
  25081. * @param node defines the root node where the animation will take place
  25082. * @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
  25083. * @param targetProperty defines property to animate
  25084. * @param framePerSecond defines the number of frame per second to use
  25085. * @param totalFrame defines the number of frames in total
  25086. * @param from defines the initial value
  25087. * @param to defines the final value
  25088. * @param loopMode defines which loop mode you want to use (off by default)
  25089. * @param easingFunction defines the easing function to use (linear by default)
  25090. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25091. * @returns the list of animatables created for all nodes
  25092. * @example https://www.babylonjs-playground.com/#MH0VLI
  25093. */
  25094. 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[]>;
  25095. /**
  25096. * Creates a new animation, merges it with the existing animations and starts it
  25097. * @param name Name of the animation
  25098. * @param node Node which contains the scene that begins the animations
  25099. * @param targetProperty Specifies which property to animate
  25100. * @param framePerSecond The frames per second of the animation
  25101. * @param totalFrame The total number of frames
  25102. * @param from The frame at the beginning of the animation
  25103. * @param to The frame at the end of the animation
  25104. * @param loopMode Specifies the loop mode of the animation
  25105. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25106. * @param onAnimationEnd Callback to run once the animation is complete
  25107. * @returns Nullable animation
  25108. */
  25109. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25110. /**
  25111. * Transition property of an host to the target Value
  25112. * @param property The property to transition
  25113. * @param targetValue The target Value of the property
  25114. * @param host The object where the property to animate belongs
  25115. * @param scene Scene used to run the animation
  25116. * @param frameRate Framerate (in frame/s) to use
  25117. * @param transition The transition type we want to use
  25118. * @param duration The duration of the animation, in milliseconds
  25119. * @param onAnimationEnd Callback trigger at the end of the animation
  25120. * @returns Nullable animation
  25121. */
  25122. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25123. /**
  25124. * Return the array of runtime animations currently using this animation
  25125. */
  25126. readonly runtimeAnimations: RuntimeAnimation[];
  25127. /**
  25128. * Specifies if any of the runtime animations are currently running
  25129. */
  25130. readonly hasRunningRuntimeAnimations: boolean;
  25131. /**
  25132. * Initializes the animation
  25133. * @param name Name of the animation
  25134. * @param targetProperty Property to animate
  25135. * @param framePerSecond The frames per second of the animation
  25136. * @param dataType The data type of the animation
  25137. * @param loopMode The loop mode of the animation
  25138. * @param enableBlending Specifies if blending should be enabled
  25139. */
  25140. constructor(
  25141. /**Name of the animation */
  25142. name: string,
  25143. /**Property to animate */
  25144. targetProperty: string,
  25145. /**The frames per second of the animation */
  25146. framePerSecond: number,
  25147. /**The data type of the animation */
  25148. dataType: number,
  25149. /**The loop mode of the animation */
  25150. loopMode?: number | undefined,
  25151. /**Specifies if blending should be enabled */
  25152. enableBlending?: boolean | undefined);
  25153. /**
  25154. * Converts the animation to a string
  25155. * @param fullDetails support for multiple levels of logging within scene loading
  25156. * @returns String form of the animation
  25157. */
  25158. toString(fullDetails?: boolean): string;
  25159. /**
  25160. * Add an event to this animation
  25161. * @param event Event to add
  25162. */
  25163. addEvent(event: AnimationEvent): void;
  25164. /**
  25165. * Remove all events found at the given frame
  25166. * @param frame The frame to remove events from
  25167. */
  25168. removeEvents(frame: number): void;
  25169. /**
  25170. * Retrieves all the events from the animation
  25171. * @returns Events from the animation
  25172. */
  25173. getEvents(): AnimationEvent[];
  25174. /**
  25175. * Creates an animation range
  25176. * @param name Name of the animation range
  25177. * @param from Starting frame of the animation range
  25178. * @param to Ending frame of the animation
  25179. */
  25180. createRange(name: string, from: number, to: number): void;
  25181. /**
  25182. * Deletes an animation range by name
  25183. * @param name Name of the animation range to delete
  25184. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25185. */
  25186. deleteRange(name: string, deleteFrames?: boolean): void;
  25187. /**
  25188. * Gets the animation range by name, or null if not defined
  25189. * @param name Name of the animation range
  25190. * @returns Nullable animation range
  25191. */
  25192. getRange(name: string): Nullable<AnimationRange>;
  25193. /**
  25194. * Gets the key frames from the animation
  25195. * @returns The key frames of the animation
  25196. */
  25197. getKeys(): Array<IAnimationKey>;
  25198. /**
  25199. * Gets the highest frame rate of the animation
  25200. * @returns Highest frame rate of the animation
  25201. */
  25202. getHighestFrame(): number;
  25203. /**
  25204. * Gets the easing function of the animation
  25205. * @returns Easing function of the animation
  25206. */
  25207. getEasingFunction(): IEasingFunction;
  25208. /**
  25209. * Sets the easing function of the animation
  25210. * @param easingFunction A custom mathematical formula for animation
  25211. */
  25212. setEasingFunction(easingFunction: EasingFunction): void;
  25213. /**
  25214. * Interpolates a scalar linearly
  25215. * @param startValue Start value of the animation curve
  25216. * @param endValue End value of the animation curve
  25217. * @param gradient Scalar amount to interpolate
  25218. * @returns Interpolated scalar value
  25219. */
  25220. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25221. /**
  25222. * Interpolates a scalar cubically
  25223. * @param startValue Start value of the animation curve
  25224. * @param outTangent End tangent of the animation
  25225. * @param endValue End value of the animation curve
  25226. * @param inTangent Start tangent of the animation curve
  25227. * @param gradient Scalar amount to interpolate
  25228. * @returns Interpolated scalar value
  25229. */
  25230. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25231. /**
  25232. * Interpolates a quaternion using a spherical linear interpolation
  25233. * @param startValue Start value of the animation curve
  25234. * @param endValue End value of the animation curve
  25235. * @param gradient Scalar amount to interpolate
  25236. * @returns Interpolated quaternion value
  25237. */
  25238. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25239. /**
  25240. * Interpolates a quaternion cubically
  25241. * @param startValue Start value of the animation curve
  25242. * @param outTangent End tangent of the animation curve
  25243. * @param endValue End value of the animation curve
  25244. * @param inTangent Start tangent of the animation curve
  25245. * @param gradient Scalar amount to interpolate
  25246. * @returns Interpolated quaternion value
  25247. */
  25248. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25249. /**
  25250. * Interpolates a Vector3 linearl
  25251. * @param startValue Start value of the animation curve
  25252. * @param endValue End value of the animation curve
  25253. * @param gradient Scalar amount to interpolate
  25254. * @returns Interpolated scalar value
  25255. */
  25256. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25257. /**
  25258. * Interpolates a Vector3 cubically
  25259. * @param startValue Start value of the animation curve
  25260. * @param outTangent End tangent of the animation
  25261. * @param endValue End value of the animation curve
  25262. * @param inTangent Start tangent of the animation curve
  25263. * @param gradient Scalar amount to interpolate
  25264. * @returns InterpolatedVector3 value
  25265. */
  25266. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25267. /**
  25268. * Interpolates a Vector2 linearly
  25269. * @param startValue Start value of the animation curve
  25270. * @param endValue End value of the animation curve
  25271. * @param gradient Scalar amount to interpolate
  25272. * @returns Interpolated Vector2 value
  25273. */
  25274. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25275. /**
  25276. * Interpolates a Vector2 cubically
  25277. * @param startValue Start value of the animation curve
  25278. * @param outTangent End tangent of the animation
  25279. * @param endValue End value of the animation curve
  25280. * @param inTangent Start tangent of the animation curve
  25281. * @param gradient Scalar amount to interpolate
  25282. * @returns Interpolated Vector2 value
  25283. */
  25284. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25285. /**
  25286. * Interpolates a size linearly
  25287. * @param startValue Start value of the animation curve
  25288. * @param endValue End value of the animation curve
  25289. * @param gradient Scalar amount to interpolate
  25290. * @returns Interpolated Size value
  25291. */
  25292. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25293. /**
  25294. * Interpolates a Color3 linearly
  25295. * @param startValue Start value of the animation curve
  25296. * @param endValue End value of the animation curve
  25297. * @param gradient Scalar amount to interpolate
  25298. * @returns Interpolated Color3 value
  25299. */
  25300. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25301. /**
  25302. * @hidden Internal use only
  25303. */
  25304. _getKeyValue(value: any): any;
  25305. /**
  25306. * @hidden Internal use only
  25307. */
  25308. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25309. /**
  25310. * Defines the function to use to interpolate matrices
  25311. * @param startValue defines the start matrix
  25312. * @param endValue defines the end matrix
  25313. * @param gradient defines the gradient between both matrices
  25314. * @param result defines an optional target matrix where to store the interpolation
  25315. * @returns the interpolated matrix
  25316. */
  25317. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25318. /**
  25319. * Makes a copy of the animation
  25320. * @returns Cloned animation
  25321. */
  25322. clone(): Animation;
  25323. /**
  25324. * Sets the key frames of the animation
  25325. * @param values The animation key frames to set
  25326. */
  25327. setKeys(values: Array<IAnimationKey>): void;
  25328. /**
  25329. * Serializes the animation to an object
  25330. * @returns Serialized object
  25331. */
  25332. serialize(): any;
  25333. /**
  25334. * Float animation type
  25335. */
  25336. private static _ANIMATIONTYPE_FLOAT;
  25337. /**
  25338. * Vector3 animation type
  25339. */
  25340. private static _ANIMATIONTYPE_VECTOR3;
  25341. /**
  25342. * Quaternion animation type
  25343. */
  25344. private static _ANIMATIONTYPE_QUATERNION;
  25345. /**
  25346. * Matrix animation type
  25347. */
  25348. private static _ANIMATIONTYPE_MATRIX;
  25349. /**
  25350. * Color3 animation type
  25351. */
  25352. private static _ANIMATIONTYPE_COLOR3;
  25353. /**
  25354. * Vector2 animation type
  25355. */
  25356. private static _ANIMATIONTYPE_VECTOR2;
  25357. /**
  25358. * Size animation type
  25359. */
  25360. private static _ANIMATIONTYPE_SIZE;
  25361. /**
  25362. * Relative Loop Mode
  25363. */
  25364. private static _ANIMATIONLOOPMODE_RELATIVE;
  25365. /**
  25366. * Cycle Loop Mode
  25367. */
  25368. private static _ANIMATIONLOOPMODE_CYCLE;
  25369. /**
  25370. * Constant Loop Mode
  25371. */
  25372. private static _ANIMATIONLOOPMODE_CONSTANT;
  25373. /**
  25374. * Get the float animation type
  25375. */
  25376. static readonly ANIMATIONTYPE_FLOAT: number;
  25377. /**
  25378. * Get the Vector3 animation type
  25379. */
  25380. static readonly ANIMATIONTYPE_VECTOR3: number;
  25381. /**
  25382. * Get the Vector2 animation type
  25383. */
  25384. static readonly ANIMATIONTYPE_VECTOR2: number;
  25385. /**
  25386. * Get the Size animation type
  25387. */
  25388. static readonly ANIMATIONTYPE_SIZE: number;
  25389. /**
  25390. * Get the Quaternion animation type
  25391. */
  25392. static readonly ANIMATIONTYPE_QUATERNION: number;
  25393. /**
  25394. * Get the Matrix animation type
  25395. */
  25396. static readonly ANIMATIONTYPE_MATRIX: number;
  25397. /**
  25398. * Get the Color3 animation type
  25399. */
  25400. static readonly ANIMATIONTYPE_COLOR3: number;
  25401. /**
  25402. * Get the Relative Loop Mode
  25403. */
  25404. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25405. /**
  25406. * Get the Cycle Loop Mode
  25407. */
  25408. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25409. /**
  25410. * Get the Constant Loop Mode
  25411. */
  25412. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25413. /** @hidden */
  25414. static _UniversalLerp(left: any, right: any, amount: number): any;
  25415. /**
  25416. * Parses an animation object and creates an animation
  25417. * @param parsedAnimation Parsed animation object
  25418. * @returns Animation object
  25419. */
  25420. static Parse(parsedAnimation: any): Animation;
  25421. /**
  25422. * Appends the serialized animations from the source animations
  25423. * @param source Source containing the animations
  25424. * @param destination Target to store the animations
  25425. */
  25426. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25427. }
  25428. }
  25429. declare module "babylonjs/Materials/Textures/baseTexture" {
  25430. import { Observable } from "babylonjs/Misc/observable";
  25431. import { IAnimatable } from "babylonjs/Misc/tools";
  25432. import { Nullable } from "babylonjs/types";
  25433. import { Scene } from "babylonjs/scene";
  25434. import { Matrix, ISize } from "babylonjs/Maths/math";
  25435. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25436. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25437. /**
  25438. * Base class of all the textures in babylon.
  25439. * It groups all the common properties the materials, post process, lights... might need
  25440. * in order to make a correct use of the texture.
  25441. */
  25442. export class BaseTexture implements IAnimatable {
  25443. /**
  25444. * Default anisotropic filtering level for the application.
  25445. * It is set to 4 as a good tradeoff between perf and quality.
  25446. */
  25447. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25448. /**
  25449. * Gets or sets the unique id of the texture
  25450. */
  25451. uniqueId: number;
  25452. /**
  25453. * Define the name of the texture.
  25454. */
  25455. name: string;
  25456. /**
  25457. * Gets or sets an object used to store user defined information.
  25458. */
  25459. metadata: any;
  25460. /**
  25461. * For internal use only. Please do not use.
  25462. */
  25463. reservedDataStore: any;
  25464. private _hasAlpha;
  25465. /**
  25466. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25467. */
  25468. hasAlpha: boolean;
  25469. /**
  25470. * Defines if the alpha value should be determined via the rgb values.
  25471. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25472. */
  25473. getAlphaFromRGB: boolean;
  25474. /**
  25475. * Intensity or strength of the texture.
  25476. * It is commonly used by materials to fine tune the intensity of the texture
  25477. */
  25478. level: number;
  25479. /**
  25480. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25481. * This is part of the texture as textures usually maps to one uv set.
  25482. */
  25483. coordinatesIndex: number;
  25484. private _coordinatesMode;
  25485. /**
  25486. * How a texture is mapped.
  25487. *
  25488. * | Value | Type | Description |
  25489. * | ----- | ----------------------------------- | ----------- |
  25490. * | 0 | EXPLICIT_MODE | |
  25491. * | 1 | SPHERICAL_MODE | |
  25492. * | 2 | PLANAR_MODE | |
  25493. * | 3 | CUBIC_MODE | |
  25494. * | 4 | PROJECTION_MODE | |
  25495. * | 5 | SKYBOX_MODE | |
  25496. * | 6 | INVCUBIC_MODE | |
  25497. * | 7 | EQUIRECTANGULAR_MODE | |
  25498. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25499. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25500. */
  25501. coordinatesMode: number;
  25502. /**
  25503. * | Value | Type | Description |
  25504. * | ----- | ------------------ | ----------- |
  25505. * | 0 | CLAMP_ADDRESSMODE | |
  25506. * | 1 | WRAP_ADDRESSMODE | |
  25507. * | 2 | MIRROR_ADDRESSMODE | |
  25508. */
  25509. wrapU: number;
  25510. /**
  25511. * | Value | Type | Description |
  25512. * | ----- | ------------------ | ----------- |
  25513. * | 0 | CLAMP_ADDRESSMODE | |
  25514. * | 1 | WRAP_ADDRESSMODE | |
  25515. * | 2 | MIRROR_ADDRESSMODE | |
  25516. */
  25517. wrapV: number;
  25518. /**
  25519. * | Value | Type | Description |
  25520. * | ----- | ------------------ | ----------- |
  25521. * | 0 | CLAMP_ADDRESSMODE | |
  25522. * | 1 | WRAP_ADDRESSMODE | |
  25523. * | 2 | MIRROR_ADDRESSMODE | |
  25524. */
  25525. wrapR: number;
  25526. /**
  25527. * With compliant hardware and browser (supporting anisotropic filtering)
  25528. * this defines the level of anisotropic filtering in the texture.
  25529. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25530. */
  25531. anisotropicFilteringLevel: number;
  25532. /**
  25533. * Define if the texture is a cube texture or if false a 2d texture.
  25534. */
  25535. isCube: boolean;
  25536. /**
  25537. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25538. */
  25539. is3D: boolean;
  25540. /**
  25541. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25542. * HDR texture are usually stored in linear space.
  25543. * This only impacts the PBR and Background materials
  25544. */
  25545. gammaSpace: boolean;
  25546. /**
  25547. * Gets whether or not the texture contains RGBD data.
  25548. */
  25549. readonly isRGBD: boolean;
  25550. /**
  25551. * Is Z inverted in the texture (useful in a cube texture).
  25552. */
  25553. invertZ: boolean;
  25554. /**
  25555. * Are mip maps generated for this texture or not.
  25556. */
  25557. readonly noMipmap: boolean;
  25558. /**
  25559. * @hidden
  25560. */
  25561. lodLevelInAlpha: boolean;
  25562. /**
  25563. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25564. */
  25565. lodGenerationOffset: number;
  25566. /**
  25567. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25568. */
  25569. lodGenerationScale: number;
  25570. /**
  25571. * Define if the texture is a render target.
  25572. */
  25573. isRenderTarget: boolean;
  25574. /**
  25575. * Define the unique id of the texture in the scene.
  25576. */
  25577. readonly uid: string;
  25578. /**
  25579. * Return a string representation of the texture.
  25580. * @returns the texture as a string
  25581. */
  25582. toString(): string;
  25583. /**
  25584. * Get the class name of the texture.
  25585. * @returns "BaseTexture"
  25586. */
  25587. getClassName(): string;
  25588. /**
  25589. * Define the list of animation attached to the texture.
  25590. */
  25591. animations: import("babylonjs/Animations/animation").Animation[];
  25592. /**
  25593. * An event triggered when the texture is disposed.
  25594. */
  25595. onDisposeObservable: Observable<BaseTexture>;
  25596. private _onDisposeObserver;
  25597. /**
  25598. * Callback triggered when the texture has been disposed.
  25599. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25600. */
  25601. onDispose: () => void;
  25602. /**
  25603. * Define the current state of the loading sequence when in delayed load mode.
  25604. */
  25605. delayLoadState: number;
  25606. private _scene;
  25607. /** @hidden */
  25608. _texture: Nullable<InternalTexture>;
  25609. private _uid;
  25610. /**
  25611. * Define if the texture is preventinga material to render or not.
  25612. * If not and the texture is not ready, the engine will use a default black texture instead.
  25613. */
  25614. readonly isBlocking: boolean;
  25615. /**
  25616. * Instantiates a new BaseTexture.
  25617. * Base class of all the textures in babylon.
  25618. * It groups all the common properties the materials, post process, lights... might need
  25619. * in order to make a correct use of the texture.
  25620. * @param scene Define the scene the texture blongs to
  25621. */
  25622. constructor(scene: Nullable<Scene>);
  25623. /**
  25624. * Get the scene the texture belongs to.
  25625. * @returns the scene or null if undefined
  25626. */
  25627. getScene(): Nullable<Scene>;
  25628. /**
  25629. * Get the texture transform matrix used to offset tile the texture for istance.
  25630. * @returns the transformation matrix
  25631. */
  25632. getTextureMatrix(): Matrix;
  25633. /**
  25634. * Get the texture reflection matrix used to rotate/transform the reflection.
  25635. * @returns the reflection matrix
  25636. */
  25637. getReflectionTextureMatrix(): Matrix;
  25638. /**
  25639. * Get the underlying lower level texture from Babylon.
  25640. * @returns the insternal texture
  25641. */
  25642. getInternalTexture(): Nullable<InternalTexture>;
  25643. /**
  25644. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25645. * @returns true if ready or not blocking
  25646. */
  25647. isReadyOrNotBlocking(): boolean;
  25648. /**
  25649. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25650. * @returns true if fully ready
  25651. */
  25652. isReady(): boolean;
  25653. private _cachedSize;
  25654. /**
  25655. * Get the size of the texture.
  25656. * @returns the texture size.
  25657. */
  25658. getSize(): ISize;
  25659. /**
  25660. * Get the base size of the texture.
  25661. * It can be different from the size if the texture has been resized for POT for instance
  25662. * @returns the base size
  25663. */
  25664. getBaseSize(): ISize;
  25665. /**
  25666. * Update the sampling mode of the texture.
  25667. * Default is Trilinear mode.
  25668. *
  25669. * | Value | Type | Description |
  25670. * | ----- | ------------------ | ----------- |
  25671. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25672. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25673. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25674. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25675. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25676. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25677. * | 7 | NEAREST_LINEAR | |
  25678. * | 8 | NEAREST_NEAREST | |
  25679. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25680. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25681. * | 11 | LINEAR_LINEAR | |
  25682. * | 12 | LINEAR_NEAREST | |
  25683. *
  25684. * > _mag_: magnification filter (close to the viewer)
  25685. * > _min_: minification filter (far from the viewer)
  25686. * > _mip_: filter used between mip map levels
  25687. *@param samplingMode Define the new sampling mode of the texture
  25688. */
  25689. updateSamplingMode(samplingMode: number): void;
  25690. /**
  25691. * Scales the texture if is `canRescale()`
  25692. * @param ratio the resize factor we want to use to rescale
  25693. */
  25694. scale(ratio: number): void;
  25695. /**
  25696. * Get if the texture can rescale.
  25697. */
  25698. readonly canRescale: boolean;
  25699. /** @hidden */
  25700. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  25701. /** @hidden */
  25702. _rebuild(): void;
  25703. /**
  25704. * Triggers the load sequence in delayed load mode.
  25705. */
  25706. delayLoad(): void;
  25707. /**
  25708. * Clones the texture.
  25709. * @returns the cloned texture
  25710. */
  25711. clone(): Nullable<BaseTexture>;
  25712. /**
  25713. * Get the texture underlying type (INT, FLOAT...)
  25714. */
  25715. readonly textureType: number;
  25716. /**
  25717. * Get the texture underlying format (RGB, RGBA...)
  25718. */
  25719. readonly textureFormat: number;
  25720. /**
  25721. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25722. * This will returns an RGBA array buffer containing either in values (0-255) or
  25723. * float values (0-1) depending of the underlying buffer type.
  25724. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25725. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25726. * @param buffer defines a user defined buffer to fill with data (can be null)
  25727. * @returns The Array buffer containing the pixels data.
  25728. */
  25729. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25730. /**
  25731. * Release and destroy the underlying lower level texture aka internalTexture.
  25732. */
  25733. releaseInternalTexture(): void;
  25734. /**
  25735. * Get the polynomial representation of the texture data.
  25736. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25737. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25738. */
  25739. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25740. /** @hidden */
  25741. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25742. /** @hidden */
  25743. readonly _lodTextureMid: Nullable<BaseTexture>;
  25744. /** @hidden */
  25745. readonly _lodTextureLow: Nullable<BaseTexture>;
  25746. /**
  25747. * Dispose the texture and release its associated resources.
  25748. */
  25749. dispose(): void;
  25750. /**
  25751. * Serialize the texture into a JSON representation that can be parsed later on.
  25752. * @returns the JSON representation of the texture
  25753. */
  25754. serialize(): any;
  25755. /**
  25756. * Helper function to be called back once a list of texture contains only ready textures.
  25757. * @param textures Define the list of textures to wait for
  25758. * @param callback Define the callback triggered once the entire list will be ready
  25759. */
  25760. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25761. }
  25762. }
  25763. declare module "babylonjs/Materials/uniformBuffer" {
  25764. import { Nullable, FloatArray } from "babylonjs/types";
  25765. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25766. import { Engine } from "babylonjs/Engines/engine";
  25767. import { Effect } from "babylonjs/Materials/effect";
  25768. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25769. /**
  25770. * Uniform buffer objects.
  25771. *
  25772. * Handles blocks of uniform on the GPU.
  25773. *
  25774. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25775. *
  25776. * For more information, please refer to :
  25777. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25778. */
  25779. export class UniformBuffer {
  25780. private _engine;
  25781. private _buffer;
  25782. private _data;
  25783. private _bufferData;
  25784. private _dynamic?;
  25785. private _uniformLocations;
  25786. private _uniformSizes;
  25787. private _uniformLocationPointer;
  25788. private _needSync;
  25789. private _noUBO;
  25790. private _currentEffect;
  25791. private static _MAX_UNIFORM_SIZE;
  25792. private static _tempBuffer;
  25793. /**
  25794. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25795. * This is dynamic to allow compat with webgl 1 and 2.
  25796. * You will need to pass the name of the uniform as well as the value.
  25797. */
  25798. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25799. /**
  25800. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25801. * This is dynamic to allow compat with webgl 1 and 2.
  25802. * You will need to pass the name of the uniform as well as the value.
  25803. */
  25804. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25805. /**
  25806. * Lambda to Update a single float in a uniform buffer.
  25807. * This is dynamic to allow compat with webgl 1 and 2.
  25808. * You will need to pass the name of the uniform as well as the value.
  25809. */
  25810. updateFloat: (name: string, x: number) => void;
  25811. /**
  25812. * Lambda to Update a vec2 of float in a uniform buffer.
  25813. * This is dynamic to allow compat with webgl 1 and 2.
  25814. * You will need to pass the name of the uniform as well as the value.
  25815. */
  25816. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25817. /**
  25818. * Lambda to Update a vec3 of float in a uniform buffer.
  25819. * This is dynamic to allow compat with webgl 1 and 2.
  25820. * You will need to pass the name of the uniform as well as the value.
  25821. */
  25822. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25823. /**
  25824. * Lambda to Update a vec4 of float in a uniform buffer.
  25825. * This is dynamic to allow compat with webgl 1 and 2.
  25826. * You will need to pass the name of the uniform as well as the value.
  25827. */
  25828. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25829. /**
  25830. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25831. * This is dynamic to allow compat with webgl 1 and 2.
  25832. * You will need to pass the name of the uniform as well as the value.
  25833. */
  25834. updateMatrix: (name: string, mat: Matrix) => void;
  25835. /**
  25836. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25837. * This is dynamic to allow compat with webgl 1 and 2.
  25838. * You will need to pass the name of the uniform as well as the value.
  25839. */
  25840. updateVector3: (name: string, vector: Vector3) => void;
  25841. /**
  25842. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25843. * This is dynamic to allow compat with webgl 1 and 2.
  25844. * You will need to pass the name of the uniform as well as the value.
  25845. */
  25846. updateVector4: (name: string, vector: Vector4) => void;
  25847. /**
  25848. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25849. * This is dynamic to allow compat with webgl 1 and 2.
  25850. * You will need to pass the name of the uniform as well as the value.
  25851. */
  25852. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25853. /**
  25854. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25855. * This is dynamic to allow compat with webgl 1 and 2.
  25856. * You will need to pass the name of the uniform as well as the value.
  25857. */
  25858. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25859. /**
  25860. * Instantiates a new Uniform buffer objects.
  25861. *
  25862. * Handles blocks of uniform on the GPU.
  25863. *
  25864. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25865. *
  25866. * For more information, please refer to :
  25867. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25868. * @param engine Define the engine the buffer is associated with
  25869. * @param data Define the data contained in the buffer
  25870. * @param dynamic Define if the buffer is updatable
  25871. */
  25872. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25873. /**
  25874. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25875. * or just falling back on setUniformXXX calls.
  25876. */
  25877. readonly useUbo: boolean;
  25878. /**
  25879. * Indicates if the WebGL underlying uniform buffer is in sync
  25880. * with the javascript cache data.
  25881. */
  25882. readonly isSync: boolean;
  25883. /**
  25884. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25885. * Also, a dynamic UniformBuffer will disable cache verification and always
  25886. * update the underlying WebGL uniform buffer to the GPU.
  25887. * @returns if Dynamic, otherwise false
  25888. */
  25889. isDynamic(): boolean;
  25890. /**
  25891. * The data cache on JS side.
  25892. * @returns the underlying data as a float array
  25893. */
  25894. getData(): Float32Array;
  25895. /**
  25896. * The underlying WebGL Uniform buffer.
  25897. * @returns the webgl buffer
  25898. */
  25899. getBuffer(): Nullable<WebGLBuffer>;
  25900. /**
  25901. * std140 layout specifies how to align data within an UBO structure.
  25902. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25903. * for specs.
  25904. */
  25905. private _fillAlignment;
  25906. /**
  25907. * Adds an uniform in the buffer.
  25908. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25909. * for the layout to be correct !
  25910. * @param name Name of the uniform, as used in the uniform block in the shader.
  25911. * @param size Data size, or data directly.
  25912. */
  25913. addUniform(name: string, size: number | number[]): void;
  25914. /**
  25915. * Adds a Matrix 4x4 to the uniform buffer.
  25916. * @param name Name of the uniform, as used in the uniform block in the shader.
  25917. * @param mat A 4x4 matrix.
  25918. */
  25919. addMatrix(name: string, mat: Matrix): void;
  25920. /**
  25921. * Adds a vec2 to the uniform buffer.
  25922. * @param name Name of the uniform, as used in the uniform block in the shader.
  25923. * @param x Define the x component value of the vec2
  25924. * @param y Define the y component value of the vec2
  25925. */
  25926. addFloat2(name: string, x: number, y: number): void;
  25927. /**
  25928. * Adds a vec3 to the uniform buffer.
  25929. * @param name Name of the uniform, as used in the uniform block in the shader.
  25930. * @param x Define the x component value of the vec3
  25931. * @param y Define the y component value of the vec3
  25932. * @param z Define the z component value of the vec3
  25933. */
  25934. addFloat3(name: string, x: number, y: number, z: number): void;
  25935. /**
  25936. * Adds a vec3 to the uniform buffer.
  25937. * @param name Name of the uniform, as used in the uniform block in the shader.
  25938. * @param color Define the vec3 from a Color
  25939. */
  25940. addColor3(name: string, color: Color3): void;
  25941. /**
  25942. * Adds a vec4 to the uniform buffer.
  25943. * @param name Name of the uniform, as used in the uniform block in the shader.
  25944. * @param color Define the rgb components from a Color
  25945. * @param alpha Define the a component of the vec4
  25946. */
  25947. addColor4(name: string, color: Color3, alpha: number): void;
  25948. /**
  25949. * Adds a vec3 to the uniform buffer.
  25950. * @param name Name of the uniform, as used in the uniform block in the shader.
  25951. * @param vector Define the vec3 components from a Vector
  25952. */
  25953. addVector3(name: string, vector: Vector3): void;
  25954. /**
  25955. * Adds a Matrix 3x3 to the uniform buffer.
  25956. * @param name Name of the uniform, as used in the uniform block in the shader.
  25957. */
  25958. addMatrix3x3(name: string): void;
  25959. /**
  25960. * Adds a Matrix 2x2 to the uniform buffer.
  25961. * @param name Name of the uniform, as used in the uniform block in the shader.
  25962. */
  25963. addMatrix2x2(name: string): void;
  25964. /**
  25965. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25966. */
  25967. create(): void;
  25968. /** @hidden */
  25969. _rebuild(): void;
  25970. /**
  25971. * Updates the WebGL Uniform Buffer on the GPU.
  25972. * If the `dynamic` flag is set to true, no cache comparison is done.
  25973. * Otherwise, the buffer will be updated only if the cache differs.
  25974. */
  25975. update(): void;
  25976. /**
  25977. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25978. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25979. * @param data Define the flattened data
  25980. * @param size Define the size of the data.
  25981. */
  25982. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  25983. private _updateMatrix3x3ForUniform;
  25984. private _updateMatrix3x3ForEffect;
  25985. private _updateMatrix2x2ForEffect;
  25986. private _updateMatrix2x2ForUniform;
  25987. private _updateFloatForEffect;
  25988. private _updateFloatForUniform;
  25989. private _updateFloat2ForEffect;
  25990. private _updateFloat2ForUniform;
  25991. private _updateFloat3ForEffect;
  25992. private _updateFloat3ForUniform;
  25993. private _updateFloat4ForEffect;
  25994. private _updateFloat4ForUniform;
  25995. private _updateMatrixForEffect;
  25996. private _updateMatrixForUniform;
  25997. private _updateVector3ForEffect;
  25998. private _updateVector3ForUniform;
  25999. private _updateVector4ForEffect;
  26000. private _updateVector4ForUniform;
  26001. private _updateColor3ForEffect;
  26002. private _updateColor3ForUniform;
  26003. private _updateColor4ForEffect;
  26004. private _updateColor4ForUniform;
  26005. /**
  26006. * Sets a sampler uniform on the effect.
  26007. * @param name Define the name of the sampler.
  26008. * @param texture Define the texture to set in the sampler
  26009. */
  26010. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26011. /**
  26012. * Directly updates the value of the uniform in the cache AND on the GPU.
  26013. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26014. * @param data Define the flattened data
  26015. */
  26016. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26017. /**
  26018. * Binds this uniform buffer to an effect.
  26019. * @param effect Define the effect to bind the buffer to
  26020. * @param name Name of the uniform block in the shader.
  26021. */
  26022. bindToEffect(effect: Effect, name: string): void;
  26023. /**
  26024. * Disposes the uniform buffer.
  26025. */
  26026. dispose(): void;
  26027. }
  26028. }
  26029. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26030. import { Nullable } from "babylonjs/types";
  26031. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26032. /**
  26033. * This represents the required contract to create a new type of texture loader.
  26034. */
  26035. export interface IInternalTextureLoader {
  26036. /**
  26037. * Defines wether the loader supports cascade loading the different faces.
  26038. */
  26039. supportCascades: boolean;
  26040. /**
  26041. * This returns if the loader support the current file information.
  26042. * @param extension defines the file extension of the file being loaded
  26043. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26044. * @param fallback defines the fallback internal texture if any
  26045. * @param isBase64 defines whether the texture is encoded as a base64
  26046. * @param isBuffer defines whether the texture data are stored as a buffer
  26047. * @returns true if the loader can load the specified file
  26048. */
  26049. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26050. /**
  26051. * Transform the url before loading if required.
  26052. * @param rootUrl the url of the texture
  26053. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26054. * @returns the transformed texture
  26055. */
  26056. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26057. /**
  26058. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26059. * @param rootUrl the url of the texture
  26060. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26061. * @returns the fallback texture
  26062. */
  26063. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26064. /**
  26065. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26066. * @param data contains the texture data
  26067. * @param texture defines the BabylonJS internal texture
  26068. * @param createPolynomials will be true if polynomials have been requested
  26069. * @param onLoad defines the callback to trigger once the texture is ready
  26070. * @param onError defines the callback to trigger in case of error
  26071. */
  26072. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26073. /**
  26074. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26075. * @param data contains the texture data
  26076. * @param texture defines the BabylonJS internal texture
  26077. * @param callback defines the method to call once ready to upload
  26078. */
  26079. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26080. }
  26081. }
  26082. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26083. import { Scene } from "babylonjs/scene";
  26084. import { Engine } from "babylonjs/Engines/engine";
  26085. import { Texture } from "babylonjs/Materials/Textures/texture";
  26086. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26087. /**
  26088. * Creation options of the multi render target texture.
  26089. */
  26090. export interface IMultiRenderTargetOptions {
  26091. /**
  26092. * Define if the texture needs to create mip maps after render.
  26093. */
  26094. generateMipMaps?: boolean;
  26095. /**
  26096. * Define the types of all the draw buffers we want to create
  26097. */
  26098. types?: number[];
  26099. /**
  26100. * Define the sampling modes of all the draw buffers we want to create
  26101. */
  26102. samplingModes?: number[];
  26103. /**
  26104. * Define if a depth buffer is required
  26105. */
  26106. generateDepthBuffer?: boolean;
  26107. /**
  26108. * Define if a stencil buffer is required
  26109. */
  26110. generateStencilBuffer?: boolean;
  26111. /**
  26112. * Define if a depth texture is required instead of a depth buffer
  26113. */
  26114. generateDepthTexture?: boolean;
  26115. /**
  26116. * Define the number of desired draw buffers
  26117. */
  26118. textureCount?: number;
  26119. /**
  26120. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26121. */
  26122. doNotChangeAspectRatio?: boolean;
  26123. /**
  26124. * Define the default type of the buffers we are creating
  26125. */
  26126. defaultType?: number;
  26127. }
  26128. /**
  26129. * A multi render target, like a render target provides the ability to render to a texture.
  26130. * Unlike the render target, it can render to several draw buffers in one draw.
  26131. * This is specially interesting in deferred rendering or for any effects requiring more than
  26132. * just one color from a single pass.
  26133. */
  26134. export class MultiRenderTarget extends RenderTargetTexture {
  26135. private _internalTextures;
  26136. private _textures;
  26137. private _multiRenderTargetOptions;
  26138. /**
  26139. * Get if draw buffers are currently supported by the used hardware and browser.
  26140. */
  26141. readonly isSupported: boolean;
  26142. /**
  26143. * Get the list of textures generated by the multi render target.
  26144. */
  26145. readonly textures: Texture[];
  26146. /**
  26147. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26148. */
  26149. readonly depthTexture: Texture;
  26150. /**
  26151. * Set the wrapping mode on U of all the textures we are rendering to.
  26152. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26153. */
  26154. wrapU: number;
  26155. /**
  26156. * Set the wrapping mode on V of all the textures we are rendering to.
  26157. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26158. */
  26159. wrapV: number;
  26160. /**
  26161. * Instantiate a new multi render target texture.
  26162. * A multi render target, like a render target provides the ability to render to a texture.
  26163. * Unlike the render target, it can render to several draw buffers in one draw.
  26164. * This is specially interesting in deferred rendering or for any effects requiring more than
  26165. * just one color from a single pass.
  26166. * @param name Define the name of the texture
  26167. * @param size Define the size of the buffers to render to
  26168. * @param count Define the number of target we are rendering into
  26169. * @param scene Define the scene the texture belongs to
  26170. * @param options Define the options used to create the multi render target
  26171. */
  26172. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26173. /** @hidden */
  26174. _rebuild(): void;
  26175. private _createInternalTextures;
  26176. private _createTextures;
  26177. /**
  26178. * Define the number of samples used if MSAA is enabled.
  26179. */
  26180. samples: number;
  26181. /**
  26182. * Resize all the textures in the multi render target.
  26183. * Be carrefull as it will recreate all the data in the new texture.
  26184. * @param size Define the new size
  26185. */
  26186. resize(size: any): void;
  26187. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26188. /**
  26189. * Dispose the render targets and their associated resources
  26190. */
  26191. dispose(): void;
  26192. /**
  26193. * Release all the underlying texture used as draw buffers.
  26194. */
  26195. releaseInternalTextures(): void;
  26196. }
  26197. }
  26198. declare module "babylonjs/Audio/analyser" {
  26199. import { Scene } from "babylonjs/scene";
  26200. /**
  26201. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26202. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26203. */
  26204. export class Analyser {
  26205. /**
  26206. * Gets or sets the smoothing
  26207. * @ignorenaming
  26208. */
  26209. SMOOTHING: number;
  26210. /**
  26211. * Gets or sets the FFT table size
  26212. * @ignorenaming
  26213. */
  26214. FFT_SIZE: number;
  26215. /**
  26216. * Gets or sets the bar graph amplitude
  26217. * @ignorenaming
  26218. */
  26219. BARGRAPHAMPLITUDE: number;
  26220. /**
  26221. * Gets or sets the position of the debug canvas
  26222. * @ignorenaming
  26223. */
  26224. DEBUGCANVASPOS: {
  26225. x: number;
  26226. y: number;
  26227. };
  26228. /**
  26229. * Gets or sets the debug canvas size
  26230. * @ignorenaming
  26231. */
  26232. DEBUGCANVASSIZE: {
  26233. width: number;
  26234. height: number;
  26235. };
  26236. private _byteFreqs;
  26237. private _byteTime;
  26238. private _floatFreqs;
  26239. private _webAudioAnalyser;
  26240. private _debugCanvas;
  26241. private _debugCanvasContext;
  26242. private _scene;
  26243. private _registerFunc;
  26244. private _audioEngine;
  26245. /**
  26246. * Creates a new analyser
  26247. * @param scene defines hosting scene
  26248. */
  26249. constructor(scene: Scene);
  26250. /**
  26251. * Get the number of data values you will have to play with for the visualization
  26252. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26253. * @returns a number
  26254. */
  26255. getFrequencyBinCount(): number;
  26256. /**
  26257. * Gets the current frequency data as a byte array
  26258. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26259. * @returns a Uint8Array
  26260. */
  26261. getByteFrequencyData(): Uint8Array;
  26262. /**
  26263. * Gets the current waveform as a byte array
  26264. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26265. * @returns a Uint8Array
  26266. */
  26267. getByteTimeDomainData(): Uint8Array;
  26268. /**
  26269. * Gets the current frequency data as a float array
  26270. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26271. * @returns a Float32Array
  26272. */
  26273. getFloatFrequencyData(): Float32Array;
  26274. /**
  26275. * Renders the debug canvas
  26276. */
  26277. drawDebugCanvas(): void;
  26278. /**
  26279. * Stops rendering the debug canvas and removes it
  26280. */
  26281. stopDebugCanvas(): void;
  26282. /**
  26283. * Connects two audio nodes
  26284. * @param inputAudioNode defines first node to connect
  26285. * @param outputAudioNode defines second node to connect
  26286. */
  26287. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26288. /**
  26289. * Releases all associated resources
  26290. */
  26291. dispose(): void;
  26292. }
  26293. }
  26294. declare module "babylonjs/Audio/audioEngine" {
  26295. import { IDisposable } from "babylonjs/scene";
  26296. import { Analyser } from "babylonjs/Audio/analyser";
  26297. import { Nullable } from "babylonjs/types";
  26298. import { Observable } from "babylonjs/Misc/observable";
  26299. /**
  26300. * This represents an audio engine and it is responsible
  26301. * to play, synchronize and analyse sounds throughout the application.
  26302. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26303. */
  26304. export interface IAudioEngine extends IDisposable {
  26305. /**
  26306. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26307. */
  26308. readonly canUseWebAudio: boolean;
  26309. /**
  26310. * Gets the current AudioContext if available.
  26311. */
  26312. readonly audioContext: Nullable<AudioContext>;
  26313. /**
  26314. * The master gain node defines the global audio volume of your audio engine.
  26315. */
  26316. readonly masterGain: GainNode;
  26317. /**
  26318. * Gets whether or not mp3 are supported by your browser.
  26319. */
  26320. readonly isMP3supported: boolean;
  26321. /**
  26322. * Gets whether or not ogg are supported by your browser.
  26323. */
  26324. readonly isOGGsupported: boolean;
  26325. /**
  26326. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26327. * @ignoreNaming
  26328. */
  26329. WarnedWebAudioUnsupported: boolean;
  26330. /**
  26331. * Defines if the audio engine relies on a custom unlocked button.
  26332. * In this case, the embedded button will not be displayed.
  26333. */
  26334. useCustomUnlockedButton: boolean;
  26335. /**
  26336. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26337. */
  26338. readonly unlocked: boolean;
  26339. /**
  26340. * Event raised when audio has been unlocked on the browser.
  26341. */
  26342. onAudioUnlockedObservable: Observable<AudioEngine>;
  26343. /**
  26344. * Event raised when audio has been locked on the browser.
  26345. */
  26346. onAudioLockedObservable: Observable<AudioEngine>;
  26347. /**
  26348. * Flags the audio engine in Locked state.
  26349. * This happens due to new browser policies preventing audio to autoplay.
  26350. */
  26351. lock(): void;
  26352. /**
  26353. * Unlocks the audio engine once a user action has been done on the dom.
  26354. * This is helpful to resume play once browser policies have been satisfied.
  26355. */
  26356. unlock(): void;
  26357. }
  26358. /**
  26359. * This represents the default audio engine used in babylon.
  26360. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26361. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26362. */
  26363. export class AudioEngine implements IAudioEngine {
  26364. private _audioContext;
  26365. private _audioContextInitialized;
  26366. private _muteButton;
  26367. private _hostElement;
  26368. /**
  26369. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26370. */
  26371. canUseWebAudio: boolean;
  26372. /**
  26373. * The master gain node defines the global audio volume of your audio engine.
  26374. */
  26375. masterGain: GainNode;
  26376. /**
  26377. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26378. * @ignoreNaming
  26379. */
  26380. WarnedWebAudioUnsupported: boolean;
  26381. /**
  26382. * Gets whether or not mp3 are supported by your browser.
  26383. */
  26384. isMP3supported: boolean;
  26385. /**
  26386. * Gets whether or not ogg are supported by your browser.
  26387. */
  26388. isOGGsupported: boolean;
  26389. /**
  26390. * Gets whether audio has been unlocked on the device.
  26391. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26392. * a user interaction has happened.
  26393. */
  26394. unlocked: 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. * Event raised when audio has been unlocked on the browser.
  26402. */
  26403. onAudioUnlockedObservable: Observable<AudioEngine>;
  26404. /**
  26405. * Event raised when audio has been locked on the browser.
  26406. */
  26407. onAudioLockedObservable: Observable<AudioEngine>;
  26408. /**
  26409. * Gets the current AudioContext if available.
  26410. */
  26411. readonly audioContext: Nullable<AudioContext>;
  26412. private _connectedAnalyser;
  26413. /**
  26414. * Instantiates a new audio engine.
  26415. *
  26416. * There should be only one per page as some browsers restrict the number
  26417. * of audio contexts you can create.
  26418. * @param hostElement defines the host element where to display the mute icon if necessary
  26419. */
  26420. constructor(hostElement?: Nullable<HTMLElement>);
  26421. /**
  26422. * Flags the audio engine in Locked state.
  26423. * This happens due to new browser policies preventing audio to autoplay.
  26424. */
  26425. lock(): void;
  26426. /**
  26427. * Unlocks the audio engine once a user action has been done on the dom.
  26428. * This is helpful to resume play once browser policies have been satisfied.
  26429. */
  26430. unlock(): void;
  26431. private _resumeAudioContext;
  26432. private _initializeAudioContext;
  26433. private _tryToRun;
  26434. private _triggerRunningState;
  26435. private _triggerSuspendedState;
  26436. private _displayMuteButton;
  26437. private _moveButtonToTopLeft;
  26438. private _onResize;
  26439. private _hideMuteButton;
  26440. /**
  26441. * Destroy and release the resources associated with the audio ccontext.
  26442. */
  26443. dispose(): void;
  26444. /**
  26445. * Gets the global volume sets on the master gain.
  26446. * @returns the global volume if set or -1 otherwise
  26447. */
  26448. getGlobalVolume(): number;
  26449. /**
  26450. * Sets the global volume of your experience (sets on the master gain).
  26451. * @param newVolume Defines the new global volume of the application
  26452. */
  26453. setGlobalVolume(newVolume: number): void;
  26454. /**
  26455. * Connect the audio engine to an audio analyser allowing some amazing
  26456. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26458. * @param analyser The analyser to connect to the engine
  26459. */
  26460. connectToAnalyser(analyser: Analyser): void;
  26461. }
  26462. }
  26463. declare module "babylonjs/Loading/loadingScreen" {
  26464. /**
  26465. * Interface used to present a loading screen while loading a scene
  26466. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26467. */
  26468. export interface ILoadingScreen {
  26469. /**
  26470. * Function called to display the loading screen
  26471. */
  26472. displayLoadingUI: () => void;
  26473. /**
  26474. * Function called to hide the loading screen
  26475. */
  26476. hideLoadingUI: () => void;
  26477. /**
  26478. * Gets or sets the color to use for the background
  26479. */
  26480. loadingUIBackgroundColor: string;
  26481. /**
  26482. * Gets or sets the text to display while loading
  26483. */
  26484. loadingUIText: string;
  26485. }
  26486. /**
  26487. * Class used for the default loading screen
  26488. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26489. */
  26490. export class DefaultLoadingScreen implements ILoadingScreen {
  26491. private _renderingCanvas;
  26492. private _loadingText;
  26493. private _loadingDivBackgroundColor;
  26494. private _loadingDiv;
  26495. private _loadingTextDiv;
  26496. /**
  26497. * Creates a new default loading screen
  26498. * @param _renderingCanvas defines the canvas used to render the scene
  26499. * @param _loadingText defines the default text to display
  26500. * @param _loadingDivBackgroundColor defines the default background color
  26501. */
  26502. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26503. /**
  26504. * Function called to display the loading screen
  26505. */
  26506. displayLoadingUI(): void;
  26507. /**
  26508. * Function called to hide the loading screen
  26509. */
  26510. hideLoadingUI(): void;
  26511. /**
  26512. * Gets or sets the text to display while loading
  26513. */
  26514. loadingUIText: string;
  26515. /**
  26516. * Gets or sets the color to use for the background
  26517. */
  26518. loadingUIBackgroundColor: string;
  26519. private _resizeLoadingUI;
  26520. }
  26521. }
  26522. declare module "babylonjs/Materials/Textures/videoTexture" {
  26523. import { Observable } from "babylonjs/Misc/observable";
  26524. import { Nullable } from "babylonjs/types";
  26525. import { Scene } from "babylonjs/scene";
  26526. import { Texture } from "babylonjs/Materials/Textures/texture";
  26527. /**
  26528. * Settings for finer control over video usage
  26529. */
  26530. export interface VideoTextureSettings {
  26531. /**
  26532. * Applies `autoplay` to video, if specified
  26533. */
  26534. autoPlay?: boolean;
  26535. /**
  26536. * Applies `loop` to video, if specified
  26537. */
  26538. loop?: boolean;
  26539. /**
  26540. * Automatically updates internal texture from video at every frame in the render loop
  26541. */
  26542. autoUpdateTexture: boolean;
  26543. /**
  26544. * Image src displayed during the video loading or until the user interacts with the video.
  26545. */
  26546. poster?: string;
  26547. }
  26548. /**
  26549. * If you want to display a video in your scene, this is the special texture for that.
  26550. * This special texture works similar to other textures, with the exception of a few parameters.
  26551. * @see https://doc.babylonjs.com/how_to/video_texture
  26552. */
  26553. export class VideoTexture extends Texture {
  26554. /**
  26555. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26556. */
  26557. readonly autoUpdateTexture: boolean;
  26558. /**
  26559. * The video instance used by the texture internally
  26560. */
  26561. readonly video: HTMLVideoElement;
  26562. private _onUserActionRequestedObservable;
  26563. /**
  26564. * Event triggerd when a dom action is required by the user to play the video.
  26565. * This happens due to recent changes in browser policies preventing video to auto start.
  26566. */
  26567. readonly onUserActionRequestedObservable: Observable<Texture>;
  26568. private _generateMipMaps;
  26569. private _engine;
  26570. private _stillImageCaptured;
  26571. private _displayingPosterTexture;
  26572. private _settings;
  26573. private _createInternalTextureOnEvent;
  26574. /**
  26575. * Creates a video texture.
  26576. * If you want to display a video in your scene, this is the special texture for that.
  26577. * This special texture works similar to other textures, with the exception of a few parameters.
  26578. * @see https://doc.babylonjs.com/how_to/video_texture
  26579. * @param name optional name, will detect from video source, if not defined
  26580. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26581. * @param scene is obviously the current scene.
  26582. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26583. * @param invertY is false by default but can be used to invert video on Y axis
  26584. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26585. * @param settings allows finer control over video usage
  26586. */
  26587. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26588. private _getName;
  26589. private _getVideo;
  26590. private _createInternalTexture;
  26591. private reset;
  26592. /**
  26593. * @hidden Internal method to initiate `update`.
  26594. */
  26595. _rebuild(): void;
  26596. /**
  26597. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26598. */
  26599. update(): void;
  26600. /**
  26601. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26602. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26603. */
  26604. updateTexture(isVisible: boolean): void;
  26605. protected _updateInternalTexture: () => void;
  26606. /**
  26607. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26608. * @param url New url.
  26609. */
  26610. updateURL(url: string): void;
  26611. /**
  26612. * Dispose the texture and release its associated resources.
  26613. */
  26614. dispose(): void;
  26615. /**
  26616. * Creates a video texture straight from your WebCam video feed.
  26617. * @param scene Define the scene the texture should be created in
  26618. * @param onReady Define a callback to triggered once the texture will be ready
  26619. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26620. */
  26621. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26622. minWidth: number;
  26623. maxWidth: number;
  26624. minHeight: number;
  26625. maxHeight: number;
  26626. deviceId: string;
  26627. }): void;
  26628. }
  26629. }
  26630. declare module "babylonjs/Engines/engine" {
  26631. import { Observable } from "babylonjs/Misc/observable";
  26632. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26633. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26634. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26635. import { Camera } from "babylonjs/Cameras/camera";
  26636. import { Scene } from "babylonjs/scene";
  26637. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26638. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26639. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26640. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26641. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26642. import { Material } from "babylonjs/Materials/material";
  26643. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26644. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26645. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26646. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26647. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26648. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26649. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26650. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26651. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26652. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26653. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26654. /**
  26655. * Interface for attribute information associated with buffer instanciation
  26656. */
  26657. export class InstancingAttributeInfo {
  26658. /**
  26659. * Index/offset of the attribute in the vertex shader
  26660. */
  26661. index: number;
  26662. /**
  26663. * size of the attribute, 1, 2, 3 or 4
  26664. */
  26665. attributeSize: number;
  26666. /**
  26667. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26668. * default is FLOAT
  26669. */
  26670. attribyteType: number;
  26671. /**
  26672. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26673. */
  26674. normalized: boolean;
  26675. /**
  26676. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26677. */
  26678. offset: number;
  26679. /**
  26680. * Name of the GLSL attribute, for debugging purpose only
  26681. */
  26682. attributeName: string;
  26683. }
  26684. /**
  26685. * Define options used to create a depth texture
  26686. */
  26687. export class DepthTextureCreationOptions {
  26688. /** Specifies whether or not a stencil should be allocated in the texture */
  26689. generateStencil?: boolean;
  26690. /** Specifies whether or not bilinear filtering is enable on the texture */
  26691. bilinearFiltering?: boolean;
  26692. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26693. comparisonFunction?: number;
  26694. /** Specifies if the created texture is a cube texture */
  26695. isCube?: boolean;
  26696. }
  26697. /**
  26698. * Class used to describe the capabilities of the engine relatively to the current browser
  26699. */
  26700. export class EngineCapabilities {
  26701. /** Maximum textures units per fragment shader */
  26702. maxTexturesImageUnits: number;
  26703. /** Maximum texture units per vertex shader */
  26704. maxVertexTextureImageUnits: number;
  26705. /** Maximum textures units in the entire pipeline */
  26706. maxCombinedTexturesImageUnits: number;
  26707. /** Maximum texture size */
  26708. maxTextureSize: number;
  26709. /** Maximum cube texture size */
  26710. maxCubemapTextureSize: number;
  26711. /** Maximum render texture size */
  26712. maxRenderTextureSize: number;
  26713. /** Maximum number of vertex attributes */
  26714. maxVertexAttribs: number;
  26715. /** Maximum number of varyings */
  26716. maxVaryingVectors: number;
  26717. /** Maximum number of uniforms per vertex shader */
  26718. maxVertexUniformVectors: number;
  26719. /** Maximum number of uniforms per fragment shader */
  26720. maxFragmentUniformVectors: number;
  26721. /** Defines if standard derivates (dx/dy) are supported */
  26722. standardDerivatives: boolean;
  26723. /** Defines if s3tc texture compression is supported */
  26724. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26725. /** Defines if pvrtc texture compression is supported */
  26726. pvrtc: any;
  26727. /** Defines if etc1 texture compression is supported */
  26728. etc1: any;
  26729. /** Defines if etc2 texture compression is supported */
  26730. etc2: any;
  26731. /** Defines if astc texture compression is supported */
  26732. astc: any;
  26733. /** Defines if float textures are supported */
  26734. textureFloat: boolean;
  26735. /** Defines if vertex array objects are supported */
  26736. vertexArrayObject: boolean;
  26737. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26738. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26739. /** Gets the maximum level of anisotropy supported */
  26740. maxAnisotropy: number;
  26741. /** Defines if instancing is supported */
  26742. instancedArrays: boolean;
  26743. /** Defines if 32 bits indices are supported */
  26744. uintIndices: boolean;
  26745. /** Defines if high precision shaders are supported */
  26746. highPrecisionShaderSupported: boolean;
  26747. /** Defines if depth reading in the fragment shader is supported */
  26748. fragmentDepthSupported: boolean;
  26749. /** Defines if float texture linear filtering is supported*/
  26750. textureFloatLinearFiltering: boolean;
  26751. /** Defines if rendering to float textures is supported */
  26752. textureFloatRender: boolean;
  26753. /** Defines if half float textures are supported*/
  26754. textureHalfFloat: boolean;
  26755. /** Defines if half float texture linear filtering is supported*/
  26756. textureHalfFloatLinearFiltering: boolean;
  26757. /** Defines if rendering to half float textures is supported */
  26758. textureHalfFloatRender: boolean;
  26759. /** Defines if textureLOD shader command is supported */
  26760. textureLOD: boolean;
  26761. /** Defines if draw buffers extension is supported */
  26762. drawBuffersExtension: boolean;
  26763. /** Defines if depth textures are supported */
  26764. depthTextureExtension: boolean;
  26765. /** Defines if float color buffer are supported */
  26766. colorBufferFloat: boolean;
  26767. /** Gets disjoint timer query extension (null if not supported) */
  26768. timerQuery: EXT_disjoint_timer_query;
  26769. /** Defines if timestamp can be used with timer query */
  26770. canUseTimestampForTimerQuery: boolean;
  26771. /** Function used to let the system compiles shaders in background */
  26772. parallelShaderCompile: {
  26773. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26774. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26775. COMPLETION_STATUS_KHR: number;
  26776. };
  26777. }
  26778. /** Interface defining initialization parameters for Engine class */
  26779. export interface EngineOptions extends WebGLContextAttributes {
  26780. /**
  26781. * Defines if the engine should no exceed a specified device ratio
  26782. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26783. */
  26784. limitDeviceRatio?: number;
  26785. /**
  26786. * Defines if webvr should be enabled automatically
  26787. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26788. */
  26789. autoEnableWebVR?: boolean;
  26790. /**
  26791. * Defines if webgl2 should be turned off even if supported
  26792. * @see http://doc.babylonjs.com/features/webgl2
  26793. */
  26794. disableWebGL2Support?: boolean;
  26795. /**
  26796. * Defines if webaudio should be initialized as well
  26797. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26798. */
  26799. audioEngine?: boolean;
  26800. /**
  26801. * Defines if animations should run using a deterministic lock step
  26802. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26803. */
  26804. deterministicLockstep?: boolean;
  26805. /** Defines the maximum steps to use with deterministic lock step mode */
  26806. lockstepMaxSteps?: number;
  26807. /**
  26808. * Defines that engine should ignore context lost events
  26809. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26810. */
  26811. doNotHandleContextLost?: boolean;
  26812. /**
  26813. * Defines that engine should ignore modifying touch action attribute and style
  26814. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26815. */
  26816. doNotHandleTouchAction?: boolean;
  26817. }
  26818. /**
  26819. * Defines the interface used by display changed events
  26820. */
  26821. export interface IDisplayChangedEventArgs {
  26822. /** Gets the vrDisplay object (if any) */
  26823. vrDisplay: Nullable<any>;
  26824. /** Gets a boolean indicating if webVR is supported */
  26825. vrSupported: boolean;
  26826. }
  26827. /**
  26828. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26829. */
  26830. export class Engine {
  26831. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26832. static ExceptionList: ({
  26833. key: string;
  26834. capture: string;
  26835. captureConstraint: number;
  26836. targets: string[];
  26837. } | {
  26838. key: string;
  26839. capture: null;
  26840. captureConstraint: null;
  26841. targets: string[];
  26842. })[];
  26843. /** Gets the list of created engines */
  26844. static readonly Instances: Engine[];
  26845. /**
  26846. * Gets the latest created engine
  26847. */
  26848. static readonly LastCreatedEngine: Nullable<Engine>;
  26849. /**
  26850. * Gets the latest created scene
  26851. */
  26852. static readonly LastCreatedScene: Nullable<Scene>;
  26853. /**
  26854. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26855. * @param flag defines which part of the materials must be marked as dirty
  26856. * @param predicate defines a predicate used to filter which materials should be affected
  26857. */
  26858. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26859. /**
  26860. * Hidden
  26861. */
  26862. static _TextureLoaders: IInternalTextureLoader[];
  26863. /** Defines that alpha blending is disabled */
  26864. static readonly ALPHA_DISABLE: number;
  26865. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26866. static readonly ALPHA_ADD: number;
  26867. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26868. static readonly ALPHA_COMBINE: number;
  26869. /** Defines that alpha blending to DEST - SRC * DEST */
  26870. static readonly ALPHA_SUBTRACT: number;
  26871. /** Defines that alpha blending to SRC * DEST */
  26872. static readonly ALPHA_MULTIPLY: number;
  26873. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26874. static readonly ALPHA_MAXIMIZED: number;
  26875. /** Defines that alpha blending to SRC + DEST */
  26876. static readonly ALPHA_ONEONE: number;
  26877. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26878. static readonly ALPHA_PREMULTIPLIED: number;
  26879. /**
  26880. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26881. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26882. */
  26883. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26884. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26885. static readonly ALPHA_INTERPOLATE: number;
  26886. /**
  26887. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26888. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26889. */
  26890. static readonly ALPHA_SCREENMODE: number;
  26891. /** Defines that the ressource is not delayed*/
  26892. static readonly DELAYLOADSTATE_NONE: number;
  26893. /** Defines that the ressource was successfully delay loaded */
  26894. static readonly DELAYLOADSTATE_LOADED: number;
  26895. /** Defines that the ressource is currently delay loading */
  26896. static readonly DELAYLOADSTATE_LOADING: number;
  26897. /** Defines that the ressource is delayed and has not started loading */
  26898. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26899. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26900. static readonly NEVER: number;
  26901. /** 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 */
  26902. static readonly ALWAYS: number;
  26903. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26904. static readonly LESS: number;
  26905. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26906. static readonly EQUAL: number;
  26907. /** 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 */
  26908. static readonly LEQUAL: number;
  26909. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26910. static readonly GREATER: number;
  26911. /** 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 */
  26912. static readonly GEQUAL: number;
  26913. /** 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 */
  26914. static readonly NOTEQUAL: number;
  26915. /** Passed to stencilOperation to specify that stencil value must be kept */
  26916. static readonly KEEP: number;
  26917. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26918. static readonly REPLACE: number;
  26919. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26920. static readonly INCR: number;
  26921. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26922. static readonly DECR: number;
  26923. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26924. static readonly INVERT: number;
  26925. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26926. static readonly INCR_WRAP: number;
  26927. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26928. static readonly DECR_WRAP: number;
  26929. /** Texture is not repeating outside of 0..1 UVs */
  26930. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26931. /** Texture is repeating outside of 0..1 UVs */
  26932. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26933. /** Texture is repeating and mirrored */
  26934. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26935. /** ALPHA */
  26936. static readonly TEXTUREFORMAT_ALPHA: number;
  26937. /** LUMINANCE */
  26938. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26939. /** LUMINANCE_ALPHA */
  26940. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26941. /** RGB */
  26942. static readonly TEXTUREFORMAT_RGB: number;
  26943. /** RGBA */
  26944. static readonly TEXTUREFORMAT_RGBA: number;
  26945. /** RED */
  26946. static readonly TEXTUREFORMAT_RED: number;
  26947. /** RED (2nd reference) */
  26948. static readonly TEXTUREFORMAT_R: number;
  26949. /** RG */
  26950. static readonly TEXTUREFORMAT_RG: number;
  26951. /** RED_INTEGER */
  26952. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26953. /** RED_INTEGER (2nd reference) */
  26954. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26955. /** RG_INTEGER */
  26956. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26957. /** RGB_INTEGER */
  26958. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26959. /** RGBA_INTEGER */
  26960. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26961. /** UNSIGNED_BYTE */
  26962. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26963. /** UNSIGNED_BYTE (2nd reference) */
  26964. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26965. /** FLOAT */
  26966. static readonly TEXTURETYPE_FLOAT: number;
  26967. /** HALF_FLOAT */
  26968. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26969. /** BYTE */
  26970. static readonly TEXTURETYPE_BYTE: number;
  26971. /** SHORT */
  26972. static readonly TEXTURETYPE_SHORT: number;
  26973. /** UNSIGNED_SHORT */
  26974. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26975. /** INT */
  26976. static readonly TEXTURETYPE_INT: number;
  26977. /** UNSIGNED_INT */
  26978. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26979. /** UNSIGNED_SHORT_4_4_4_4 */
  26980. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26981. /** UNSIGNED_SHORT_5_5_5_1 */
  26982. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26983. /** UNSIGNED_SHORT_5_6_5 */
  26984. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26985. /** UNSIGNED_INT_2_10_10_10_REV */
  26986. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26987. /** UNSIGNED_INT_24_8 */
  26988. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26989. /** UNSIGNED_INT_10F_11F_11F_REV */
  26990. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26991. /** UNSIGNED_INT_5_9_9_9_REV */
  26992. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26993. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26994. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26995. /** nearest is mag = nearest and min = nearest and mip = linear */
  26996. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26997. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26998. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  26999. /** Trilinear is mag = linear and min = linear and mip = linear */
  27000. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27001. /** nearest is mag = nearest and min = nearest and mip = linear */
  27002. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27003. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27004. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27005. /** Trilinear is mag = linear and min = linear and mip = linear */
  27006. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27007. /** mag = nearest and min = nearest and mip = nearest */
  27008. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27009. /** mag = nearest and min = linear and mip = nearest */
  27010. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27011. /** mag = nearest and min = linear and mip = linear */
  27012. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27013. /** mag = nearest and min = linear and mip = none */
  27014. static readonly TEXTURE_NEAREST_LINEAR: number;
  27015. /** mag = nearest and min = nearest and mip = none */
  27016. static readonly TEXTURE_NEAREST_NEAREST: number;
  27017. /** mag = linear and min = nearest and mip = nearest */
  27018. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27019. /** mag = linear and min = nearest and mip = linear */
  27020. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27021. /** mag = linear and min = linear and mip = none */
  27022. static readonly TEXTURE_LINEAR_LINEAR: number;
  27023. /** mag = linear and min = nearest and mip = none */
  27024. static readonly TEXTURE_LINEAR_NEAREST: number;
  27025. /** Explicit coordinates mode */
  27026. static readonly TEXTURE_EXPLICIT_MODE: number;
  27027. /** Spherical coordinates mode */
  27028. static readonly TEXTURE_SPHERICAL_MODE: number;
  27029. /** Planar coordinates mode */
  27030. static readonly TEXTURE_PLANAR_MODE: number;
  27031. /** Cubic coordinates mode */
  27032. static readonly TEXTURE_CUBIC_MODE: number;
  27033. /** Projection coordinates mode */
  27034. static readonly TEXTURE_PROJECTION_MODE: number;
  27035. /** Skybox coordinates mode */
  27036. static readonly TEXTURE_SKYBOX_MODE: number;
  27037. /** Inverse Cubic coordinates mode */
  27038. static readonly TEXTURE_INVCUBIC_MODE: number;
  27039. /** Equirectangular coordinates mode */
  27040. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27041. /** Equirectangular Fixed coordinates mode */
  27042. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27043. /** Equirectangular Fixed Mirrored coordinates mode */
  27044. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27045. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27046. static readonly SCALEMODE_FLOOR: number;
  27047. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27048. static readonly SCALEMODE_NEAREST: number;
  27049. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27050. static readonly SCALEMODE_CEILING: number;
  27051. /**
  27052. * Returns the current version of the framework
  27053. */
  27054. static readonly Version: string;
  27055. /**
  27056. * Returns a string describing the current engine
  27057. */
  27058. readonly description: string;
  27059. /**
  27060. * Gets or sets the epsilon value used by collision engine
  27061. */
  27062. static CollisionsEpsilon: number;
  27063. /**
  27064. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27065. */
  27066. static ShadersRepository: string;
  27067. /**
  27068. * Method called to create the default loading screen.
  27069. * This can be overriden in your own app.
  27070. * @param canvas The rendering canvas element
  27071. * @returns The loading screen
  27072. */
  27073. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27074. /**
  27075. * Method called to create the default rescale post process on each engine.
  27076. */
  27077. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27078. /**
  27079. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27080. */
  27081. forcePOTTextures: boolean;
  27082. /**
  27083. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27084. */
  27085. isFullscreen: boolean;
  27086. /**
  27087. * Gets a boolean indicating if the pointer is currently locked
  27088. */
  27089. isPointerLock: boolean;
  27090. /**
  27091. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27092. */
  27093. cullBackFaces: boolean;
  27094. /**
  27095. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27096. */
  27097. renderEvenInBackground: boolean;
  27098. /**
  27099. * Gets or sets a boolean indicating that cache can be kept between frames
  27100. */
  27101. preventCacheWipeBetweenFrames: boolean;
  27102. /**
  27103. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27104. **/
  27105. enableOfflineSupport: boolean;
  27106. /**
  27107. * 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)
  27108. **/
  27109. disableManifestCheck: boolean;
  27110. /**
  27111. * Gets the list of created scenes
  27112. */
  27113. scenes: Scene[];
  27114. /**
  27115. * Event raised when a new scene is created
  27116. */
  27117. onNewSceneAddedObservable: Observable<Scene>;
  27118. /**
  27119. * Gets the list of created postprocesses
  27120. */
  27121. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27122. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27123. validateShaderPrograms: boolean;
  27124. /**
  27125. * Observable event triggered each time the rendering canvas is resized
  27126. */
  27127. onResizeObservable: Observable<Engine>;
  27128. /**
  27129. * Observable event triggered each time the canvas loses focus
  27130. */
  27131. onCanvasBlurObservable: Observable<Engine>;
  27132. /**
  27133. * Observable event triggered each time the canvas gains focus
  27134. */
  27135. onCanvasFocusObservable: Observable<Engine>;
  27136. /**
  27137. * Observable event triggered each time the canvas receives pointerout event
  27138. */
  27139. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27140. /**
  27141. * Observable event triggered before each texture is initialized
  27142. */
  27143. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27144. private _vrDisplay;
  27145. private _vrSupported;
  27146. private _oldSize;
  27147. private _oldHardwareScaleFactor;
  27148. private _vrExclusivePointerMode;
  27149. private _webVRInitPromise;
  27150. /**
  27151. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27152. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27153. */
  27154. readonly isInVRExclusivePointerMode: boolean;
  27155. /**
  27156. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27157. */
  27158. disableUniformBuffers: boolean;
  27159. /** @hidden */
  27160. _uniformBuffers: UniformBuffer[];
  27161. /**
  27162. * Gets a boolean indicating that the engine supports uniform buffers
  27163. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27164. */
  27165. readonly supportsUniformBuffers: boolean;
  27166. /**
  27167. * Observable raised when the engine begins a new frame
  27168. */
  27169. onBeginFrameObservable: Observable<Engine>;
  27170. /**
  27171. * If set, will be used to request the next animation frame for the render loop
  27172. */
  27173. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27174. /**
  27175. * Observable raised when the engine ends the current frame
  27176. */
  27177. onEndFrameObservable: Observable<Engine>;
  27178. /**
  27179. * Observable raised when the engine is about to compile a shader
  27180. */
  27181. onBeforeShaderCompilationObservable: Observable<Engine>;
  27182. /**
  27183. * Observable raised when the engine has jsut compiled a shader
  27184. */
  27185. onAfterShaderCompilationObservable: Observable<Engine>;
  27186. /** @hidden */
  27187. _gl: WebGLRenderingContext;
  27188. private _renderingCanvas;
  27189. private _windowIsBackground;
  27190. private _webGLVersion;
  27191. /**
  27192. * Gets a boolean indicating that only power of 2 textures are supported
  27193. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27194. */
  27195. readonly needPOTTextures: boolean;
  27196. /** @hidden */
  27197. _badOS: boolean;
  27198. /** @hidden */
  27199. _badDesktopOS: boolean;
  27200. /**
  27201. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27202. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27203. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27204. */
  27205. disableTextureBindingOptimization: boolean;
  27206. /**
  27207. * Gets the audio engine
  27208. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27209. * @ignorenaming
  27210. */
  27211. static audioEngine: IAudioEngine;
  27212. /**
  27213. * Default AudioEngine factory responsible of creating the Audio Engine.
  27214. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27215. */
  27216. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27217. /**
  27218. * Default offline support factory responsible of creating a tool used to store data locally.
  27219. * By default, this will create a Database object if the workload has been embedded.
  27220. */
  27221. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27222. private _onFocus;
  27223. private _onBlur;
  27224. private _onCanvasPointerOut;
  27225. private _onCanvasBlur;
  27226. private _onCanvasFocus;
  27227. private _onFullscreenChange;
  27228. private _onPointerLockChange;
  27229. private _onVRDisplayPointerRestricted;
  27230. private _onVRDisplayPointerUnrestricted;
  27231. private _onVrDisplayConnect;
  27232. private _onVrDisplayDisconnect;
  27233. private _onVrDisplayPresentChange;
  27234. /**
  27235. * Observable signaled when VR display mode changes
  27236. */
  27237. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27238. /**
  27239. * Observable signaled when VR request present is complete
  27240. */
  27241. onVRRequestPresentComplete: Observable<boolean>;
  27242. /**
  27243. * Observable signaled when VR request present starts
  27244. */
  27245. onVRRequestPresentStart: Observable<Engine>;
  27246. private _hardwareScalingLevel;
  27247. /** @hidden */
  27248. protected _caps: EngineCapabilities;
  27249. private _pointerLockRequested;
  27250. private _isStencilEnable;
  27251. private _colorWrite;
  27252. private _loadingScreen;
  27253. /** @hidden */
  27254. _drawCalls: PerfCounter;
  27255. /** @hidden */
  27256. _textureCollisions: PerfCounter;
  27257. private _glVersion;
  27258. private _glRenderer;
  27259. private _glVendor;
  27260. private _videoTextureSupported;
  27261. private _renderingQueueLaunched;
  27262. private _activeRenderLoops;
  27263. private _deterministicLockstep;
  27264. private _lockstepMaxSteps;
  27265. /**
  27266. * Observable signaled when a context lost event is raised
  27267. */
  27268. onContextLostObservable: Observable<Engine>;
  27269. /**
  27270. * Observable signaled when a context restored event is raised
  27271. */
  27272. onContextRestoredObservable: Observable<Engine>;
  27273. private _onContextLost;
  27274. private _onContextRestored;
  27275. private _contextWasLost;
  27276. private _doNotHandleContextLost;
  27277. /**
  27278. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27279. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27280. */
  27281. doNotHandleContextLost: boolean;
  27282. private _performanceMonitor;
  27283. private _fps;
  27284. private _deltaTime;
  27285. /**
  27286. * Turn this value on if you want to pause FPS computation when in background
  27287. */
  27288. disablePerformanceMonitorInBackground: boolean;
  27289. /**
  27290. * Gets the performance monitor attached to this engine
  27291. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27292. */
  27293. readonly performanceMonitor: PerformanceMonitor;
  27294. /** @hidden */
  27295. protected _depthCullingState: _DepthCullingState;
  27296. /** @hidden */
  27297. protected _stencilState: _StencilState;
  27298. /** @hidden */
  27299. protected _alphaState: _AlphaState;
  27300. /** @hidden */
  27301. protected _alphaMode: number;
  27302. protected _internalTexturesCache: InternalTexture[];
  27303. /** @hidden */
  27304. protected _activeChannel: number;
  27305. private _currentTextureChannel;
  27306. /** @hidden */
  27307. protected _boundTexturesCache: {
  27308. [key: string]: Nullable<InternalTexture>;
  27309. };
  27310. /** @hidden */
  27311. protected _currentEffect: Nullable<Effect>;
  27312. /** @hidden */
  27313. protected _currentProgram: Nullable<WebGLProgram>;
  27314. private _compiledEffects;
  27315. private _vertexAttribArraysEnabled;
  27316. /** @hidden */
  27317. protected _cachedViewport: Nullable<Viewport>;
  27318. private _cachedVertexArrayObject;
  27319. /** @hidden */
  27320. protected _cachedVertexBuffers: any;
  27321. /** @hidden */
  27322. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27323. /** @hidden */
  27324. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27325. /** @hidden */
  27326. protected _currentRenderTarget: Nullable<InternalTexture>;
  27327. private _uintIndicesCurrentlySet;
  27328. private _currentBoundBuffer;
  27329. /** @hidden */
  27330. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27331. private _currentBufferPointers;
  27332. private _currentInstanceLocations;
  27333. private _currentInstanceBuffers;
  27334. private _textureUnits;
  27335. private _firstBoundInternalTextureTracker;
  27336. private _lastBoundInternalTextureTracker;
  27337. private _workingCanvas;
  27338. private _workingContext;
  27339. private _rescalePostProcess;
  27340. private _dummyFramebuffer;
  27341. private _externalData;
  27342. private _bindedRenderFunction;
  27343. private _vaoRecordInProgress;
  27344. private _mustWipeVertexAttributes;
  27345. private _emptyTexture;
  27346. private _emptyCubeTexture;
  27347. private _emptyTexture3D;
  27348. /** @hidden */
  27349. _frameHandler: number;
  27350. private _nextFreeTextureSlots;
  27351. private _maxSimultaneousTextures;
  27352. private _activeRequests;
  27353. private _texturesSupported;
  27354. private _textureFormatInUse;
  27355. /**
  27356. * Gets the list of texture formats supported
  27357. */
  27358. readonly texturesSupported: Array<string>;
  27359. /**
  27360. * Gets the list of texture formats in use
  27361. */
  27362. readonly textureFormatInUse: Nullable<string>;
  27363. /**
  27364. * Gets the current viewport
  27365. */
  27366. readonly currentViewport: Nullable<Viewport>;
  27367. /**
  27368. * Gets the default empty texture
  27369. */
  27370. readonly emptyTexture: InternalTexture;
  27371. /**
  27372. * Gets the default empty 3D texture
  27373. */
  27374. readonly emptyTexture3D: InternalTexture;
  27375. /**
  27376. * Gets the default empty cube texture
  27377. */
  27378. readonly emptyCubeTexture: InternalTexture;
  27379. /**
  27380. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27381. */
  27382. readonly premultipliedAlpha: boolean;
  27383. /**
  27384. * Creates a new engine
  27385. * @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
  27386. * @param antialias defines enable antialiasing (default: false)
  27387. * @param options defines further options to be sent to the getContext() function
  27388. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27389. */
  27390. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27391. private _disableTouchAction;
  27392. private _rebuildInternalTextures;
  27393. private _rebuildEffects;
  27394. /**
  27395. * Gets a boolean indicating if all created effects are ready
  27396. * @returns true if all effects are ready
  27397. */
  27398. areAllEffectsReady(): boolean;
  27399. private _rebuildBuffers;
  27400. private _initGLContext;
  27401. /**
  27402. * Gets version of the current webGL context
  27403. */
  27404. readonly webGLVersion: number;
  27405. /**
  27406. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27407. */
  27408. readonly isStencilEnable: boolean;
  27409. private _prepareWorkingCanvas;
  27410. /**
  27411. * Reset the texture cache to empty state
  27412. */
  27413. resetTextureCache(): void;
  27414. /**
  27415. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27416. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27417. * @returns true if engine is in deterministic lock step mode
  27418. */
  27419. isDeterministicLockStep(): boolean;
  27420. /**
  27421. * Gets the max steps when engine is running in deterministic lock step
  27422. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27423. * @returns the max steps
  27424. */
  27425. getLockstepMaxSteps(): number;
  27426. /**
  27427. * Gets an object containing information about the current webGL context
  27428. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27429. */
  27430. getGlInfo(): {
  27431. vendor: string;
  27432. renderer: string;
  27433. version: string;
  27434. };
  27435. /**
  27436. * Gets current aspect ratio
  27437. * @param camera defines the camera to use to get the aspect ratio
  27438. * @param useScreen defines if screen size must be used (or the current render target if any)
  27439. * @returns a number defining the aspect ratio
  27440. */
  27441. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27442. /**
  27443. * Gets current screen aspect ratio
  27444. * @returns a number defining the aspect ratio
  27445. */
  27446. getScreenAspectRatio(): number;
  27447. /**
  27448. * Gets the current render width
  27449. * @param useScreen defines if screen size must be used (or the current render target if any)
  27450. * @returns a number defining the current render width
  27451. */
  27452. getRenderWidth(useScreen?: boolean): number;
  27453. /**
  27454. * Gets the current render height
  27455. * @param useScreen defines if screen size must be used (or the current render target if any)
  27456. * @returns a number defining the current render height
  27457. */
  27458. getRenderHeight(useScreen?: boolean): number;
  27459. /**
  27460. * Gets the HTML canvas attached with the current webGL context
  27461. * @returns a HTML canvas
  27462. */
  27463. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27464. /**
  27465. * Gets the client rect of the HTML canvas attached with the current webGL context
  27466. * @returns a client rectanglee
  27467. */
  27468. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27469. /**
  27470. * Defines the hardware scaling level.
  27471. * By default the hardware scaling level is computed from the window device ratio.
  27472. * 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.
  27473. * @param level defines the level to use
  27474. */
  27475. setHardwareScalingLevel(level: number): void;
  27476. /**
  27477. * Gets the current hardware scaling level.
  27478. * By default the hardware scaling level is computed from the window device ratio.
  27479. * 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.
  27480. * @returns a number indicating the current hardware scaling level
  27481. */
  27482. getHardwareScalingLevel(): number;
  27483. /**
  27484. * Gets the list of loaded textures
  27485. * @returns an array containing all loaded textures
  27486. */
  27487. getLoadedTexturesCache(): InternalTexture[];
  27488. /**
  27489. * Gets the object containing all engine capabilities
  27490. * @returns the EngineCapabilities object
  27491. */
  27492. getCaps(): EngineCapabilities;
  27493. /**
  27494. * Gets the current depth function
  27495. * @returns a number defining the depth function
  27496. */
  27497. getDepthFunction(): Nullable<number>;
  27498. /**
  27499. * Sets the current depth function
  27500. * @param depthFunc defines the function to use
  27501. */
  27502. setDepthFunction(depthFunc: number): void;
  27503. /**
  27504. * Sets the current depth function to GREATER
  27505. */
  27506. setDepthFunctionToGreater(): void;
  27507. /**
  27508. * Sets the current depth function to GEQUAL
  27509. */
  27510. setDepthFunctionToGreaterOrEqual(): void;
  27511. /**
  27512. * Sets the current depth function to LESS
  27513. */
  27514. setDepthFunctionToLess(): void;
  27515. /**
  27516. * Sets the current depth function to LEQUAL
  27517. */
  27518. setDepthFunctionToLessOrEqual(): void;
  27519. /**
  27520. * Gets a boolean indicating if stencil buffer is enabled
  27521. * @returns the current stencil buffer state
  27522. */
  27523. getStencilBuffer(): boolean;
  27524. /**
  27525. * Enable or disable the stencil buffer
  27526. * @param enable defines if the stencil buffer must be enabled or disabled
  27527. */
  27528. setStencilBuffer(enable: boolean): void;
  27529. /**
  27530. * Gets the current stencil mask
  27531. * @returns a number defining the new stencil mask to use
  27532. */
  27533. getStencilMask(): number;
  27534. /**
  27535. * Sets the current stencil mask
  27536. * @param mask defines the new stencil mask to use
  27537. */
  27538. setStencilMask(mask: number): void;
  27539. /**
  27540. * Gets the current stencil function
  27541. * @returns a number defining the stencil function to use
  27542. */
  27543. getStencilFunction(): number;
  27544. /**
  27545. * Gets the current stencil reference value
  27546. * @returns a number defining the stencil reference value to use
  27547. */
  27548. getStencilFunctionReference(): number;
  27549. /**
  27550. * Gets the current stencil mask
  27551. * @returns a number defining the stencil mask to use
  27552. */
  27553. getStencilFunctionMask(): number;
  27554. /**
  27555. * Sets the current stencil function
  27556. * @param stencilFunc defines the new stencil function to use
  27557. */
  27558. setStencilFunction(stencilFunc: number): void;
  27559. /**
  27560. * Sets the current stencil reference
  27561. * @param reference defines the new stencil reference to use
  27562. */
  27563. setStencilFunctionReference(reference: number): void;
  27564. /**
  27565. * Sets the current stencil mask
  27566. * @param mask defines the new stencil mask to use
  27567. */
  27568. setStencilFunctionMask(mask: number): void;
  27569. /**
  27570. * Gets the current stencil operation when stencil fails
  27571. * @returns a number defining stencil operation to use when stencil fails
  27572. */
  27573. getStencilOperationFail(): number;
  27574. /**
  27575. * Gets the current stencil operation when depth fails
  27576. * @returns a number defining stencil operation to use when depth fails
  27577. */
  27578. getStencilOperationDepthFail(): number;
  27579. /**
  27580. * Gets the current stencil operation when stencil passes
  27581. * @returns a number defining stencil operation to use when stencil passes
  27582. */
  27583. getStencilOperationPass(): number;
  27584. /**
  27585. * Sets the stencil operation to use when stencil fails
  27586. * @param operation defines the stencil operation to use when stencil fails
  27587. */
  27588. setStencilOperationFail(operation: number): void;
  27589. /**
  27590. * Sets the stencil operation to use when depth fails
  27591. * @param operation defines the stencil operation to use when depth fails
  27592. */
  27593. setStencilOperationDepthFail(operation: number): void;
  27594. /**
  27595. * Sets the stencil operation to use when stencil passes
  27596. * @param operation defines the stencil operation to use when stencil passes
  27597. */
  27598. setStencilOperationPass(operation: number): void;
  27599. /**
  27600. * Sets a boolean indicating if the dithering state is enabled or disabled
  27601. * @param value defines the dithering state
  27602. */
  27603. setDitheringState(value: boolean): void;
  27604. /**
  27605. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27606. * @param value defines the rasterizer state
  27607. */
  27608. setRasterizerState(value: boolean): void;
  27609. /**
  27610. * stop executing a render loop function and remove it from the execution array
  27611. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27612. */
  27613. stopRenderLoop(renderFunction?: () => void): void;
  27614. /** @hidden */
  27615. _renderLoop(): void;
  27616. /**
  27617. * Register and execute a render loop. The engine can have more than one render function
  27618. * @param renderFunction defines the function to continuously execute
  27619. */
  27620. runRenderLoop(renderFunction: () => void): void;
  27621. /**
  27622. * Toggle full screen mode
  27623. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27624. */
  27625. switchFullscreen(requestPointerLock: boolean): void;
  27626. /**
  27627. * Clear the current render buffer or the current render target (if any is set up)
  27628. * @param color defines the color to use
  27629. * @param backBuffer defines if the back buffer must be cleared
  27630. * @param depth defines if the depth buffer must be cleared
  27631. * @param stencil defines if the stencil buffer must be cleared
  27632. */
  27633. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27634. /**
  27635. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27636. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27637. * @param y defines the y-coordinate of the corner of the clear rectangle
  27638. * @param width defines the width of the clear rectangle
  27639. * @param height defines the height of the clear rectangle
  27640. * @param clearColor defines the clear color
  27641. */
  27642. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27643. /**
  27644. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27645. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27646. * @param y defines the y-coordinate of the corner of the clear rectangle
  27647. * @param width defines the width of the clear rectangle
  27648. * @param height defines the height of the clear rectangle
  27649. */
  27650. enableScissor(x: number, y: number, width: number, height: number): void;
  27651. /**
  27652. * Disable previously set scissor test rectangle
  27653. */
  27654. disableScissor(): void;
  27655. private _viewportCached;
  27656. /** @hidden */
  27657. _viewport(x: number, y: number, width: number, height: number): void;
  27658. /**
  27659. * Set the WebGL's viewport
  27660. * @param viewport defines the viewport element to be used
  27661. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27662. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27663. */
  27664. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27665. /**
  27666. * Directly set the WebGL Viewport
  27667. * @param x defines the x coordinate of the viewport (in screen space)
  27668. * @param y defines the y coordinate of the viewport (in screen space)
  27669. * @param width defines the width of the viewport (in screen space)
  27670. * @param height defines the height of the viewport (in screen space)
  27671. * @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
  27672. */
  27673. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27674. /**
  27675. * Begin a new frame
  27676. */
  27677. beginFrame(): void;
  27678. /**
  27679. * Enf the current frame
  27680. */
  27681. endFrame(): void;
  27682. /**
  27683. * Resize the view according to the canvas' size
  27684. */
  27685. resize(): void;
  27686. /**
  27687. * Force a specific size of the canvas
  27688. * @param width defines the new canvas' width
  27689. * @param height defines the new canvas' height
  27690. */
  27691. setSize(width: number, height: number): void;
  27692. /**
  27693. * Gets a boolean indicating if a webVR device was detected
  27694. * @returns true if a webVR device was detected
  27695. */
  27696. isVRDevicePresent(): boolean;
  27697. /**
  27698. * Gets the current webVR device
  27699. * @returns the current webVR device (or null)
  27700. */
  27701. getVRDevice(): any;
  27702. /**
  27703. * Initializes a webVR display and starts listening to display change events
  27704. * The onVRDisplayChangedObservable will be notified upon these changes
  27705. * @returns The onVRDisplayChangedObservable
  27706. */
  27707. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27708. /**
  27709. * Initializes a webVR display and starts listening to display change events
  27710. * The onVRDisplayChangedObservable will be notified upon these changes
  27711. * @returns A promise containing a VRDisplay and if vr is supported
  27712. */
  27713. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27714. /**
  27715. * Call this function to switch to webVR mode
  27716. * Will do nothing if webVR is not supported or if there is no webVR device
  27717. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27718. */
  27719. enableVR(): void;
  27720. /**
  27721. * Call this function to leave webVR mode
  27722. * Will do nothing if webVR is not supported or if there is no webVR device
  27723. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27724. */
  27725. disableVR(): void;
  27726. private _onVRFullScreenTriggered;
  27727. private _getVRDisplaysAsync;
  27728. /**
  27729. * Binds the frame buffer to the specified texture.
  27730. * @param texture The texture to render to or null for the default canvas
  27731. * @param faceIndex The face of the texture to render to in case of cube texture
  27732. * @param requiredWidth The width of the target to render to
  27733. * @param requiredHeight The height of the target to render to
  27734. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27735. * @param depthStencilTexture The depth stencil texture to use to render
  27736. * @param lodLevel defines le lod level to bind to the frame buffer
  27737. */
  27738. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27739. private bindUnboundFramebuffer;
  27740. /**
  27741. * Unbind the current render target texture from the webGL context
  27742. * @param texture defines the render target texture to unbind
  27743. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27744. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27745. */
  27746. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27747. /**
  27748. * Unbind a list of render target textures from the webGL context
  27749. * This is used only when drawBuffer extension or webGL2 are active
  27750. * @param textures defines the render target textures to unbind
  27751. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27752. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27753. */
  27754. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27755. /**
  27756. * Force the mipmap generation for the given render target texture
  27757. * @param texture defines the render target texture to use
  27758. */
  27759. generateMipMapsForCubemap(texture: InternalTexture): void;
  27760. /**
  27761. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27762. */
  27763. flushFramebuffer(): void;
  27764. /**
  27765. * Unbind the current render target and bind the default framebuffer
  27766. */
  27767. restoreDefaultFramebuffer(): void;
  27768. /**
  27769. * Create an uniform buffer
  27770. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27771. * @param elements defines the content of the uniform buffer
  27772. * @returns the webGL uniform buffer
  27773. */
  27774. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27775. /**
  27776. * Create a dynamic uniform buffer
  27777. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27778. * @param elements defines the content of the uniform buffer
  27779. * @returns the webGL uniform buffer
  27780. */
  27781. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27782. /**
  27783. * Update an existing uniform buffer
  27784. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27785. * @param uniformBuffer defines the target uniform buffer
  27786. * @param elements defines the content to update
  27787. * @param offset defines the offset in the uniform buffer where update should start
  27788. * @param count defines the size of the data to update
  27789. */
  27790. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27791. private _resetVertexBufferBinding;
  27792. /**
  27793. * Creates a vertex buffer
  27794. * @param data the data for the vertex buffer
  27795. * @returns the new WebGL static buffer
  27796. */
  27797. createVertexBuffer(data: DataArray): WebGLBuffer;
  27798. /**
  27799. * Creates a dynamic vertex buffer
  27800. * @param data the data for the dynamic vertex buffer
  27801. * @returns the new WebGL dynamic buffer
  27802. */
  27803. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27804. /**
  27805. * Update a dynamic index buffer
  27806. * @param indexBuffer defines the target index buffer
  27807. * @param indices defines the data to update
  27808. * @param offset defines the offset in the target index buffer where update should start
  27809. */
  27810. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27811. /**
  27812. * Updates a dynamic vertex buffer.
  27813. * @param vertexBuffer the vertex buffer to update
  27814. * @param data the data used to update the vertex buffer
  27815. * @param byteOffset the byte offset of the data
  27816. * @param byteLength the byte length of the data
  27817. */
  27818. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27819. private _resetIndexBufferBinding;
  27820. /**
  27821. * Creates a new index buffer
  27822. * @param indices defines the content of the index buffer
  27823. * @param updatable defines if the index buffer must be updatable
  27824. * @returns a new webGL buffer
  27825. */
  27826. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27827. /**
  27828. * Bind a webGL buffer to the webGL context
  27829. * @param buffer defines the buffer to bind
  27830. */
  27831. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27832. /**
  27833. * Bind an uniform buffer to the current webGL context
  27834. * @param buffer defines the buffer to bind
  27835. */
  27836. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27837. /**
  27838. * Bind a buffer to the current webGL context at a given location
  27839. * @param buffer defines the buffer to bind
  27840. * @param location defines the index where to bind the buffer
  27841. */
  27842. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27843. /**
  27844. * Bind a specific block at a given index in a specific shader program
  27845. * @param shaderProgram defines the shader program
  27846. * @param blockName defines the block name
  27847. * @param index defines the index where to bind the block
  27848. */
  27849. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27850. private bindIndexBuffer;
  27851. private bindBuffer;
  27852. /**
  27853. * update the bound buffer with the given data
  27854. * @param data defines the data to update
  27855. */
  27856. updateArrayBuffer(data: Float32Array): void;
  27857. private _vertexAttribPointer;
  27858. private _bindIndexBufferWithCache;
  27859. private _bindVertexBuffersAttributes;
  27860. /**
  27861. * Records a vertex array object
  27862. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27863. * @param vertexBuffers defines the list of vertex buffers to store
  27864. * @param indexBuffer defines the index buffer to store
  27865. * @param effect defines the effect to store
  27866. * @returns the new vertex array object
  27867. */
  27868. recordVertexArrayObject(vertexBuffers: {
  27869. [key: string]: VertexBuffer;
  27870. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27871. /**
  27872. * Bind a specific vertex array object
  27873. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27874. * @param vertexArrayObject defines the vertex array object to bind
  27875. * @param indexBuffer defines the index buffer to bind
  27876. */
  27877. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27878. /**
  27879. * Bind webGl buffers directly to the webGL context
  27880. * @param vertexBuffer defines the vertex buffer to bind
  27881. * @param indexBuffer defines the index buffer to bind
  27882. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27883. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27884. * @param effect defines the effect associated with the vertex buffer
  27885. */
  27886. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27887. private _unbindVertexArrayObject;
  27888. /**
  27889. * Bind a list of vertex buffers to the webGL context
  27890. * @param vertexBuffers defines the list of vertex buffers to bind
  27891. * @param indexBuffer defines the index buffer to bind
  27892. * @param effect defines the effect associated with the vertex buffers
  27893. */
  27894. bindBuffers(vertexBuffers: {
  27895. [key: string]: Nullable<VertexBuffer>;
  27896. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27897. /**
  27898. * Unbind all instance attributes
  27899. */
  27900. unbindInstanceAttributes(): void;
  27901. /**
  27902. * Release and free the memory of a vertex array object
  27903. * @param vao defines the vertex array object to delete
  27904. */
  27905. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27906. /** @hidden */
  27907. _releaseBuffer(buffer: WebGLBuffer): boolean;
  27908. /**
  27909. * Creates a webGL buffer to use with instanciation
  27910. * @param capacity defines the size of the buffer
  27911. * @returns the webGL buffer
  27912. */
  27913. createInstancesBuffer(capacity: number): WebGLBuffer;
  27914. /**
  27915. * Delete a webGL buffer used with instanciation
  27916. * @param buffer defines the webGL buffer to delete
  27917. */
  27918. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27919. /**
  27920. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27921. * @param instancesBuffer defines the webGL buffer to update and bind
  27922. * @param data defines the data to store in the buffer
  27923. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27924. */
  27925. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27926. /**
  27927. * Apply all cached states (depth, culling, stencil and alpha)
  27928. */
  27929. applyStates(): void;
  27930. /**
  27931. * Send a draw order
  27932. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27933. * @param indexStart defines the starting index
  27934. * @param indexCount defines the number of index to draw
  27935. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27936. */
  27937. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27938. /**
  27939. * Draw a list of points
  27940. * @param verticesStart defines the index of first vertex to draw
  27941. * @param verticesCount defines the count of vertices to draw
  27942. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27943. */
  27944. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27945. /**
  27946. * Draw a list of unindexed primitives
  27947. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27948. * @param verticesStart defines the index of first vertex to draw
  27949. * @param verticesCount defines the count of vertices to draw
  27950. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27951. */
  27952. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27953. /**
  27954. * Draw a list of indexed primitives
  27955. * @param fillMode defines the primitive to use
  27956. * @param indexStart defines the starting index
  27957. * @param indexCount defines the number of index to draw
  27958. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27959. */
  27960. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27961. /**
  27962. * Draw a list of unindexed primitives
  27963. * @param fillMode defines the primitive to use
  27964. * @param verticesStart defines the index of first vertex to draw
  27965. * @param verticesCount defines the count of vertices to draw
  27966. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27967. */
  27968. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27969. private _drawMode;
  27970. /** @hidden */
  27971. _releaseEffect(effect: Effect): void;
  27972. /** @hidden */
  27973. _deleteProgram(program: WebGLProgram): void;
  27974. /**
  27975. * Create a new effect (used to store vertex/fragment shaders)
  27976. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27977. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27978. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27979. * @param samplers defines an array of string used to represent textures
  27980. * @param defines defines the string containing the defines to use to compile the shaders
  27981. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27982. * @param onCompiled defines a function to call when the effect creation is successful
  27983. * @param onError defines a function to call when the effect creation has failed
  27984. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27985. * @returns the new Effect
  27986. */
  27987. 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;
  27988. private _compileShader;
  27989. private _compileRawShader;
  27990. /**
  27991. * Directly creates a webGL program
  27992. * @param vertexCode defines the vertex shader code to use
  27993. * @param fragmentCode defines the fragment shader code to use
  27994. * @param context defines the webGL context to use (if not set, the current one will be used)
  27995. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27996. * @returns the new webGL program
  27997. */
  27998. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27999. /**
  28000. * Creates a webGL program
  28001. * @param vertexCode defines the vertex shader code to use
  28002. * @param fragmentCode defines the fragment shader code to use
  28003. * @param defines defines the string containing the defines to use to compile the shaders
  28004. * @param context defines the webGL context to use (if not set, the current one will be used)
  28005. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28006. * @returns the new webGL program
  28007. */
  28008. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28009. private _createShaderProgram;
  28010. private _finalizeProgram;
  28011. /** @hidden */
  28012. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28013. /** @hidden */
  28014. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28015. /**
  28016. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28017. * @param shaderProgram defines the webGL program to use
  28018. * @param uniformsNames defines the list of uniform names
  28019. * @returns an array of webGL uniform locations
  28020. */
  28021. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28022. /**
  28023. * Gets the lsit of active attributes for a given webGL program
  28024. * @param shaderProgram defines the webGL program to use
  28025. * @param attributesNames defines the list of attribute names to get
  28026. * @returns an array of indices indicating the offset of each attribute
  28027. */
  28028. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28029. /**
  28030. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28031. * @param effect defines the effect to activate
  28032. */
  28033. enableEffect(effect: Nullable<Effect>): void;
  28034. /**
  28035. * Set the value of an uniform to an array of int32
  28036. * @param uniform defines the webGL uniform location where to store the value
  28037. * @param array defines the array of int32 to store
  28038. */
  28039. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28040. /**
  28041. * Set the value of an uniform to an array of int32 (stored as vec2)
  28042. * @param uniform defines the webGL uniform location where to store the value
  28043. * @param array defines the array of int32 to store
  28044. */
  28045. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28046. /**
  28047. * Set the value of an uniform to an array of int32 (stored as vec3)
  28048. * @param uniform defines the webGL uniform location where to store the value
  28049. * @param array defines the array of int32 to store
  28050. */
  28051. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28052. /**
  28053. * Set the value of an uniform to an array of int32 (stored as vec4)
  28054. * @param uniform defines the webGL uniform location where to store the value
  28055. * @param array defines the array of int32 to store
  28056. */
  28057. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28058. /**
  28059. * Set the value of an uniform to an array of float32
  28060. * @param uniform defines the webGL uniform location where to store the value
  28061. * @param array defines the array of float32 to store
  28062. */
  28063. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28064. /**
  28065. * Set the value of an uniform to an array of float32 (stored as vec2)
  28066. * @param uniform defines the webGL uniform location where to store the value
  28067. * @param array defines the array of float32 to store
  28068. */
  28069. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28070. /**
  28071. * Set the value of an uniform to an array of float32 (stored as vec3)
  28072. * @param uniform defines the webGL uniform location where to store the value
  28073. * @param array defines the array of float32 to store
  28074. */
  28075. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28076. /**
  28077. * Set the value of an uniform to an array of float32 (stored as vec4)
  28078. * @param uniform defines the webGL uniform location where to store the value
  28079. * @param array defines the array of float32 to store
  28080. */
  28081. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28082. /**
  28083. * Set the value of an uniform to an array of number
  28084. * @param uniform defines the webGL uniform location where to store the value
  28085. * @param array defines the array of number to store
  28086. */
  28087. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28088. /**
  28089. * Set the value of an uniform to an array of number (stored as vec2)
  28090. * @param uniform defines the webGL uniform location where to store the value
  28091. * @param array defines the array of number to store
  28092. */
  28093. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28094. /**
  28095. * Set the value of an uniform to an array of number (stored as vec3)
  28096. * @param uniform defines the webGL uniform location where to store the value
  28097. * @param array defines the array of number to store
  28098. */
  28099. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28100. /**
  28101. * Set the value of an uniform to an array of number (stored as vec4)
  28102. * @param uniform defines the webGL uniform location where to store the value
  28103. * @param array defines the array of number to store
  28104. */
  28105. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28106. /**
  28107. * Set the value of an uniform to an array of float32 (stored as matrices)
  28108. * @param uniform defines the webGL uniform location where to store the value
  28109. * @param matrices defines the array of float32 to store
  28110. */
  28111. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28112. /**
  28113. * Set the value of an uniform to a matrix
  28114. * @param uniform defines the webGL uniform location where to store the value
  28115. * @param matrix defines the matrix to store
  28116. */
  28117. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28118. /**
  28119. * Set the value of an uniform to a matrix (3x3)
  28120. * @param uniform defines the webGL uniform location where to store the value
  28121. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28122. */
  28123. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28124. /**
  28125. * Set the value of an uniform to a matrix (2x2)
  28126. * @param uniform defines the webGL uniform location where to store the value
  28127. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28128. */
  28129. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28130. /**
  28131. * Set the value of an uniform to a number (int)
  28132. * @param uniform defines the webGL uniform location where to store the value
  28133. * @param value defines the int number to store
  28134. */
  28135. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28136. /**
  28137. * Set the value of an uniform to a number (float)
  28138. * @param uniform defines the webGL uniform location where to store the value
  28139. * @param value defines the float number to store
  28140. */
  28141. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28142. /**
  28143. * Set the value of an uniform to a vec2
  28144. * @param uniform defines the webGL uniform location where to store the value
  28145. * @param x defines the 1st component of the value
  28146. * @param y defines the 2nd component of the value
  28147. */
  28148. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28149. /**
  28150. * Set the value of an uniform to a vec3
  28151. * @param uniform defines the webGL uniform location where to store the value
  28152. * @param x defines the 1st component of the value
  28153. * @param y defines the 2nd component of the value
  28154. * @param z defines the 3rd component of the value
  28155. */
  28156. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28157. /**
  28158. * Set the value of an uniform to a boolean
  28159. * @param uniform defines the webGL uniform location where to store the value
  28160. * @param bool defines the boolean to store
  28161. */
  28162. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28163. /**
  28164. * Set the value of an uniform to a vec4
  28165. * @param uniform defines the webGL uniform location where to store the value
  28166. * @param x defines the 1st component of the value
  28167. * @param y defines the 2nd component of the value
  28168. * @param z defines the 3rd component of the value
  28169. * @param w defines the 4th component of the value
  28170. */
  28171. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28172. /**
  28173. * Set the value of an uniform to a Color3
  28174. * @param uniform defines the webGL uniform location where to store the value
  28175. * @param color3 defines the color to store
  28176. */
  28177. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28178. /**
  28179. * Set the value of an uniform to a Color3 and an alpha value
  28180. * @param uniform defines the webGL uniform location where to store the value
  28181. * @param color3 defines the color to store
  28182. * @param alpha defines the alpha component to store
  28183. */
  28184. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28185. /**
  28186. * Sets a Color4 on a uniform variable
  28187. * @param uniform defines the uniform location
  28188. * @param color4 defines the value to be set
  28189. */
  28190. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28191. /**
  28192. * Set various states to the webGL context
  28193. * @param culling defines backface culling state
  28194. * @param zOffset defines the value to apply to zOffset (0 by default)
  28195. * @param force defines if states must be applied even if cache is up to date
  28196. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28197. */
  28198. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28199. /**
  28200. * Set the z offset to apply to current rendering
  28201. * @param value defines the offset to apply
  28202. */
  28203. setZOffset(value: number): void;
  28204. /**
  28205. * Gets the current value of the zOffset
  28206. * @returns the current zOffset state
  28207. */
  28208. getZOffset(): number;
  28209. /**
  28210. * Enable or disable depth buffering
  28211. * @param enable defines the state to set
  28212. */
  28213. setDepthBuffer(enable: boolean): void;
  28214. /**
  28215. * Gets a boolean indicating if depth writing is enabled
  28216. * @returns the current depth writing state
  28217. */
  28218. getDepthWrite(): boolean;
  28219. /**
  28220. * Enable or disable depth writing
  28221. * @param enable defines the state to set
  28222. */
  28223. setDepthWrite(enable: boolean): void;
  28224. /**
  28225. * Enable or disable color writing
  28226. * @param enable defines the state to set
  28227. */
  28228. setColorWrite(enable: boolean): void;
  28229. /**
  28230. * Gets a boolean indicating if color writing is enabled
  28231. * @returns the current color writing state
  28232. */
  28233. getColorWrite(): boolean;
  28234. /**
  28235. * Sets alpha constants used by some alpha blending modes
  28236. * @param r defines the red component
  28237. * @param g defines the green component
  28238. * @param b defines the blue component
  28239. * @param a defines the alpha component
  28240. */
  28241. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28242. /**
  28243. * Sets the current alpha mode
  28244. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28245. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28246. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28247. */
  28248. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28249. /**
  28250. * Gets the current alpha mode
  28251. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28252. * @returns the current alpha mode
  28253. */
  28254. getAlphaMode(): number;
  28255. /**
  28256. * Clears the list of texture accessible through engine.
  28257. * This can help preventing texture load conflict due to name collision.
  28258. */
  28259. clearInternalTexturesCache(): void;
  28260. /**
  28261. * Force the entire cache to be cleared
  28262. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28263. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28264. */
  28265. wipeCaches(bruteForce?: boolean): void;
  28266. /**
  28267. * Set the compressed texture format to use, based on the formats you have, and the formats
  28268. * supported by the hardware / browser.
  28269. *
  28270. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28271. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28272. * to API arguments needed to compressed textures. This puts the burden on the container
  28273. * generator to house the arcane code for determining these for current & future formats.
  28274. *
  28275. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28276. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28277. *
  28278. * Note: The result of this call is not taken into account when a texture is base64.
  28279. *
  28280. * @param formatsAvailable defines the list of those format families you have created
  28281. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28282. *
  28283. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28284. * @returns The extension selected.
  28285. */
  28286. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28287. private _getSamplingParameters;
  28288. private _partialLoadImg;
  28289. private _cascadeLoadImgs;
  28290. /** @hidden */
  28291. _createTexture(): WebGLTexture;
  28292. /**
  28293. * Usually called from Texture.ts.
  28294. * Passed information to create a WebGLTexture
  28295. * @param urlArg defines a value which contains one of the following:
  28296. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28297. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28298. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28299. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28300. * @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)
  28301. * @param scene needed for loading to the correct scene
  28302. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28303. * @param onLoad optional callback to be called upon successful completion
  28304. * @param onError optional callback to be called upon failure
  28305. * @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
  28306. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28307. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28308. * @param forcedExtension defines the extension to use to pick the right loader
  28309. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28310. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28311. */
  28312. 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;
  28313. private _rescaleTexture;
  28314. /**
  28315. * Update a raw texture
  28316. * @param texture defines the texture to update
  28317. * @param data defines the data to store in the texture
  28318. * @param format defines the format of the data
  28319. * @param invertY defines if data must be stored with Y axis inverted
  28320. * @param compression defines the compression used (null by default)
  28321. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28322. */
  28323. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28324. /**
  28325. * Creates a raw texture
  28326. * @param data defines the data to store in the texture
  28327. * @param width defines the width of the texture
  28328. * @param height defines the height of the texture
  28329. * @param format defines the format of the data
  28330. * @param generateMipMaps defines if the engine should generate the mip levels
  28331. * @param invertY defines if data must be stored with Y axis inverted
  28332. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28333. * @param compression defines the compression used (null by default)
  28334. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28335. * @returns the raw texture inside an InternalTexture
  28336. */
  28337. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28338. private _unpackFlipYCached;
  28339. /**
  28340. * In case you are sharing the context with other applications, it might
  28341. * be interested to not cache the unpack flip y state to ensure a consistent
  28342. * value would be set.
  28343. */
  28344. enableUnpackFlipYCached: boolean;
  28345. /** @hidden */
  28346. _unpackFlipY(value: boolean): void;
  28347. /** @hidden */
  28348. _getUnpackAlignement(): number;
  28349. /**
  28350. * Creates a dynamic texture
  28351. * @param width defines the width of the texture
  28352. * @param height defines the height of the texture
  28353. * @param generateMipMaps defines if the engine should generate the mip levels
  28354. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28355. * @returns the dynamic texture inside an InternalTexture
  28356. */
  28357. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28358. /**
  28359. * Update the sampling mode of a given texture
  28360. * @param samplingMode defines the required sampling mode
  28361. * @param texture defines the texture to update
  28362. */
  28363. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28364. /**
  28365. * Update the content of a dynamic texture
  28366. * @param texture defines the texture to update
  28367. * @param canvas defines the canvas containing the source
  28368. * @param invertY defines if data must be stored with Y axis inverted
  28369. * @param premulAlpha defines if alpha is stored as premultiplied
  28370. * @param format defines the format of the data
  28371. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28372. */
  28373. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28374. /**
  28375. * Update a video texture
  28376. * @param texture defines the texture to update
  28377. * @param video defines the video element to use
  28378. * @param invertY defines if data must be stored with Y axis inverted
  28379. */
  28380. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28381. /**
  28382. * Updates a depth texture Comparison Mode and Function.
  28383. * If the comparison Function is equal to 0, the mode will be set to none.
  28384. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28385. * @param texture The texture to set the comparison function for
  28386. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28387. */
  28388. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28389. private _setupDepthStencilTexture;
  28390. /**
  28391. * Creates a depth stencil texture.
  28392. * This is only available in WebGL 2 or with the depth texture extension available.
  28393. * @param size The size of face edge in the texture.
  28394. * @param options The options defining the texture.
  28395. * @returns The texture
  28396. */
  28397. createDepthStencilTexture(size: number | {
  28398. width: number;
  28399. height: number;
  28400. }, options: DepthTextureCreationOptions): InternalTexture;
  28401. /**
  28402. * Creates a depth stencil texture.
  28403. * This is only available in WebGL 2 or with the depth texture extension available.
  28404. * @param size The size of face edge in the texture.
  28405. * @param options The options defining the texture.
  28406. * @returns The texture
  28407. */
  28408. private _createDepthStencilTexture;
  28409. /**
  28410. * Creates a depth stencil cube texture.
  28411. * This is only available in WebGL 2.
  28412. * @param size The size of face edge in the cube texture.
  28413. * @param options The options defining the cube texture.
  28414. * @returns The cube texture
  28415. */
  28416. private _createDepthStencilCubeTexture;
  28417. /**
  28418. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28419. * @param renderTarget The render target to set the frame buffer for
  28420. */
  28421. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28422. /**
  28423. * Creates a new render target texture
  28424. * @param size defines the size of the texture
  28425. * @param options defines the options used to create the texture
  28426. * @returns a new render target texture stored in an InternalTexture
  28427. */
  28428. createRenderTargetTexture(size: number | {
  28429. width: number;
  28430. height: number;
  28431. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28432. /**
  28433. * Create a multi render target texture
  28434. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28435. * @param size defines the size of the texture
  28436. * @param options defines the creation options
  28437. * @returns the cube texture as an InternalTexture
  28438. */
  28439. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28440. private _setupFramebufferDepthAttachments;
  28441. /**
  28442. * Updates the sample count of a render target texture
  28443. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28444. * @param texture defines the texture to update
  28445. * @param samples defines the sample count to set
  28446. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28447. */
  28448. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28449. /**
  28450. * Update the sample count for a given multiple render target texture
  28451. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28452. * @param textures defines the textures to update
  28453. * @param samples defines the sample count to set
  28454. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28455. */
  28456. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28457. /** @hidden */
  28458. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28459. /** @hidden */
  28460. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28461. /** @hidden */
  28462. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28463. /** @hidden */
  28464. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28465. /**
  28466. * Creates a new render target cube texture
  28467. * @param size defines the size of the texture
  28468. * @param options defines the options used to create the texture
  28469. * @returns a new render target cube texture stored in an InternalTexture
  28470. */
  28471. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28472. /**
  28473. * Creates a cube texture
  28474. * @param rootUrl defines the url where the files to load is located
  28475. * @param scene defines the current scene
  28476. * @param files defines the list of files to load (1 per face)
  28477. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28478. * @param onLoad defines an optional callback raised when the texture is loaded
  28479. * @param onError defines an optional callback raised if there is an issue to load the texture
  28480. * @param format defines the format of the data
  28481. * @param forcedExtension defines the extension to use to pick the right loader
  28482. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28483. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28484. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28485. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28486. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28487. * @returns the cube texture as an InternalTexture
  28488. */
  28489. 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;
  28490. /**
  28491. * @hidden
  28492. */
  28493. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28494. /**
  28495. * Update a raw cube texture
  28496. * @param texture defines the texture to udpdate
  28497. * @param data defines the data to store
  28498. * @param format defines the data format
  28499. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28500. * @param invertY defines if data must be stored with Y axis inverted
  28501. * @param compression defines the compression used (null by default)
  28502. * @param level defines which level of the texture to update
  28503. */
  28504. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28505. /**
  28506. * Creates a new raw cube texture
  28507. * @param data defines the array of data to use to create each face
  28508. * @param size defines the size of the textures
  28509. * @param format defines the format of the data
  28510. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28511. * @param generateMipMaps defines if the engine should generate the mip levels
  28512. * @param invertY defines if data must be stored with Y axis inverted
  28513. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28514. * @param compression defines the compression used (null by default)
  28515. * @returns the cube texture as an InternalTexture
  28516. */
  28517. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28518. /**
  28519. * Creates a new raw cube texture from a specified url
  28520. * @param url defines the url where the data is located
  28521. * @param scene defines the current scene
  28522. * @param size defines the size of the textures
  28523. * @param format defines the format of the data
  28524. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28525. * @param noMipmap defines if the engine should avoid generating the mip levels
  28526. * @param callback defines a callback used to extract texture data from loaded data
  28527. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28528. * @param onLoad defines a callback called when texture is loaded
  28529. * @param onError defines a callback called if there is an error
  28530. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28531. * @param invertY defines if data must be stored with Y axis inverted
  28532. * @returns the cube texture as an InternalTexture
  28533. */
  28534. 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;
  28535. /**
  28536. * Update a raw 3D texture
  28537. * @param texture defines the texture to update
  28538. * @param data defines the data to store
  28539. * @param format defines the data format
  28540. * @param invertY defines if data must be stored with Y axis inverted
  28541. * @param compression defines the used compression (can be null)
  28542. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28543. */
  28544. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28545. /**
  28546. * Creates a new raw 3D texture
  28547. * @param data defines the data used to create the texture
  28548. * @param width defines the width of the texture
  28549. * @param height defines the height of the texture
  28550. * @param depth defines the depth of the texture
  28551. * @param format defines the format of the texture
  28552. * @param generateMipMaps defines if the engine must generate mip levels
  28553. * @param invertY defines if data must be stored with Y axis inverted
  28554. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28555. * @param compression defines the compressed used (can be null)
  28556. * @param textureType defines the compressed used (can be null)
  28557. * @returns a new raw 3D texture (stored in an InternalTexture)
  28558. */
  28559. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28560. private _prepareWebGLTextureContinuation;
  28561. private _prepareWebGLTexture;
  28562. private _convertRGBtoRGBATextureData;
  28563. /** @hidden */
  28564. _releaseFramebufferObjects(texture: InternalTexture): void;
  28565. /** @hidden */
  28566. _releaseTexture(texture: InternalTexture): void;
  28567. private setProgram;
  28568. private _boundUniforms;
  28569. /**
  28570. * Binds an effect to the webGL context
  28571. * @param effect defines the effect to bind
  28572. */
  28573. bindSamplers(effect: Effect): void;
  28574. private _moveBoundTextureOnTop;
  28575. private _getCorrectTextureChannel;
  28576. private _linkTrackers;
  28577. private _removeDesignatedSlot;
  28578. private _activateCurrentTexture;
  28579. /** @hidden */
  28580. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28581. /** @hidden */
  28582. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28583. /**
  28584. * Sets a texture to the webGL context from a postprocess
  28585. * @param channel defines the channel to use
  28586. * @param postProcess defines the source postprocess
  28587. */
  28588. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28589. /**
  28590. * Binds the output of the passed in post process to the texture channel specified
  28591. * @param channel The channel the texture should be bound to
  28592. * @param postProcess The post process which's output should be bound
  28593. */
  28594. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28595. /**
  28596. * Unbind all textures from the webGL context
  28597. */
  28598. unbindAllTextures(): void;
  28599. /**
  28600. * Sets a texture to the according uniform.
  28601. * @param channel The texture channel
  28602. * @param uniform The uniform to set
  28603. * @param texture The texture to apply
  28604. */
  28605. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28606. /**
  28607. * Sets a depth stencil texture from a render target to the according uniform.
  28608. * @param channel The texture channel
  28609. * @param uniform The uniform to set
  28610. * @param texture The render target texture containing the depth stencil texture to apply
  28611. */
  28612. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28613. private _bindSamplerUniformToChannel;
  28614. private _getTextureWrapMode;
  28615. private _setTexture;
  28616. /**
  28617. * Sets an array of texture to the webGL context
  28618. * @param channel defines the channel where the texture array must be set
  28619. * @param uniform defines the associated uniform location
  28620. * @param textures defines the array of textures to bind
  28621. */
  28622. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28623. /** @hidden */
  28624. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28625. private _setTextureParameterFloat;
  28626. private _setTextureParameterInteger;
  28627. /**
  28628. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28629. * @param x defines the x coordinate of the rectangle where pixels must be read
  28630. * @param y defines the y coordinate of the rectangle where pixels must be read
  28631. * @param width defines the width of the rectangle where pixels must be read
  28632. * @param height defines the height of the rectangle where pixels must be read
  28633. * @returns a Uint8Array containing RGBA colors
  28634. */
  28635. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28636. /**
  28637. * Add an externaly attached data from its key.
  28638. * This method call will fail and return false, if such key already exists.
  28639. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28640. * @param key the unique key that identifies the data
  28641. * @param data the data object to associate to the key for this Engine instance
  28642. * @return true if no such key were already present and the data was added successfully, false otherwise
  28643. */
  28644. addExternalData<T>(key: string, data: T): boolean;
  28645. /**
  28646. * Get an externaly attached data from its key
  28647. * @param key the unique key that identifies the data
  28648. * @return the associated data, if present (can be null), or undefined if not present
  28649. */
  28650. getExternalData<T>(key: string): T;
  28651. /**
  28652. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28653. * @param key the unique key that identifies the data
  28654. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28655. * @return the associated data, can be null if the factory returned null.
  28656. */
  28657. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28658. /**
  28659. * Remove an externaly attached data from the Engine instance
  28660. * @param key the unique key that identifies the data
  28661. * @return true if the data was successfully removed, false if it doesn't exist
  28662. */
  28663. removeExternalData(key: string): boolean;
  28664. /**
  28665. * Unbind all vertex attributes from the webGL context
  28666. */
  28667. unbindAllAttributes(): void;
  28668. /**
  28669. * 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
  28670. */
  28671. releaseEffects(): void;
  28672. /**
  28673. * Dispose and release all associated resources
  28674. */
  28675. dispose(): void;
  28676. /**
  28677. * Display the loading screen
  28678. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28679. */
  28680. displayLoadingUI(): void;
  28681. /**
  28682. * Hide the loading screen
  28683. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28684. */
  28685. hideLoadingUI(): void;
  28686. /**
  28687. * Gets the current loading screen object
  28688. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28689. */
  28690. /**
  28691. * Sets the current loading screen object
  28692. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28693. */
  28694. loadingScreen: ILoadingScreen;
  28695. /**
  28696. * Sets the current loading screen text
  28697. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28698. */
  28699. loadingUIText: string;
  28700. /**
  28701. * Sets the current loading screen background color
  28702. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28703. */
  28704. loadingUIBackgroundColor: string;
  28705. /**
  28706. * Attach a new callback raised when context lost event is fired
  28707. * @param callback defines the callback to call
  28708. */
  28709. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28710. /**
  28711. * Attach a new callback raised when context restored event is fired
  28712. * @param callback defines the callback to call
  28713. */
  28714. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28715. /**
  28716. * Gets the source code of the vertex shader associated with a specific webGL program
  28717. * @param program defines the program to use
  28718. * @returns a string containing the source code of the vertex shader associated with the program
  28719. */
  28720. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28721. /**
  28722. * Gets the source code of the fragment shader associated with a specific webGL program
  28723. * @param program defines the program to use
  28724. * @returns a string containing the source code of the fragment shader associated with the program
  28725. */
  28726. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28727. /**
  28728. * Get the current error code of the webGL context
  28729. * @returns the error code
  28730. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28731. */
  28732. getError(): number;
  28733. /**
  28734. * Gets the current framerate
  28735. * @returns a number representing the framerate
  28736. */
  28737. getFps(): number;
  28738. /**
  28739. * Gets the time spent between current and previous frame
  28740. * @returns a number representing the delta time in ms
  28741. */
  28742. getDeltaTime(): number;
  28743. private _measureFps;
  28744. /** @hidden */
  28745. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28746. private _canRenderToFloatFramebuffer;
  28747. private _canRenderToHalfFloatFramebuffer;
  28748. private _canRenderToFramebuffer;
  28749. /** @hidden */
  28750. _getWebGLTextureType(type: number): number;
  28751. private _getInternalFormat;
  28752. /** @hidden */
  28753. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28754. /** @hidden */
  28755. _getRGBAMultiSampleBufferFormat(type: number): number;
  28756. /** @hidden */
  28757. _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;
  28758. /** @hidden */
  28759. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28760. private _partialLoadFile;
  28761. private _cascadeLoadFiles;
  28762. /**
  28763. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28764. * @returns true if the engine can be created
  28765. * @ignorenaming
  28766. */
  28767. static isSupported(): boolean;
  28768. }
  28769. }
  28770. declare module "babylonjs/Materials/effect" {
  28771. import { Observable } from "babylonjs/Misc/observable";
  28772. import { Nullable } from "babylonjs/types";
  28773. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  28774. import { Engine } from "babylonjs/Engines/engine";
  28775. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28776. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28777. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28778. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28779. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28780. /**
  28781. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28782. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28783. */
  28784. export class EffectFallbacks {
  28785. private _defines;
  28786. private _currentRank;
  28787. private _maxRank;
  28788. private _mesh;
  28789. /**
  28790. * Removes the fallback from the bound mesh.
  28791. */
  28792. unBindMesh(): void;
  28793. /**
  28794. * Adds a fallback on the specified property.
  28795. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28796. * @param define The name of the define in the shader
  28797. */
  28798. addFallback(rank: number, define: string): void;
  28799. /**
  28800. * Sets the mesh to use CPU skinning when needing to fallback.
  28801. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28802. * @param mesh The mesh to use the fallbacks.
  28803. */
  28804. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28805. /**
  28806. * Checks to see if more fallbacks are still availible.
  28807. */
  28808. readonly isMoreFallbacks: boolean;
  28809. /**
  28810. * Removes the defines that shoould be removed when falling back.
  28811. * @param currentDefines defines the current define statements for the shader.
  28812. * @param effect defines the current effect we try to compile
  28813. * @returns The resulting defines with defines of the current rank removed.
  28814. */
  28815. reduce(currentDefines: string, effect: Effect): string;
  28816. }
  28817. /**
  28818. * Options to be used when creating an effect.
  28819. */
  28820. export class EffectCreationOptions {
  28821. /**
  28822. * Atrributes that will be used in the shader.
  28823. */
  28824. attributes: string[];
  28825. /**
  28826. * Uniform varible names that will be set in the shader.
  28827. */
  28828. uniformsNames: string[];
  28829. /**
  28830. * Uniform buffer varible names that will be set in the shader.
  28831. */
  28832. uniformBuffersNames: string[];
  28833. /**
  28834. * Sampler texture variable names that will be set in the shader.
  28835. */
  28836. samplers: string[];
  28837. /**
  28838. * Define statements that will be set in the shader.
  28839. */
  28840. defines: any;
  28841. /**
  28842. * Possible fallbacks for this effect to improve performance when needed.
  28843. */
  28844. fallbacks: Nullable<EffectFallbacks>;
  28845. /**
  28846. * Callback that will be called when the shader is compiled.
  28847. */
  28848. onCompiled: Nullable<(effect: Effect) => void>;
  28849. /**
  28850. * Callback that will be called if an error occurs during shader compilation.
  28851. */
  28852. onError: Nullable<(effect: Effect, errors: string) => void>;
  28853. /**
  28854. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28855. */
  28856. indexParameters: any;
  28857. /**
  28858. * Max number of lights that can be used in the shader.
  28859. */
  28860. maxSimultaneousLights: number;
  28861. /**
  28862. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28863. */
  28864. transformFeedbackVaryings: Nullable<string[]>;
  28865. }
  28866. /**
  28867. * Effect containing vertex and fragment shader that can be executed on an object.
  28868. */
  28869. export class Effect {
  28870. /**
  28871. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28872. */
  28873. static ShadersRepository: string;
  28874. /**
  28875. * Name of the effect.
  28876. */
  28877. name: any;
  28878. /**
  28879. * String container all the define statements that should be set on the shader.
  28880. */
  28881. defines: string;
  28882. /**
  28883. * Callback that will be called when the shader is compiled.
  28884. */
  28885. onCompiled: Nullable<(effect: Effect) => void>;
  28886. /**
  28887. * Callback that will be called if an error occurs during shader compilation.
  28888. */
  28889. onError: Nullable<(effect: Effect, errors: string) => void>;
  28890. /**
  28891. * Callback that will be called when effect is bound.
  28892. */
  28893. onBind: Nullable<(effect: Effect) => void>;
  28894. /**
  28895. * Unique ID of the effect.
  28896. */
  28897. uniqueId: number;
  28898. /**
  28899. * Observable that will be called when the shader is compiled.
  28900. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28901. */
  28902. onCompileObservable: Observable<Effect>;
  28903. /**
  28904. * Observable that will be called if an error occurs during shader compilation.
  28905. */
  28906. onErrorObservable: Observable<Effect>;
  28907. /** @hidden */
  28908. _onBindObservable: Nullable<Observable<Effect>>;
  28909. /**
  28910. * Observable that will be called when effect is bound.
  28911. */
  28912. readonly onBindObservable: Observable<Effect>;
  28913. /** @hidden */
  28914. _bonesComputationForcedToCPU: boolean;
  28915. private static _uniqueIdSeed;
  28916. private _engine;
  28917. private _uniformBuffersNames;
  28918. private _uniformsNames;
  28919. private _samplers;
  28920. private _isReady;
  28921. private _compilationError;
  28922. private _attributesNames;
  28923. private _attributes;
  28924. private _uniforms;
  28925. /**
  28926. * Key for the effect.
  28927. * @hidden
  28928. */
  28929. _key: string;
  28930. private _indexParameters;
  28931. private _fallbacks;
  28932. private _vertexSourceCode;
  28933. private _fragmentSourceCode;
  28934. private _vertexSourceCodeOverride;
  28935. private _fragmentSourceCodeOverride;
  28936. private _transformFeedbackVaryings;
  28937. /**
  28938. * Compiled shader to webGL program.
  28939. * @hidden
  28940. */
  28941. _program: WebGLProgram;
  28942. private _valueCache;
  28943. private static _baseCache;
  28944. /**
  28945. * Instantiates an effect.
  28946. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28947. * @param baseName Name of the effect.
  28948. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28949. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28950. * @param samplers List of sampler variables that will be passed to the shader.
  28951. * @param engine Engine to be used to render the effect
  28952. * @param defines Define statements to be added to the shader.
  28953. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28954. * @param onCompiled Callback that will be called when the shader is compiled.
  28955. * @param onError Callback that will be called if an error occurs during shader compilation.
  28956. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28957. */
  28958. 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);
  28959. /**
  28960. * Unique key for this effect
  28961. */
  28962. readonly key: string;
  28963. /**
  28964. * If the effect has been compiled and prepared.
  28965. * @returns if the effect is compiled and prepared.
  28966. */
  28967. isReady(): boolean;
  28968. /**
  28969. * The engine the effect was initialized with.
  28970. * @returns the engine.
  28971. */
  28972. getEngine(): Engine;
  28973. /**
  28974. * The compiled webGL program for the effect
  28975. * @returns the webGL program.
  28976. */
  28977. getProgram(): WebGLProgram;
  28978. /**
  28979. * The set of names of attribute variables for the shader.
  28980. * @returns An array of attribute names.
  28981. */
  28982. getAttributesNames(): string[];
  28983. /**
  28984. * Returns the attribute at the given index.
  28985. * @param index The index of the attribute.
  28986. * @returns The location of the attribute.
  28987. */
  28988. getAttributeLocation(index: number): number;
  28989. /**
  28990. * Returns the attribute based on the name of the variable.
  28991. * @param name of the attribute to look up.
  28992. * @returns the attribute location.
  28993. */
  28994. getAttributeLocationByName(name: string): number;
  28995. /**
  28996. * The number of attributes.
  28997. * @returns the numnber of attributes.
  28998. */
  28999. getAttributesCount(): number;
  29000. /**
  29001. * Gets the index of a uniform variable.
  29002. * @param uniformName of the uniform to look up.
  29003. * @returns the index.
  29004. */
  29005. getUniformIndex(uniformName: string): number;
  29006. /**
  29007. * Returns the attribute based on the name of the variable.
  29008. * @param uniformName of the uniform to look up.
  29009. * @returns the location of the uniform.
  29010. */
  29011. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29012. /**
  29013. * Returns an array of sampler variable names
  29014. * @returns The array of sampler variable neames.
  29015. */
  29016. getSamplers(): string[];
  29017. /**
  29018. * The error from the last compilation.
  29019. * @returns the error string.
  29020. */
  29021. getCompilationError(): string;
  29022. /**
  29023. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29024. * @param func The callback to be used.
  29025. */
  29026. executeWhenCompiled(func: (effect: Effect) => void): void;
  29027. private _checkIsReady;
  29028. /** @hidden */
  29029. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29030. /** @hidden */
  29031. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29032. /** @hidden */
  29033. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29034. private _processShaderConversion;
  29035. private _processIncludes;
  29036. private _processPrecision;
  29037. /**
  29038. * Recompiles the webGL program
  29039. * @param vertexSourceCode The source code for the vertex shader.
  29040. * @param fragmentSourceCode The source code for the fragment shader.
  29041. * @param onCompiled Callback called when completed.
  29042. * @param onError Callback called on error.
  29043. * @hidden
  29044. */
  29045. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29046. /**
  29047. * Gets the uniform locations of the the specified variable names
  29048. * @param names THe names of the variables to lookup.
  29049. * @returns Array of locations in the same order as variable names.
  29050. */
  29051. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29052. /**
  29053. * Prepares the effect
  29054. * @hidden
  29055. */
  29056. _prepareEffect(): void;
  29057. /**
  29058. * Checks if the effect is supported. (Must be called after compilation)
  29059. */
  29060. readonly isSupported: boolean;
  29061. /**
  29062. * Binds a texture to the engine to be used as output of the shader.
  29063. * @param channel Name of the output variable.
  29064. * @param texture Texture to bind.
  29065. * @hidden
  29066. */
  29067. _bindTexture(channel: string, texture: InternalTexture): void;
  29068. /**
  29069. * Sets a texture on the engine to be used in the shader.
  29070. * @param channel Name of the sampler variable.
  29071. * @param texture Texture to set.
  29072. */
  29073. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29074. /**
  29075. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29076. * @param channel Name of the sampler variable.
  29077. * @param texture Texture to set.
  29078. */
  29079. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29080. /**
  29081. * Sets an array of textures on the engine to be used in the shader.
  29082. * @param channel Name of the variable.
  29083. * @param textures Textures to set.
  29084. */
  29085. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29086. /**
  29087. * 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)
  29088. * @param channel Name of the sampler variable.
  29089. * @param postProcess Post process to get the input texture from.
  29090. */
  29091. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29092. /**
  29093. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29094. * 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)
  29095. * @param channel Name of the sampler variable.
  29096. * @param postProcess Post process to get the output texture from.
  29097. */
  29098. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29099. /** @hidden */
  29100. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29101. /** @hidden */
  29102. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29103. /** @hidden */
  29104. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29105. /** @hidden */
  29106. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29107. /**
  29108. * Binds a buffer to a uniform.
  29109. * @param buffer Buffer to bind.
  29110. * @param name Name of the uniform variable to bind to.
  29111. */
  29112. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29113. /**
  29114. * Binds block to a uniform.
  29115. * @param blockName Name of the block to bind.
  29116. * @param index Index to bind.
  29117. */
  29118. bindUniformBlock(blockName: string, index: number): void;
  29119. /**
  29120. * Sets an interger value on a uniform variable.
  29121. * @param uniformName Name of the variable.
  29122. * @param value Value to be set.
  29123. * @returns this effect.
  29124. */
  29125. setInt(uniformName: string, value: number): Effect;
  29126. /**
  29127. * Sets an int array on a uniform variable.
  29128. * @param uniformName Name of the variable.
  29129. * @param array array to be set.
  29130. * @returns this effect.
  29131. */
  29132. setIntArray(uniformName: string, array: Int32Array): Effect;
  29133. /**
  29134. * 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)
  29135. * @param uniformName Name of the variable.
  29136. * @param array array to be set.
  29137. * @returns this effect.
  29138. */
  29139. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29140. /**
  29141. * 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)
  29142. * @param uniformName Name of the variable.
  29143. * @param array array to be set.
  29144. * @returns this effect.
  29145. */
  29146. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29147. /**
  29148. * 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)
  29149. * @param uniformName Name of the variable.
  29150. * @param array array to be set.
  29151. * @returns this effect.
  29152. */
  29153. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29154. /**
  29155. * Sets an float array on a uniform variable.
  29156. * @param uniformName Name of the variable.
  29157. * @param array array to be set.
  29158. * @returns this effect.
  29159. */
  29160. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29161. /**
  29162. * 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)
  29163. * @param uniformName Name of the variable.
  29164. * @param array array to be set.
  29165. * @returns this effect.
  29166. */
  29167. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29168. /**
  29169. * 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)
  29170. * @param uniformName Name of the variable.
  29171. * @param array array to be set.
  29172. * @returns this effect.
  29173. */
  29174. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29175. /**
  29176. * 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)
  29177. * @param uniformName Name of the variable.
  29178. * @param array array to be set.
  29179. * @returns this effect.
  29180. */
  29181. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29182. /**
  29183. * Sets an array on a uniform variable.
  29184. * @param uniformName Name of the variable.
  29185. * @param array array to be set.
  29186. * @returns this effect.
  29187. */
  29188. setArray(uniformName: string, array: number[]): Effect;
  29189. /**
  29190. * 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)
  29191. * @param uniformName Name of the variable.
  29192. * @param array array to be set.
  29193. * @returns this effect.
  29194. */
  29195. setArray2(uniformName: string, array: number[]): Effect;
  29196. /**
  29197. * 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)
  29198. * @param uniformName Name of the variable.
  29199. * @param array array to be set.
  29200. * @returns this effect.
  29201. */
  29202. setArray3(uniformName: string, array: number[]): Effect;
  29203. /**
  29204. * 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)
  29205. * @param uniformName Name of the variable.
  29206. * @param array array to be set.
  29207. * @returns this effect.
  29208. */
  29209. setArray4(uniformName: string, array: number[]): Effect;
  29210. /**
  29211. * Sets matrices on a uniform variable.
  29212. * @param uniformName Name of the variable.
  29213. * @param matrices matrices to be set.
  29214. * @returns this effect.
  29215. */
  29216. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29217. /**
  29218. * Sets matrix on a uniform variable.
  29219. * @param uniformName Name of the variable.
  29220. * @param matrix matrix to be set.
  29221. * @returns this effect.
  29222. */
  29223. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29224. /**
  29225. * 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)
  29226. * @param uniformName Name of the variable.
  29227. * @param matrix matrix to be set.
  29228. * @returns this effect.
  29229. */
  29230. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29231. /**
  29232. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29233. * @param uniformName Name of the variable.
  29234. * @param matrix matrix to be set.
  29235. * @returns this effect.
  29236. */
  29237. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29238. /**
  29239. * Sets a float on a uniform variable.
  29240. * @param uniformName Name of the variable.
  29241. * @param value value to be set.
  29242. * @returns this effect.
  29243. */
  29244. setFloat(uniformName: string, value: number): Effect;
  29245. /**
  29246. * Sets a boolean on a uniform variable.
  29247. * @param uniformName Name of the variable.
  29248. * @param bool value to be set.
  29249. * @returns this effect.
  29250. */
  29251. setBool(uniformName: string, bool: boolean): Effect;
  29252. /**
  29253. * Sets a Vector2 on a uniform variable.
  29254. * @param uniformName Name of the variable.
  29255. * @param vector2 vector2 to be set.
  29256. * @returns this effect.
  29257. */
  29258. setVector2(uniformName: string, vector2: Vector2): Effect;
  29259. /**
  29260. * Sets a float2 on a uniform variable.
  29261. * @param uniformName Name of the variable.
  29262. * @param x First float in float2.
  29263. * @param y Second float in float2.
  29264. * @returns this effect.
  29265. */
  29266. setFloat2(uniformName: string, x: number, y: number): Effect;
  29267. /**
  29268. * Sets a Vector3 on a uniform variable.
  29269. * @param uniformName Name of the variable.
  29270. * @param vector3 Value to be set.
  29271. * @returns this effect.
  29272. */
  29273. setVector3(uniformName: string, vector3: Vector3): Effect;
  29274. /**
  29275. * Sets a float3 on a uniform variable.
  29276. * @param uniformName Name of the variable.
  29277. * @param x First float in float3.
  29278. * @param y Second float in float3.
  29279. * @param z Third float in float3.
  29280. * @returns this effect.
  29281. */
  29282. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29283. /**
  29284. * Sets a Vector4 on a uniform variable.
  29285. * @param uniformName Name of the variable.
  29286. * @param vector4 Value to be set.
  29287. * @returns this effect.
  29288. */
  29289. setVector4(uniformName: string, vector4: Vector4): Effect;
  29290. /**
  29291. * Sets a float4 on a uniform variable.
  29292. * @param uniformName Name of the variable.
  29293. * @param x First float in float4.
  29294. * @param y Second float in float4.
  29295. * @param z Third float in float4.
  29296. * @param w Fourth float in float4.
  29297. * @returns this effect.
  29298. */
  29299. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29300. /**
  29301. * Sets a Color3 on a uniform variable.
  29302. * @param uniformName Name of the variable.
  29303. * @param color3 Value to be set.
  29304. * @returns this effect.
  29305. */
  29306. setColor3(uniformName: string, color3: Color3): Effect;
  29307. /**
  29308. * Sets a Color4 on a uniform variable.
  29309. * @param uniformName Name of the variable.
  29310. * @param color3 Value to be set.
  29311. * @param alpha Alpha value to be set.
  29312. * @returns this effect.
  29313. */
  29314. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29315. /**
  29316. * Sets a Color4 on a uniform variable
  29317. * @param uniformName defines the name of the variable
  29318. * @param color4 defines the value to be set
  29319. * @returns this effect.
  29320. */
  29321. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29322. /**
  29323. * This function will add a new shader to the shader store
  29324. * @param name the name of the shader
  29325. * @param pixelShader optional pixel shader content
  29326. * @param vertexShader optional vertex shader content
  29327. */
  29328. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29329. /**
  29330. * Store of each shader (The can be looked up using effect.key)
  29331. */
  29332. static ShadersStore: {
  29333. [key: string]: string;
  29334. };
  29335. /**
  29336. * Store of each included file for a shader (The can be looked up using effect.key)
  29337. */
  29338. static IncludesShadersStore: {
  29339. [key: string]: string;
  29340. };
  29341. /**
  29342. * Resets the cache of effects.
  29343. */
  29344. static ResetCache(): void;
  29345. }
  29346. }
  29347. declare module "babylonjs/Materials/colorCurves" {
  29348. import { Effect } from "babylonjs/Materials/effect";
  29349. /**
  29350. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29351. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29352. * 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;
  29353. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29354. */
  29355. export class ColorCurves {
  29356. private _dirty;
  29357. private _tempColor;
  29358. private _globalCurve;
  29359. private _highlightsCurve;
  29360. private _midtonesCurve;
  29361. private _shadowsCurve;
  29362. private _positiveCurve;
  29363. private _negativeCurve;
  29364. private _globalHue;
  29365. private _globalDensity;
  29366. private _globalSaturation;
  29367. private _globalExposure;
  29368. /**
  29369. * Gets the global Hue value.
  29370. * 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).
  29371. */
  29372. /**
  29373. * Sets the global Hue value.
  29374. * 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).
  29375. */
  29376. globalHue: number;
  29377. /**
  29378. * Gets the global Density value.
  29379. * 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.
  29380. * Values less than zero provide a filter of opposite hue.
  29381. */
  29382. /**
  29383. * Sets the global Density value.
  29384. * 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.
  29385. * Values less than zero provide a filter of opposite hue.
  29386. */
  29387. globalDensity: number;
  29388. /**
  29389. * Gets the global Saturation value.
  29390. * 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.
  29391. */
  29392. /**
  29393. * Sets the global Saturation value.
  29394. * 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.
  29395. */
  29396. globalSaturation: number;
  29397. /**
  29398. * Gets the global Exposure value.
  29399. * 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.
  29400. */
  29401. /**
  29402. * Sets the global Exposure value.
  29403. * 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.
  29404. */
  29405. globalExposure: number;
  29406. private _highlightsHue;
  29407. private _highlightsDensity;
  29408. private _highlightsSaturation;
  29409. private _highlightsExposure;
  29410. /**
  29411. * Gets the highlights Hue value.
  29412. * 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).
  29413. */
  29414. /**
  29415. * Sets the highlights Hue value.
  29416. * 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).
  29417. */
  29418. highlightsHue: number;
  29419. /**
  29420. * Gets the highlights Density value.
  29421. * 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.
  29422. * Values less than zero provide a filter of opposite hue.
  29423. */
  29424. /**
  29425. * Sets the highlights Density value.
  29426. * 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.
  29427. * Values less than zero provide a filter of opposite hue.
  29428. */
  29429. highlightsDensity: number;
  29430. /**
  29431. * Gets the highlights Saturation value.
  29432. * 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.
  29433. */
  29434. /**
  29435. * Sets the highlights Saturation value.
  29436. * 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.
  29437. */
  29438. highlightsSaturation: number;
  29439. /**
  29440. * Gets the highlights Exposure value.
  29441. * 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.
  29442. */
  29443. /**
  29444. * Sets the highlights Exposure value.
  29445. * 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.
  29446. */
  29447. highlightsExposure: number;
  29448. private _midtonesHue;
  29449. private _midtonesDensity;
  29450. private _midtonesSaturation;
  29451. private _midtonesExposure;
  29452. /**
  29453. * Gets the midtones Hue value.
  29454. * 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).
  29455. */
  29456. /**
  29457. * Sets the midtones Hue value.
  29458. * 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).
  29459. */
  29460. midtonesHue: number;
  29461. /**
  29462. * Gets the midtones Density value.
  29463. * 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.
  29464. * Values less than zero provide a filter of opposite hue.
  29465. */
  29466. /**
  29467. * Sets the midtones Density value.
  29468. * 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.
  29469. * Values less than zero provide a filter of opposite hue.
  29470. */
  29471. midtonesDensity: number;
  29472. /**
  29473. * Gets the midtones Saturation value.
  29474. * 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.
  29475. */
  29476. /**
  29477. * Sets the midtones Saturation value.
  29478. * 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.
  29479. */
  29480. midtonesSaturation: number;
  29481. /**
  29482. * Gets the midtones Exposure value.
  29483. * 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.
  29484. */
  29485. /**
  29486. * Sets the midtones Exposure value.
  29487. * 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.
  29488. */
  29489. midtonesExposure: number;
  29490. private _shadowsHue;
  29491. private _shadowsDensity;
  29492. private _shadowsSaturation;
  29493. private _shadowsExposure;
  29494. /**
  29495. * Gets the shadows Hue value.
  29496. * 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).
  29497. */
  29498. /**
  29499. * Sets the shadows Hue value.
  29500. * 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).
  29501. */
  29502. shadowsHue: number;
  29503. /**
  29504. * Gets the shadows Density value.
  29505. * 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.
  29506. * Values less than zero provide a filter of opposite hue.
  29507. */
  29508. /**
  29509. * Sets the shadows Density value.
  29510. * 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.
  29511. * Values less than zero provide a filter of opposite hue.
  29512. */
  29513. shadowsDensity: number;
  29514. /**
  29515. * Gets the shadows Saturation value.
  29516. * 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.
  29517. */
  29518. /**
  29519. * Sets the shadows Saturation value.
  29520. * 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.
  29521. */
  29522. shadowsSaturation: number;
  29523. /**
  29524. * Gets the shadows Exposure value.
  29525. * 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.
  29526. */
  29527. /**
  29528. * Sets the shadows Exposure value.
  29529. * 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.
  29530. */
  29531. shadowsExposure: number;
  29532. /**
  29533. * Returns the class name
  29534. * @returns The class name
  29535. */
  29536. getClassName(): string;
  29537. /**
  29538. * Binds the color curves to the shader.
  29539. * @param colorCurves The color curve to bind
  29540. * @param effect The effect to bind to
  29541. * @param positiveUniform The positive uniform shader parameter
  29542. * @param neutralUniform The neutral uniform shader parameter
  29543. * @param negativeUniform The negative uniform shader parameter
  29544. */
  29545. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29546. /**
  29547. * Prepare the list of uniforms associated with the ColorCurves effects.
  29548. * @param uniformsList The list of uniforms used in the effect
  29549. */
  29550. static PrepareUniforms(uniformsList: string[]): void;
  29551. /**
  29552. * Returns color grading data based on a hue, density, saturation and exposure value.
  29553. * @param filterHue The hue of the color filter.
  29554. * @param filterDensity The density of the color filter.
  29555. * @param saturation The saturation.
  29556. * @param exposure The exposure.
  29557. * @param result The result data container.
  29558. */
  29559. private getColorGradingDataToRef;
  29560. /**
  29561. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29562. * @param value The input slider value in range [-100,100].
  29563. * @returns Adjusted value.
  29564. */
  29565. private static applyColorGradingSliderNonlinear;
  29566. /**
  29567. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29568. * @param hue The hue (H) input.
  29569. * @param saturation The saturation (S) input.
  29570. * @param brightness The brightness (B) input.
  29571. * @result An RGBA color represented as Vector4.
  29572. */
  29573. private static fromHSBToRef;
  29574. /**
  29575. * Returns a value clamped between min and max
  29576. * @param value The value to clamp
  29577. * @param min The minimum of value
  29578. * @param max The maximum of value
  29579. * @returns The clamped value.
  29580. */
  29581. private static clamp;
  29582. /**
  29583. * Clones the current color curve instance.
  29584. * @return The cloned curves
  29585. */
  29586. clone(): ColorCurves;
  29587. /**
  29588. * Serializes the current color curve instance to a json representation.
  29589. * @return a JSON representation
  29590. */
  29591. serialize(): any;
  29592. /**
  29593. * Parses the color curve from a json representation.
  29594. * @param source the JSON source to parse
  29595. * @return The parsed curves
  29596. */
  29597. static Parse(source: any): ColorCurves;
  29598. }
  29599. }
  29600. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29601. import { Observable } from "babylonjs/Misc/observable";
  29602. import { Nullable } from "babylonjs/types";
  29603. import { Color4 } from "babylonjs/Maths/math";
  29604. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29605. import { Effect } from "babylonjs/Materials/effect";
  29606. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29607. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29608. /**
  29609. * Interface to follow in your material defines to integrate easily the
  29610. * Image proccessing functions.
  29611. * @hidden
  29612. */
  29613. export interface IImageProcessingConfigurationDefines {
  29614. IMAGEPROCESSING: boolean;
  29615. VIGNETTE: boolean;
  29616. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29617. VIGNETTEBLENDMODEOPAQUE: boolean;
  29618. TONEMAPPING: boolean;
  29619. TONEMAPPING_ACES: boolean;
  29620. CONTRAST: boolean;
  29621. EXPOSURE: boolean;
  29622. COLORCURVES: boolean;
  29623. COLORGRADING: boolean;
  29624. COLORGRADING3D: boolean;
  29625. SAMPLER3DGREENDEPTH: boolean;
  29626. SAMPLER3DBGRMAP: boolean;
  29627. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29628. }
  29629. /**
  29630. * @hidden
  29631. */
  29632. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29633. IMAGEPROCESSING: boolean;
  29634. VIGNETTE: boolean;
  29635. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29636. VIGNETTEBLENDMODEOPAQUE: boolean;
  29637. TONEMAPPING: boolean;
  29638. TONEMAPPING_ACES: boolean;
  29639. CONTRAST: boolean;
  29640. COLORCURVES: boolean;
  29641. COLORGRADING: boolean;
  29642. COLORGRADING3D: boolean;
  29643. SAMPLER3DGREENDEPTH: boolean;
  29644. SAMPLER3DBGRMAP: boolean;
  29645. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29646. EXPOSURE: boolean;
  29647. constructor();
  29648. }
  29649. /**
  29650. * This groups together the common properties used for image processing either in direct forward pass
  29651. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29652. * or not.
  29653. */
  29654. export class ImageProcessingConfiguration {
  29655. /**
  29656. * Default tone mapping applied in BabylonJS.
  29657. */
  29658. static readonly TONEMAPPING_STANDARD: number;
  29659. /**
  29660. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29661. * to other engines rendering to increase portability.
  29662. */
  29663. static readonly TONEMAPPING_ACES: number;
  29664. /**
  29665. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29666. */
  29667. colorCurves: Nullable<ColorCurves>;
  29668. private _colorCurvesEnabled;
  29669. /**
  29670. * Gets wether the color curves effect is enabled.
  29671. */
  29672. /**
  29673. * Sets wether the color curves effect is enabled.
  29674. */
  29675. colorCurvesEnabled: boolean;
  29676. private _colorGradingTexture;
  29677. /**
  29678. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29679. */
  29680. /**
  29681. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29682. */
  29683. colorGradingTexture: Nullable<BaseTexture>;
  29684. private _colorGradingEnabled;
  29685. /**
  29686. * Gets wether the color grading effect is enabled.
  29687. */
  29688. /**
  29689. * Sets wether the color grading effect is enabled.
  29690. */
  29691. colorGradingEnabled: boolean;
  29692. private _colorGradingWithGreenDepth;
  29693. /**
  29694. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29695. */
  29696. /**
  29697. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29698. */
  29699. colorGradingWithGreenDepth: boolean;
  29700. private _colorGradingBGR;
  29701. /**
  29702. * Gets wether the color grading texture contains BGR values.
  29703. */
  29704. /**
  29705. * Sets wether the color grading texture contains BGR values.
  29706. */
  29707. colorGradingBGR: boolean;
  29708. /** @hidden */
  29709. _exposure: number;
  29710. /**
  29711. * Gets the Exposure used in the effect.
  29712. */
  29713. /**
  29714. * Sets the Exposure used in the effect.
  29715. */
  29716. exposure: number;
  29717. private _toneMappingEnabled;
  29718. /**
  29719. * Gets wether the tone mapping effect is enabled.
  29720. */
  29721. /**
  29722. * Sets wether the tone mapping effect is enabled.
  29723. */
  29724. toneMappingEnabled: boolean;
  29725. private _toneMappingType;
  29726. /**
  29727. * Gets the type of tone mapping effect.
  29728. */
  29729. /**
  29730. * Sets the type of tone mapping effect used in BabylonJS.
  29731. */
  29732. toneMappingType: number;
  29733. protected _contrast: number;
  29734. /**
  29735. * Gets the contrast used in the effect.
  29736. */
  29737. /**
  29738. * Sets the contrast used in the effect.
  29739. */
  29740. contrast: number;
  29741. /**
  29742. * Vignette stretch size.
  29743. */
  29744. vignetteStretch: number;
  29745. /**
  29746. * Vignette centre X Offset.
  29747. */
  29748. vignetteCentreX: number;
  29749. /**
  29750. * Vignette centre Y Offset.
  29751. */
  29752. vignetteCentreY: number;
  29753. /**
  29754. * Vignette weight or intensity of the vignette effect.
  29755. */
  29756. vignetteWeight: number;
  29757. /**
  29758. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29759. * if vignetteEnabled is set to true.
  29760. */
  29761. vignetteColor: Color4;
  29762. /**
  29763. * Camera field of view used by the Vignette effect.
  29764. */
  29765. vignetteCameraFov: number;
  29766. private _vignetteBlendMode;
  29767. /**
  29768. * Gets the vignette blend mode allowing different kind of effect.
  29769. */
  29770. /**
  29771. * Sets the vignette blend mode allowing different kind of effect.
  29772. */
  29773. vignetteBlendMode: number;
  29774. private _vignetteEnabled;
  29775. /**
  29776. * Gets wether the vignette effect is enabled.
  29777. */
  29778. /**
  29779. * Sets wether the vignette effect is enabled.
  29780. */
  29781. vignetteEnabled: boolean;
  29782. private _applyByPostProcess;
  29783. /**
  29784. * Gets wether the image processing is applied through a post process or not.
  29785. */
  29786. /**
  29787. * Sets wether the image processing is applied through a post process or not.
  29788. */
  29789. applyByPostProcess: boolean;
  29790. private _isEnabled;
  29791. /**
  29792. * Gets wether the image processing is enabled or not.
  29793. */
  29794. /**
  29795. * Sets wether the image processing is enabled or not.
  29796. */
  29797. isEnabled: boolean;
  29798. /**
  29799. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29800. */
  29801. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29802. /**
  29803. * Method called each time the image processing information changes requires to recompile the effect.
  29804. */
  29805. protected _updateParameters(): void;
  29806. /**
  29807. * Gets the current class name.
  29808. * @return "ImageProcessingConfiguration"
  29809. */
  29810. getClassName(): string;
  29811. /**
  29812. * Prepare the list of uniforms associated with the Image Processing effects.
  29813. * @param uniforms The list of uniforms used in the effect
  29814. * @param defines the list of defines currently in use
  29815. */
  29816. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29817. /**
  29818. * Prepare the list of samplers associated with the Image Processing effects.
  29819. * @param samplersList The list of uniforms used in the effect
  29820. * @param defines the list of defines currently in use
  29821. */
  29822. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29823. /**
  29824. * Prepare the list of defines associated to the shader.
  29825. * @param defines the list of defines to complete
  29826. * @param forPostProcess Define if we are currently in post process mode or not
  29827. */
  29828. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29829. /**
  29830. * Returns true if all the image processing information are ready.
  29831. * @returns True if ready, otherwise, false
  29832. */
  29833. isReady(): boolean;
  29834. /**
  29835. * Binds the image processing to the shader.
  29836. * @param effect The effect to bind to
  29837. * @param aspectRatio Define the current aspect ratio of the effect
  29838. */
  29839. bind(effect: Effect, aspectRatio?: number): void;
  29840. /**
  29841. * Clones the current image processing instance.
  29842. * @return The cloned image processing
  29843. */
  29844. clone(): ImageProcessingConfiguration;
  29845. /**
  29846. * Serializes the current image processing instance to a json representation.
  29847. * @return a JSON representation
  29848. */
  29849. serialize(): any;
  29850. /**
  29851. * Parses the image processing from a json representation.
  29852. * @param source the JSON source to parse
  29853. * @return The parsed image processing
  29854. */
  29855. static Parse(source: any): ImageProcessingConfiguration;
  29856. private static _VIGNETTEMODE_MULTIPLY;
  29857. private static _VIGNETTEMODE_OPAQUE;
  29858. /**
  29859. * Used to apply the vignette as a mix with the pixel color.
  29860. */
  29861. static readonly VIGNETTEMODE_MULTIPLY: number;
  29862. /**
  29863. * Used to apply the vignette as a replacement of the pixel color.
  29864. */
  29865. static readonly VIGNETTEMODE_OPAQUE: number;
  29866. }
  29867. }
  29868. declare module "babylonjs/Materials/fresnelParameters" {
  29869. import { Color3 } from "babylonjs/Maths/math";
  29870. /**
  29871. * This represents all the required information to add a fresnel effect on a material:
  29872. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29873. */
  29874. export class FresnelParameters {
  29875. private _isEnabled;
  29876. /**
  29877. * Define if the fresnel effect is enable or not.
  29878. */
  29879. isEnabled: boolean;
  29880. /**
  29881. * Define the color used on edges (grazing angle)
  29882. */
  29883. leftColor: Color3;
  29884. /**
  29885. * Define the color used on center
  29886. */
  29887. rightColor: Color3;
  29888. /**
  29889. * Define bias applied to computed fresnel term
  29890. */
  29891. bias: number;
  29892. /**
  29893. * Defined the power exponent applied to fresnel term
  29894. */
  29895. power: number;
  29896. /**
  29897. * Clones the current fresnel and its valuues
  29898. * @returns a clone fresnel configuration
  29899. */
  29900. clone(): FresnelParameters;
  29901. /**
  29902. * Serializes the current fresnel parameters to a JSON representation.
  29903. * @return the JSON serialization
  29904. */
  29905. serialize(): any;
  29906. /**
  29907. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29908. * @param parsedFresnelParameters Define the JSON representation
  29909. * @returns the parsed parameters
  29910. */
  29911. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29912. }
  29913. }
  29914. declare module "babylonjs/Misc/decorators" {
  29915. import { Nullable } from "babylonjs/types";
  29916. import { Scene } from "babylonjs/scene";
  29917. import { IAnimatable } from "babylonjs/Misc/tools";
  29918. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29919. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29920. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29921. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29922. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29923. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29924. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29925. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29926. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29927. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29928. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29929. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29930. /**
  29931. * Decorator used to define property that can be serialized as reference to a camera
  29932. * @param sourceName defines the name of the property to decorate
  29933. */
  29934. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29935. /**
  29936. * Class used to help serialization objects
  29937. */
  29938. export class SerializationHelper {
  29939. /** hidden */
  29940. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  29941. /** hidden */
  29942. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  29943. /** hidden */
  29944. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  29945. /** hidden */
  29946. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  29947. /**
  29948. * Appends the serialized animations from the source animations
  29949. * @param source Source containing the animations
  29950. * @param destination Target to store the animations
  29951. */
  29952. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29953. /**
  29954. * Static function used to serialized a specific entity
  29955. * @param entity defines the entity to serialize
  29956. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29957. * @returns a JSON compatible object representing the serialization of the entity
  29958. */
  29959. static Serialize<T>(entity: T, serializationObject?: any): any;
  29960. /**
  29961. * Creates a new entity from a serialization data object
  29962. * @param creationFunction defines a function used to instanciated the new entity
  29963. * @param source defines the source serialization data
  29964. * @param scene defines the hosting scene
  29965. * @param rootUrl defines the root url for resources
  29966. * @returns a new entity
  29967. */
  29968. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29969. /**
  29970. * Clones an object
  29971. * @param creationFunction defines the function used to instanciate the new object
  29972. * @param source defines the source object
  29973. * @returns the cloned object
  29974. */
  29975. static Clone<T>(creationFunction: () => T, source: T): T;
  29976. /**
  29977. * Instanciates a new object based on a source one (some data will be shared between both object)
  29978. * @param creationFunction defines the function used to instanciate the new object
  29979. * @param source defines the source object
  29980. * @returns the new object
  29981. */
  29982. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29983. }
  29984. }
  29985. declare module "babylonjs/Cameras/camera" {
  29986. import { SmartArray } from "babylonjs/Misc/smartArray";
  29987. import { Observable } from "babylonjs/Misc/observable";
  29988. import { Nullable } from "babylonjs/types";
  29989. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  29990. import { Scene } from "babylonjs/scene";
  29991. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  29992. import { Node } from "babylonjs/node";
  29993. import { Mesh } from "babylonjs/Meshes/mesh";
  29994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29995. import { ICullable } from "babylonjs/Culling/boundingInfo";
  29996. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29997. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29998. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  29999. import { Ray } from "babylonjs/Culling/ray";
  30000. /**
  30001. * This is the base class of all the camera used in the application.
  30002. * @see http://doc.babylonjs.com/features/cameras
  30003. */
  30004. export class Camera extends Node {
  30005. /** @hidden */
  30006. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30007. /**
  30008. * This is the default projection mode used by the cameras.
  30009. * It helps recreating a feeling of perspective and better appreciate depth.
  30010. * This is the best way to simulate real life cameras.
  30011. */
  30012. static readonly PERSPECTIVE_CAMERA: number;
  30013. /**
  30014. * This helps creating camera with an orthographic mode.
  30015. * 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.
  30016. */
  30017. static readonly ORTHOGRAPHIC_CAMERA: number;
  30018. /**
  30019. * This is the default FOV mode for perspective cameras.
  30020. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30021. */
  30022. static readonly FOVMODE_VERTICAL_FIXED: number;
  30023. /**
  30024. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30025. */
  30026. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30027. /**
  30028. * This specifies ther is no need for a camera rig.
  30029. * Basically only one eye is rendered corresponding to the camera.
  30030. */
  30031. static readonly RIG_MODE_NONE: number;
  30032. /**
  30033. * Simulates a camera Rig with one blue eye and one red eye.
  30034. * This can be use with 3d blue and red glasses.
  30035. */
  30036. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30037. /**
  30038. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30039. */
  30040. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30041. /**
  30042. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30043. */
  30044. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30045. /**
  30046. * Defines that both eyes of the camera will be rendered over under each other.
  30047. */
  30048. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30049. /**
  30050. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30051. */
  30052. static readonly RIG_MODE_VR: number;
  30053. /**
  30054. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30055. */
  30056. static readonly RIG_MODE_WEBVR: number;
  30057. /**
  30058. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30059. */
  30060. static readonly RIG_MODE_CUSTOM: number;
  30061. /**
  30062. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30063. */
  30064. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30065. /**
  30066. * @hidden
  30067. * Might be removed once multiview will be a thing
  30068. */
  30069. static UseAlternateWebVRRendering: boolean;
  30070. /**
  30071. * Define the input manager associated with the camera.
  30072. */
  30073. inputs: CameraInputsManager<Camera>;
  30074. /**
  30075. * Define the current local position of the camera in the scene
  30076. */
  30077. position: Vector3;
  30078. /**
  30079. * The vector the camera should consider as up.
  30080. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30081. */
  30082. upVector: Vector3;
  30083. /**
  30084. * Define the current limit on the left side for an orthographic camera
  30085. * In scene unit
  30086. */
  30087. orthoLeft: Nullable<number>;
  30088. /**
  30089. * Define the current limit on the right side for an orthographic camera
  30090. * In scene unit
  30091. */
  30092. orthoRight: Nullable<number>;
  30093. /**
  30094. * Define the current limit on the bottom side for an orthographic camera
  30095. * In scene unit
  30096. */
  30097. orthoBottom: Nullable<number>;
  30098. /**
  30099. * Define the current limit on the top side for an orthographic camera
  30100. * In scene unit
  30101. */
  30102. orthoTop: Nullable<number>;
  30103. /**
  30104. * Field Of View is set in Radians. (default is 0.8)
  30105. */
  30106. fov: number;
  30107. /**
  30108. * Define the minimum distance the camera can see from.
  30109. * This is important to note that the depth buffer are not infinite and the closer it starts
  30110. * the more your scene might encounter depth fighting issue.
  30111. */
  30112. minZ: number;
  30113. /**
  30114. * Define the maximum distance the camera can see to.
  30115. * This is important to note that the depth buffer are not infinite and the further it end
  30116. * the more your scene might encounter depth fighting issue.
  30117. */
  30118. maxZ: number;
  30119. /**
  30120. * Define the default inertia of the camera.
  30121. * This helps giving a smooth feeling to the camera movement.
  30122. */
  30123. inertia: number;
  30124. /**
  30125. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30126. */
  30127. mode: number;
  30128. /**
  30129. * Define wether the camera is intermediate.
  30130. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30131. */
  30132. isIntermediate: boolean;
  30133. /**
  30134. * Define the viewport of the camera.
  30135. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30136. */
  30137. viewport: Viewport;
  30138. /**
  30139. * Restricts the camera to viewing objects with the same layerMask.
  30140. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30141. */
  30142. layerMask: number;
  30143. /**
  30144. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30145. */
  30146. fovMode: number;
  30147. /**
  30148. * Rig mode of the camera.
  30149. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30150. * This is normally controlled byt the camera themselves as internal use.
  30151. */
  30152. cameraRigMode: number;
  30153. /**
  30154. * Defines the distance between both "eyes" in case of a RIG
  30155. */
  30156. interaxialDistance: number;
  30157. /**
  30158. * Defines if stereoscopic rendering is done side by side or over under.
  30159. */
  30160. isStereoscopicSideBySide: boolean;
  30161. /**
  30162. * 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
  30163. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30164. * else in the scene.
  30165. */
  30166. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30167. /**
  30168. * When set, the camera will render to this render target instead of the default canvas
  30169. */
  30170. outputRenderTarget: Nullable<RenderTargetTexture>;
  30171. /**
  30172. * Observable triggered when the camera view matrix has changed.
  30173. */
  30174. onViewMatrixChangedObservable: Observable<Camera>;
  30175. /**
  30176. * Observable triggered when the camera Projection matrix has changed.
  30177. */
  30178. onProjectionMatrixChangedObservable: Observable<Camera>;
  30179. /**
  30180. * Observable triggered when the inputs have been processed.
  30181. */
  30182. onAfterCheckInputsObservable: Observable<Camera>;
  30183. /**
  30184. * Observable triggered when reset has been called and applied to the camera.
  30185. */
  30186. onRestoreStateObservable: Observable<Camera>;
  30187. /** @hidden */
  30188. _cameraRigParams: any;
  30189. /** @hidden */
  30190. _rigCameras: Camera[];
  30191. /** @hidden */
  30192. _rigPostProcess: Nullable<PostProcess>;
  30193. protected _webvrViewMatrix: Matrix;
  30194. /** @hidden */
  30195. _skipRendering: boolean;
  30196. /** @hidden */
  30197. _alternateCamera: Camera;
  30198. /** @hidden */
  30199. _projectionMatrix: Matrix;
  30200. /** @hidden */
  30201. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30202. /** @hidden */
  30203. _activeMeshes: SmartArray<AbstractMesh>;
  30204. protected _globalPosition: Vector3;
  30205. /** hidden */
  30206. _computedViewMatrix: Matrix;
  30207. private _doNotComputeProjectionMatrix;
  30208. private _transformMatrix;
  30209. private _frustumPlanes;
  30210. private _refreshFrustumPlanes;
  30211. private _storedFov;
  30212. private _stateStored;
  30213. /**
  30214. * Instantiates a new camera object.
  30215. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30216. * @see http://doc.babylonjs.com/features/cameras
  30217. * @param name Defines the name of the camera in the scene
  30218. * @param position Defines the position of the camera
  30219. * @param scene Defines the scene the camera belongs too
  30220. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30221. */
  30222. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30223. /**
  30224. * Store current camera state (fov, position, etc..)
  30225. * @returns the camera
  30226. */
  30227. storeState(): Camera;
  30228. /**
  30229. * Restores the camera state values if it has been stored. You must call storeState() first
  30230. */
  30231. protected _restoreStateValues(): boolean;
  30232. /**
  30233. * Restored camera state. You must call storeState() first.
  30234. * @returns true if restored and false otherwise
  30235. */
  30236. restoreState(): boolean;
  30237. /**
  30238. * Gets the class name of the camera.
  30239. * @returns the class name
  30240. */
  30241. getClassName(): string;
  30242. /** @hidden */
  30243. readonly _isCamera: boolean;
  30244. /**
  30245. * Gets a string representation of the camera useful for debug purpose.
  30246. * @param fullDetails Defines that a more verboe level of logging is required
  30247. * @returns the string representation
  30248. */
  30249. toString(fullDetails?: boolean): string;
  30250. /**
  30251. * Gets the current world space position of the camera.
  30252. */
  30253. readonly globalPosition: Vector3;
  30254. /**
  30255. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30256. * @returns the active meshe list
  30257. */
  30258. getActiveMeshes(): SmartArray<AbstractMesh>;
  30259. /**
  30260. * Check wether a mesh is part of the current active mesh list of the camera
  30261. * @param mesh Defines the mesh to check
  30262. * @returns true if active, false otherwise
  30263. */
  30264. isActiveMesh(mesh: Mesh): boolean;
  30265. /**
  30266. * Is this camera ready to be used/rendered
  30267. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30268. * @return true if the camera is ready
  30269. */
  30270. isReady(completeCheck?: boolean): boolean;
  30271. /** @hidden */
  30272. _initCache(): void;
  30273. /** @hidden */
  30274. _updateCache(ignoreParentClass?: boolean): void;
  30275. /** @hidden */
  30276. _isSynchronized(): boolean;
  30277. /** @hidden */
  30278. _isSynchronizedViewMatrix(): boolean;
  30279. /** @hidden */
  30280. _isSynchronizedProjectionMatrix(): boolean;
  30281. /**
  30282. * Attach the input controls to a specific dom element to get the input from.
  30283. * @param element Defines the element the controls should be listened from
  30284. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30285. */
  30286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30287. /**
  30288. * Detach the current controls from the specified dom element.
  30289. * @param element Defines the element to stop listening the inputs from
  30290. */
  30291. detachControl(element: HTMLElement): void;
  30292. /**
  30293. * Update the camera state according to the different inputs gathered during the frame.
  30294. */
  30295. update(): void;
  30296. /** @hidden */
  30297. _checkInputs(): void;
  30298. /** @hidden */
  30299. readonly rigCameras: Camera[];
  30300. /**
  30301. * Gets the post process used by the rig cameras
  30302. */
  30303. readonly rigPostProcess: Nullable<PostProcess>;
  30304. /**
  30305. * Internal, gets the first post proces.
  30306. * @returns the first post process to be run on this camera.
  30307. */
  30308. _getFirstPostProcess(): Nullable<PostProcess>;
  30309. private _cascadePostProcessesToRigCams;
  30310. /**
  30311. * Attach a post process to the camera.
  30312. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30313. * @param postProcess The post process to attach to the camera
  30314. * @param insertAt The position of the post process in case several of them are in use in the scene
  30315. * @returns the position the post process has been inserted at
  30316. */
  30317. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30318. /**
  30319. * Detach a post process to the camera.
  30320. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30321. * @param postProcess The post process to detach from the camera
  30322. */
  30323. detachPostProcess(postProcess: PostProcess): void;
  30324. /**
  30325. * Gets the current world matrix of the camera
  30326. */
  30327. getWorldMatrix(): Matrix;
  30328. /** @hidden */
  30329. _getViewMatrix(): Matrix;
  30330. /**
  30331. * Gets the current view matrix of the camera.
  30332. * @param force forces the camera to recompute the matrix without looking at the cached state
  30333. * @returns the view matrix
  30334. */
  30335. getViewMatrix(force?: boolean): Matrix;
  30336. /**
  30337. * Freeze the projection matrix.
  30338. * It will prevent the cache check of the camera projection compute and can speed up perf
  30339. * if no parameter of the camera are meant to change
  30340. * @param projection Defines manually a projection if necessary
  30341. */
  30342. freezeProjectionMatrix(projection?: Matrix): void;
  30343. /**
  30344. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30345. */
  30346. unfreezeProjectionMatrix(): void;
  30347. /**
  30348. * Gets the current projection matrix of the camera.
  30349. * @param force forces the camera to recompute the matrix without looking at the cached state
  30350. * @returns the projection matrix
  30351. */
  30352. getProjectionMatrix(force?: boolean): Matrix;
  30353. /**
  30354. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30355. * @returns a Matrix
  30356. */
  30357. getTransformationMatrix(): Matrix;
  30358. private _updateFrustumPlanes;
  30359. /**
  30360. * Checks if a cullable object (mesh...) is in the camera frustum
  30361. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30362. * @param target The object to check
  30363. * @returns true if the object is in frustum otherwise false
  30364. */
  30365. isInFrustum(target: ICullable): boolean;
  30366. /**
  30367. * Checks if a cullable object (mesh...) is in the camera frustum
  30368. * Unlike isInFrustum this cheks the full bounding box
  30369. * @param target The object to check
  30370. * @returns true if the object is in frustum otherwise false
  30371. */
  30372. isCompletelyInFrustum(target: ICullable): boolean;
  30373. /**
  30374. * Gets a ray in the forward direction from the camera.
  30375. * @param length Defines the length of the ray to create
  30376. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30377. * @param origin Defines the start point of the ray which defaults to the camera position
  30378. * @returns the forward ray
  30379. */
  30380. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30381. /**
  30382. * Releases resources associated with this node.
  30383. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30384. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30385. */
  30386. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30387. /**
  30388. * Gets the left camera of a rig setup in case of Rigged Camera
  30389. */
  30390. readonly leftCamera: Nullable<FreeCamera>;
  30391. /**
  30392. * Gets the right camera of a rig setup in case of Rigged Camera
  30393. */
  30394. readonly rightCamera: Nullable<FreeCamera>;
  30395. /**
  30396. * Gets the left camera target of a rig setup in case of Rigged Camera
  30397. * @returns the target position
  30398. */
  30399. getLeftTarget(): Nullable<Vector3>;
  30400. /**
  30401. * Gets the right camera target of a rig setup in case of Rigged Camera
  30402. * @returns the target position
  30403. */
  30404. getRightTarget(): Nullable<Vector3>;
  30405. /**
  30406. * @hidden
  30407. */
  30408. setCameraRigMode(mode: number, rigParams: any): void;
  30409. /** @hidden */
  30410. static _setStereoscopicRigMode(camera: Camera): void;
  30411. /** @hidden */
  30412. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30413. /** @hidden */
  30414. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30415. /** @hidden */
  30416. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30417. /** @hidden */
  30418. _getVRProjectionMatrix(): Matrix;
  30419. protected _updateCameraRotationMatrix(): void;
  30420. protected _updateWebVRCameraRotationMatrix(): void;
  30421. /**
  30422. * This function MUST be overwritten by the different WebVR cameras available.
  30423. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30424. * @hidden
  30425. */
  30426. _getWebVRProjectionMatrix(): Matrix;
  30427. /**
  30428. * This function MUST be overwritten by the different WebVR cameras available.
  30429. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30430. * @hidden
  30431. */
  30432. _getWebVRViewMatrix(): Matrix;
  30433. /** @hidden */
  30434. setCameraRigParameter(name: string, value: any): void;
  30435. /**
  30436. * needs to be overridden by children so sub has required properties to be copied
  30437. * @hidden
  30438. */
  30439. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30440. /**
  30441. * May need to be overridden by children
  30442. * @hidden
  30443. */
  30444. _updateRigCameras(): void;
  30445. /** @hidden */
  30446. _setupInputs(): void;
  30447. /**
  30448. * Serialiaze the camera setup to a json represention
  30449. * @returns the JSON representation
  30450. */
  30451. serialize(): any;
  30452. /**
  30453. * Clones the current camera.
  30454. * @param name The cloned camera name
  30455. * @returns the cloned camera
  30456. */
  30457. clone(name: string): Camera;
  30458. /**
  30459. * Gets the direction of the camera relative to a given local axis.
  30460. * @param localAxis Defines the reference axis to provide a relative direction.
  30461. * @return the direction
  30462. */
  30463. getDirection(localAxis: Vector3): Vector3;
  30464. /**
  30465. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30466. * @param localAxis Defines the reference axis to provide a relative direction.
  30467. * @param result Defines the vector to store the result in
  30468. */
  30469. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30470. /**
  30471. * Gets a camera constructor for a given camera type
  30472. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30473. * @param name The name of the camera the result will be able to instantiate
  30474. * @param scene The scene the result will construct the camera in
  30475. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30476. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30477. * @returns a factory method to construc the camera
  30478. */
  30479. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30480. /**
  30481. * Compute the world matrix of the camera.
  30482. * @returns the camera workd matrix
  30483. */
  30484. computeWorldMatrix(): Matrix;
  30485. /**
  30486. * Parse a JSON and creates the camera from the parsed information
  30487. * @param parsedCamera The JSON to parse
  30488. * @param scene The scene to instantiate the camera in
  30489. * @returns the newly constructed camera
  30490. */
  30491. static Parse(parsedCamera: any, scene: Scene): Camera;
  30492. }
  30493. }
  30494. declare module "babylonjs/Misc/tools" {
  30495. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30496. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30497. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30498. import { Observable } from "babylonjs/Misc/observable";
  30499. import { DomManagement } from "babylonjs/Misc/domManagement";
  30500. import { Camera } from "babylonjs/Cameras/camera";
  30501. import { Engine } from "babylonjs/Engines/engine";
  30502. import { Animation } from "babylonjs/Animations/animation";
  30503. /**
  30504. * Interface for any object that can request an animation frame
  30505. */
  30506. export interface ICustomAnimationFrameRequester {
  30507. /**
  30508. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30509. */
  30510. renderFunction?: Function;
  30511. /**
  30512. * Called to request the next frame to render to
  30513. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30514. */
  30515. requestAnimationFrame: Function;
  30516. /**
  30517. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30518. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30519. */
  30520. requestID?: number;
  30521. }
  30522. /**
  30523. * Interface containing an array of animations
  30524. */
  30525. export interface IAnimatable {
  30526. /**
  30527. * Array of animations
  30528. */
  30529. animations: Array<Animation>;
  30530. }
  30531. /** Interface used by value gradients (color, factor, ...) */
  30532. export interface IValueGradient {
  30533. /**
  30534. * Gets or sets the gradient value (between 0 and 1)
  30535. */
  30536. gradient: number;
  30537. }
  30538. /** Class used to store color4 gradient */
  30539. export class ColorGradient implements IValueGradient {
  30540. /**
  30541. * Gets or sets the gradient value (between 0 and 1)
  30542. */
  30543. gradient: number;
  30544. /**
  30545. * Gets or sets first associated color
  30546. */
  30547. color1: Color4;
  30548. /**
  30549. * Gets or sets second associated color
  30550. */
  30551. color2?: Color4;
  30552. /**
  30553. * Will get a color picked randomly between color1 and color2.
  30554. * If color2 is undefined then color1 will be used
  30555. * @param result defines the target Color4 to store the result in
  30556. */
  30557. getColorToRef(result: Color4): void;
  30558. }
  30559. /** Class used to store color 3 gradient */
  30560. export class Color3Gradient implements IValueGradient {
  30561. /**
  30562. * Gets or sets the gradient value (between 0 and 1)
  30563. */
  30564. gradient: number;
  30565. /**
  30566. * Gets or sets the associated color
  30567. */
  30568. color: Color3;
  30569. }
  30570. /** Class used to store factor gradient */
  30571. export class FactorGradient implements IValueGradient {
  30572. /**
  30573. * Gets or sets the gradient value (between 0 and 1)
  30574. */
  30575. gradient: number;
  30576. /**
  30577. * Gets or sets first associated factor
  30578. */
  30579. factor1: number;
  30580. /**
  30581. * Gets or sets second associated factor
  30582. */
  30583. factor2?: number;
  30584. /**
  30585. * Will get a number picked randomly between factor1 and factor2.
  30586. * If factor2 is undefined then factor1 will be used
  30587. * @returns the picked number
  30588. */
  30589. getFactor(): number;
  30590. }
  30591. /**
  30592. * @ignore
  30593. * Application error to support additional information when loading a file
  30594. */
  30595. export class LoadFileError extends Error {
  30596. /** defines the optional XHR request */
  30597. request?: XMLHttpRequest | undefined;
  30598. private static _setPrototypeOf;
  30599. /**
  30600. * Creates a new LoadFileError
  30601. * @param message defines the message of the error
  30602. * @param request defines the optional XHR request
  30603. */
  30604. constructor(message: string,
  30605. /** defines the optional XHR request */
  30606. request?: XMLHttpRequest | undefined);
  30607. }
  30608. /**
  30609. * Class used to define a retry strategy when error happens while loading assets
  30610. */
  30611. export class RetryStrategy {
  30612. /**
  30613. * Function used to defines an exponential back off strategy
  30614. * @param maxRetries defines the maximum number of retries (3 by default)
  30615. * @param baseInterval defines the interval between retries
  30616. * @returns the strategy function to use
  30617. */
  30618. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30619. }
  30620. /**
  30621. * File request interface
  30622. */
  30623. export interface IFileRequest {
  30624. /**
  30625. * Raised when the request is complete (success or error).
  30626. */
  30627. onCompleteObservable: Observable<IFileRequest>;
  30628. /**
  30629. * Aborts the request for a file.
  30630. */
  30631. abort: () => void;
  30632. }
  30633. /**
  30634. * Class containing a set of static utilities functions
  30635. */
  30636. export class Tools {
  30637. /**
  30638. * Gets or sets the base URL to use to load assets
  30639. */
  30640. static BaseUrl: string;
  30641. /**
  30642. * Enable/Disable Custom HTTP Request Headers globally.
  30643. * default = false
  30644. * @see CustomRequestHeaders
  30645. */
  30646. static UseCustomRequestHeaders: boolean;
  30647. /**
  30648. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30649. * i.e. when loading files, where the server/service expects an Authorization header.
  30650. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  30651. */
  30652. static CustomRequestHeaders: {
  30653. [key: string]: string;
  30654. };
  30655. /**
  30656. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30657. */
  30658. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30659. /**
  30660. * Default behaviour for cors in the application.
  30661. * It can be a string if the expected behavior is identical in the entire app.
  30662. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30663. */
  30664. static CorsBehavior: string | ((url: string | string[]) => string);
  30665. /**
  30666. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30667. * @ignorenaming
  30668. */
  30669. static UseFallbackTexture: boolean;
  30670. /**
  30671. * Use this object to register external classes like custom textures or material
  30672. * to allow the laoders to instantiate them
  30673. */
  30674. static RegisteredExternalClasses: {
  30675. [key: string]: Object;
  30676. };
  30677. /**
  30678. * Texture content used if a texture cannot loaded
  30679. * @ignorenaming
  30680. */
  30681. static fallbackTexture: string;
  30682. /**
  30683. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30684. * @param u defines the coordinate on X axis
  30685. * @param v defines the coordinate on Y axis
  30686. * @param width defines the width of the source data
  30687. * @param height defines the height of the source data
  30688. * @param pixels defines the source byte array
  30689. * @param color defines the output color
  30690. */
  30691. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30692. /**
  30693. * Interpolates between a and b via alpha
  30694. * @param a The lower value (returned when alpha = 0)
  30695. * @param b The upper value (returned when alpha = 1)
  30696. * @param alpha The interpolation-factor
  30697. * @return The mixed value
  30698. */
  30699. static Mix(a: number, b: number, alpha: number): number;
  30700. /**
  30701. * Tries to instantiate a new object from a given class name
  30702. * @param className defines the class name to instantiate
  30703. * @returns the new object or null if the system was not able to do the instantiation
  30704. */
  30705. static Instantiate(className: string): any;
  30706. /**
  30707. * Provides a slice function that will work even on IE
  30708. * @param data defines the array to slice
  30709. * @param start defines the start of the data (optional)
  30710. * @param end defines the end of the data (optional)
  30711. * @returns the new sliced array
  30712. */
  30713. static Slice<T>(data: T, start?: number, end?: number): T;
  30714. /**
  30715. * Polyfill for setImmediate
  30716. * @param action defines the action to execute after the current execution block
  30717. */
  30718. static SetImmediate(action: () => void): void;
  30719. /**
  30720. * Function indicating if a number is an exponent of 2
  30721. * @param value defines the value to test
  30722. * @returns true if the value is an exponent of 2
  30723. */
  30724. static IsExponentOfTwo(value: number): boolean;
  30725. private static _tmpFloatArray;
  30726. /**
  30727. * Returns the nearest 32-bit single precision float representation of a Number
  30728. * @param value A Number. If the parameter is of a different type, it will get converted
  30729. * to a number or to NaN if it cannot be converted
  30730. * @returns number
  30731. */
  30732. static FloatRound(value: number): number;
  30733. /**
  30734. * Find the next highest power of two.
  30735. * @param x Number to start search from.
  30736. * @return Next highest power of two.
  30737. */
  30738. static CeilingPOT(x: number): number;
  30739. /**
  30740. * Find the next lowest power of two.
  30741. * @param x Number to start search from.
  30742. * @return Next lowest power of two.
  30743. */
  30744. static FloorPOT(x: number): number;
  30745. /**
  30746. * Find the nearest power of two.
  30747. * @param x Number to start search from.
  30748. * @return Next nearest power of two.
  30749. */
  30750. static NearestPOT(x: number): number;
  30751. /**
  30752. * Get the closest exponent of two
  30753. * @param value defines the value to approximate
  30754. * @param max defines the maximum value to return
  30755. * @param mode defines how to define the closest value
  30756. * @returns closest exponent of two of the given value
  30757. */
  30758. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30759. /**
  30760. * Extracts the filename from a path
  30761. * @param path defines the path to use
  30762. * @returns the filename
  30763. */
  30764. static GetFilename(path: string): string;
  30765. /**
  30766. * Extracts the "folder" part of a path (everything before the filename).
  30767. * @param uri The URI to extract the info from
  30768. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30769. * @returns The "folder" part of the path
  30770. */
  30771. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30772. /**
  30773. * Extracts text content from a DOM element hierarchy
  30774. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30775. */
  30776. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30777. /**
  30778. * Convert an angle in radians to degrees
  30779. * @param angle defines the angle to convert
  30780. * @returns the angle in degrees
  30781. */
  30782. static ToDegrees(angle: number): number;
  30783. /**
  30784. * Convert an angle in degrees to radians
  30785. * @param angle defines the angle to convert
  30786. * @returns the angle in radians
  30787. */
  30788. static ToRadians(angle: number): number;
  30789. /**
  30790. * Encode a buffer to a base64 string
  30791. * @param buffer defines the buffer to encode
  30792. * @returns the encoded string
  30793. */
  30794. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30795. /**
  30796. * Extracts minimum and maximum values from a list of indexed positions
  30797. * @param positions defines the positions to use
  30798. * @param indices defines the indices to the positions
  30799. * @param indexStart defines the start index
  30800. * @param indexCount defines the end index
  30801. * @param bias defines bias value to add to the result
  30802. * @return minimum and maximum values
  30803. */
  30804. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30805. minimum: Vector3;
  30806. maximum: Vector3;
  30807. };
  30808. /**
  30809. * Extracts minimum and maximum values from a list of positions
  30810. * @param positions defines the positions to use
  30811. * @param start defines the start index in the positions array
  30812. * @param count defines the number of positions to handle
  30813. * @param bias defines bias value to add to the result
  30814. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30815. * @return minimum and maximum values
  30816. */
  30817. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30818. minimum: Vector3;
  30819. maximum: Vector3;
  30820. };
  30821. /**
  30822. * Returns an array if obj is not an array
  30823. * @param obj defines the object to evaluate as an array
  30824. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30825. * @returns either obj directly if obj is an array or a new array containing obj
  30826. */
  30827. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30828. /**
  30829. * Gets the pointer prefix to use
  30830. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30831. */
  30832. static GetPointerPrefix(): string;
  30833. /**
  30834. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30835. * @param func - the function to be called
  30836. * @param requester - the object that will request the next frame. Falls back to window.
  30837. * @returns frame number
  30838. */
  30839. static QueueNewFrame(func: () => void, requester?: any): number;
  30840. /**
  30841. * Ask the browser to promote the current element to fullscreen rendering mode
  30842. * @param element defines the DOM element to promote
  30843. */
  30844. static RequestFullscreen(element: HTMLElement): void;
  30845. /**
  30846. * Asks the browser to exit fullscreen mode
  30847. */
  30848. static ExitFullscreen(): void;
  30849. /**
  30850. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30851. * @param url define the url we are trying
  30852. * @param element define the dom element where to configure the cors policy
  30853. */
  30854. static SetCorsBehavior(url: string | string[], element: {
  30855. crossOrigin: string | null;
  30856. }): void;
  30857. /**
  30858. * Removes unwanted characters from an url
  30859. * @param url defines the url to clean
  30860. * @returns the cleaned url
  30861. */
  30862. static CleanUrl(url: string): string;
  30863. /**
  30864. * Gets or sets a function used to pre-process url before using them to load assets
  30865. */
  30866. static PreprocessUrl: (url: string) => string;
  30867. /**
  30868. * Loads an image as an HTMLImageElement.
  30869. * @param input url string, ArrayBuffer, or Blob to load
  30870. * @param onLoad callback called when the image successfully loads
  30871. * @param onError callback called when the image fails to load
  30872. * @param offlineProvider offline provider for caching
  30873. * @returns the HTMLImageElement of the loaded image
  30874. */
  30875. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30876. /**
  30877. * Loads a file
  30878. * @param url url string, ArrayBuffer, or Blob to load
  30879. * @param onSuccess callback called when the file successfully loads
  30880. * @param onProgress callback called while file is loading (if the server supports this mode)
  30881. * @param offlineProvider defines the offline provider for caching
  30882. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30883. * @param onError callback called when the file fails to load
  30884. * @returns a file request object
  30885. */
  30886. 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;
  30887. /**
  30888. * Load a script (identified by an url). When the url returns, the
  30889. * content of this file is added into a new script element, attached to the DOM (body element)
  30890. * @param scriptUrl defines the url of the script to laod
  30891. * @param onSuccess defines the callback called when the script is loaded
  30892. * @param onError defines the callback to call if an error occurs
  30893. */
  30894. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  30895. /**
  30896. * Loads a file from a blob
  30897. * @param fileToLoad defines the blob to use
  30898. * @param callback defines the callback to call when data is loaded
  30899. * @param progressCallback defines the callback to call during loading process
  30900. * @returns a file request object
  30901. */
  30902. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30903. /**
  30904. * Loads a file
  30905. * @param fileToLoad defines the file to load
  30906. * @param callback defines the callback to call when data is loaded
  30907. * @param progressCallBack defines the callback to call during loading process
  30908. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30909. * @returns a file request object
  30910. */
  30911. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30912. /**
  30913. * Creates a data url from a given string content
  30914. * @param content defines the content to convert
  30915. * @returns the new data url link
  30916. */
  30917. static FileAsURL(content: string): string;
  30918. /**
  30919. * Format the given number to a specific decimal format
  30920. * @param value defines the number to format
  30921. * @param decimals defines the number of decimals to use
  30922. * @returns the formatted string
  30923. */
  30924. static Format(value: number, decimals?: number): string;
  30925. /**
  30926. * Checks if a given vector is inside a specific range
  30927. * @param v defines the vector to test
  30928. * @param min defines the minimum range
  30929. * @param max defines the maximum range
  30930. */
  30931. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30932. /**
  30933. * Tries to copy an object by duplicating every property
  30934. * @param source defines the source object
  30935. * @param destination defines the target object
  30936. * @param doNotCopyList defines a list of properties to avoid
  30937. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30938. */
  30939. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30940. /**
  30941. * Gets a boolean indicating if the given object has no own property
  30942. * @param obj defines the object to test
  30943. * @returns true if object has no own property
  30944. */
  30945. static IsEmpty(obj: any): boolean;
  30946. /**
  30947. * Function used to register events at window level
  30948. * @param events defines the events to register
  30949. */
  30950. static RegisterTopRootEvents(events: {
  30951. name: string;
  30952. handler: Nullable<(e: FocusEvent) => any>;
  30953. }[]): void;
  30954. /**
  30955. * Function used to unregister events from window level
  30956. * @param events defines the events to unregister
  30957. */
  30958. static UnregisterTopRootEvents(events: {
  30959. name: string;
  30960. handler: Nullable<(e: FocusEvent) => any>;
  30961. }[]): void;
  30962. /**
  30963. * Dumps the current bound framebuffer
  30964. * @param width defines the rendering width
  30965. * @param height defines the rendering height
  30966. * @param engine defines the hosting engine
  30967. * @param successCallback defines the callback triggered once the data are available
  30968. * @param mimeType defines the mime type of the result
  30969. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30970. */
  30971. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30972. /**
  30973. * Converts the canvas data to blob.
  30974. * This acts as a polyfill for browsers not supporting the to blob function.
  30975. * @param canvas Defines the canvas to extract the data from
  30976. * @param successCallback Defines the callback triggered once the data are available
  30977. * @param mimeType Defines the mime type of the result
  30978. */
  30979. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30980. /**
  30981. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30982. * @param successCallback defines the callback triggered once the data are available
  30983. * @param mimeType defines the mime type of the result
  30984. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30985. */
  30986. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30987. /**
  30988. * Downloads a blob in the browser
  30989. * @param blob defines the blob to download
  30990. * @param fileName defines the name of the downloaded file
  30991. */
  30992. static Download(blob: Blob, fileName: string): void;
  30993. /**
  30994. * Captures a screenshot of the current rendering
  30995. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30996. * @param engine defines the rendering engine
  30997. * @param camera defines the source camera
  30998. * @param size This parameter can be set to a single number or to an object with the
  30999. * following (optional) properties: precision, width, height. If a single number is passed,
  31000. * it will be used for both width and height. If an object is passed, the screenshot size
  31001. * will be derived from the parameters. The precision property is a multiplier allowing
  31002. * rendering at a higher or lower resolution
  31003. * @param successCallback defines the callback receives a single parameter which contains the
  31004. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31005. * src parameter of an <img> to display it
  31006. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31007. * Check your browser for supported MIME types
  31008. */
  31009. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31010. /**
  31011. * Generates an image screenshot from the specified camera.
  31012. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31013. * @param engine The engine to use for rendering
  31014. * @param camera The camera to use for rendering
  31015. * @param size This parameter can be set to a single number or to an object with the
  31016. * following (optional) properties: precision, width, height. If a single number is passed,
  31017. * it will be used for both width and height. If an object is passed, the screenshot size
  31018. * will be derived from the parameters. The precision property is a multiplier allowing
  31019. * rendering at a higher or lower resolution
  31020. * @param successCallback The callback receives a single parameter which contains the
  31021. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31022. * src parameter of an <img> to display it
  31023. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31024. * Check your browser for supported MIME types
  31025. * @param samples Texture samples (default: 1)
  31026. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31027. * @param fileName A name for for the downloaded file.
  31028. */
  31029. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31030. /**
  31031. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31032. * Be aware Math.random() could cause collisions, but:
  31033. * "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"
  31034. * @returns a pseudo random id
  31035. */
  31036. static RandomId(): string;
  31037. /**
  31038. * Test if the given uri is a base64 string
  31039. * @param uri The uri to test
  31040. * @return True if the uri is a base64 string or false otherwise
  31041. */
  31042. static IsBase64(uri: string): boolean;
  31043. /**
  31044. * Decode the given base64 uri.
  31045. * @param uri The uri to decode
  31046. * @return The decoded base64 data.
  31047. */
  31048. static DecodeBase64(uri: string): ArrayBuffer;
  31049. /**
  31050. * No log
  31051. */
  31052. static readonly NoneLogLevel: number;
  31053. /**
  31054. * Only message logs
  31055. */
  31056. static readonly MessageLogLevel: number;
  31057. /**
  31058. * Only warning logs
  31059. */
  31060. static readonly WarningLogLevel: number;
  31061. /**
  31062. * Only error logs
  31063. */
  31064. static readonly ErrorLogLevel: number;
  31065. /**
  31066. * All logs
  31067. */
  31068. static readonly AllLogLevel: number;
  31069. /**
  31070. * Gets a value indicating the number of loading errors
  31071. * @ignorenaming
  31072. */
  31073. static readonly errorsCount: number;
  31074. /**
  31075. * Callback called when a new log is added
  31076. */
  31077. static OnNewCacheEntry: (entry: string) => void;
  31078. /**
  31079. * Log a message to the console
  31080. * @param message defines the message to log
  31081. */
  31082. static Log(message: string): void;
  31083. /**
  31084. * Write a warning message to the console
  31085. * @param message defines the message to log
  31086. */
  31087. static Warn(message: string): void;
  31088. /**
  31089. * Write an error message to the console
  31090. * @param message defines the message to log
  31091. */
  31092. static Error(message: string): void;
  31093. /**
  31094. * Gets current log cache (list of logs)
  31095. */
  31096. static readonly LogCache: string;
  31097. /**
  31098. * Clears the log cache
  31099. */
  31100. static ClearLogCache(): void;
  31101. /**
  31102. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31103. */
  31104. static LogLevels: number;
  31105. /**
  31106. * Checks if the loaded document was accessed via `file:`-Protocol.
  31107. * @returns boolean
  31108. */
  31109. static IsFileURL(): boolean;
  31110. /**
  31111. * Checks if the window object exists
  31112. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31113. */
  31114. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31115. /**
  31116. * No performance log
  31117. */
  31118. static readonly PerformanceNoneLogLevel: number;
  31119. /**
  31120. * Use user marks to log performance
  31121. */
  31122. static readonly PerformanceUserMarkLogLevel: number;
  31123. /**
  31124. * Log performance to the console
  31125. */
  31126. static readonly PerformanceConsoleLogLevel: number;
  31127. private static _performance;
  31128. /**
  31129. * Sets the current performance log level
  31130. */
  31131. static PerformanceLogLevel: number;
  31132. private static _StartPerformanceCounterDisabled;
  31133. private static _EndPerformanceCounterDisabled;
  31134. private static _StartUserMark;
  31135. private static _EndUserMark;
  31136. private static _StartPerformanceConsole;
  31137. private static _EndPerformanceConsole;
  31138. /**
  31139. * Injects the @see CustomRequestHeaders into the given request
  31140. * @param request the request that should be used for injection
  31141. */
  31142. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  31143. /**
  31144. * Starts a performance counter
  31145. */
  31146. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31147. /**
  31148. * Ends a specific performance coutner
  31149. */
  31150. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31151. /**
  31152. * Gets either window.performance.now() if supported or Date.now() else
  31153. */
  31154. static readonly Now: number;
  31155. /**
  31156. * This method will return the name of the class used to create the instance of the given object.
  31157. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31158. * @param object the object to get the class name from
  31159. * @param isType defines if the object is actually a type
  31160. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31161. */
  31162. static GetClassName(object: any, isType?: boolean): string;
  31163. /**
  31164. * Gets the first element of an array satisfying a given predicate
  31165. * @param array defines the array to browse
  31166. * @param predicate defines the predicate to use
  31167. * @returns null if not found or the element
  31168. */
  31169. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31170. /**
  31171. * This method will return the name of the full name of the class, including its owning module (if any).
  31172. * 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).
  31173. * @param object the object to get the class name from
  31174. * @param isType defines if the object is actually a type
  31175. * @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.
  31176. * @ignorenaming
  31177. */
  31178. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31179. /**
  31180. * Returns a promise that resolves after the given amount of time.
  31181. * @param delay Number of milliseconds to delay
  31182. * @returns Promise that resolves after the given amount of time
  31183. */
  31184. static DelayAsync(delay: number): Promise<void>;
  31185. /**
  31186. * Gets the current gradient from an array of IValueGradient
  31187. * @param ratio defines the current ratio to get
  31188. * @param gradients defines the array of IValueGradient
  31189. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31190. */
  31191. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31192. }
  31193. /**
  31194. * This class is used to track a performance counter which is number based.
  31195. * The user has access to many properties which give statistics of different nature.
  31196. *
  31197. * The implementer can track two kinds of Performance Counter: time and count.
  31198. * 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.
  31199. * 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.
  31200. */
  31201. export class PerfCounter {
  31202. /**
  31203. * Gets or sets a global boolean to turn on and off all the counters
  31204. */
  31205. static Enabled: boolean;
  31206. /**
  31207. * Returns the smallest value ever
  31208. */
  31209. readonly min: number;
  31210. /**
  31211. * Returns the biggest value ever
  31212. */
  31213. readonly max: number;
  31214. /**
  31215. * Returns the average value since the performance counter is running
  31216. */
  31217. readonly average: number;
  31218. /**
  31219. * Returns the average value of the last second the counter was monitored
  31220. */
  31221. readonly lastSecAverage: number;
  31222. /**
  31223. * Returns the current value
  31224. */
  31225. readonly current: number;
  31226. /**
  31227. * Gets the accumulated total
  31228. */
  31229. readonly total: number;
  31230. /**
  31231. * Gets the total value count
  31232. */
  31233. readonly count: number;
  31234. /**
  31235. * Creates a new counter
  31236. */
  31237. constructor();
  31238. /**
  31239. * Call this method to start monitoring a new frame.
  31240. * 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.
  31241. */
  31242. fetchNewFrame(): void;
  31243. /**
  31244. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31245. * @param newCount the count value to add to the monitored count
  31246. * @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.
  31247. */
  31248. addCount(newCount: number, fetchResult: boolean): void;
  31249. /**
  31250. * Start monitoring this performance counter
  31251. */
  31252. beginMonitoring(): void;
  31253. /**
  31254. * Compute the time lapsed since the previous beginMonitoring() call.
  31255. * @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
  31256. */
  31257. endMonitoring(newFrame?: boolean): void;
  31258. private _fetchResult;
  31259. private _startMonitoringTime;
  31260. private _min;
  31261. private _max;
  31262. private _average;
  31263. private _current;
  31264. private _totalValueCount;
  31265. private _totalAccumulated;
  31266. private _lastSecAverage;
  31267. private _lastSecAccumulated;
  31268. private _lastSecTime;
  31269. private _lastSecValueCount;
  31270. }
  31271. /**
  31272. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31273. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31274. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31275. * @param name The name of the class, case should be preserved
  31276. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31277. */
  31278. export function className(name: string, module?: string): (target: Object) => void;
  31279. /**
  31280. * An implementation of a loop for asynchronous functions.
  31281. */
  31282. export class AsyncLoop {
  31283. /**
  31284. * Defines the number of iterations for the loop
  31285. */
  31286. iterations: number;
  31287. /**
  31288. * Defines the current index of the loop.
  31289. */
  31290. index: number;
  31291. private _done;
  31292. private _fn;
  31293. private _successCallback;
  31294. /**
  31295. * Constructor.
  31296. * @param iterations the number of iterations.
  31297. * @param func the function to run each iteration
  31298. * @param successCallback the callback that will be called upon succesful execution
  31299. * @param offset starting offset.
  31300. */
  31301. constructor(
  31302. /**
  31303. * Defines the number of iterations for the loop
  31304. */
  31305. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31306. /**
  31307. * Execute the next iteration. Must be called after the last iteration was finished.
  31308. */
  31309. executeNext(): void;
  31310. /**
  31311. * Break the loop and run the success callback.
  31312. */
  31313. breakLoop(): void;
  31314. /**
  31315. * Create and run an async loop.
  31316. * @param iterations the number of iterations.
  31317. * @param fn the function to run each iteration
  31318. * @param successCallback the callback that will be called upon succesful execution
  31319. * @param offset starting offset.
  31320. * @returns the created async loop object
  31321. */
  31322. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31323. /**
  31324. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31325. * @param iterations total number of iterations
  31326. * @param syncedIterations number of synchronous iterations in each async iteration.
  31327. * @param fn the function to call each iteration.
  31328. * @param callback a success call back that will be called when iterating stops.
  31329. * @param breakFunction a break condition (optional)
  31330. * @param timeout timeout settings for the setTimeout function. default - 0.
  31331. * @returns the created async loop object
  31332. */
  31333. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31334. }
  31335. }
  31336. declare module "babylonjs/Collisions/collisionCoordinator" {
  31337. import { Nullable } from "babylonjs/types";
  31338. import { Scene } from "babylonjs/scene";
  31339. import { Vector3 } from "babylonjs/Maths/math";
  31340. import { Collider } from "babylonjs/Collisions/collider";
  31341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31342. /** @hidden */
  31343. export interface ICollisionCoordinator {
  31344. createCollider(): Collider;
  31345. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31346. init(scene: Scene): void;
  31347. }
  31348. /** @hidden */
  31349. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31350. private _scene;
  31351. private _scaledPosition;
  31352. private _scaledVelocity;
  31353. private _finalPosition;
  31354. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31355. createCollider(): Collider;
  31356. init(scene: Scene): void;
  31357. private _collideWithWorld;
  31358. }
  31359. }
  31360. declare module "babylonjs/Animations/animationGroup" {
  31361. import { Animatable } from "babylonjs/Animations/animatable";
  31362. import { Animation } from "babylonjs/Animations/animation";
  31363. import { Scene, IDisposable } from "babylonjs/scene";
  31364. import { Observable } from "babylonjs/Misc/observable";
  31365. import { Nullable } from "babylonjs/types";
  31366. /**
  31367. * This class defines the direct association between an animation and a target
  31368. */
  31369. export class TargetedAnimation {
  31370. /**
  31371. * Animation to perform
  31372. */
  31373. animation: Animation;
  31374. /**
  31375. * Target to animate
  31376. */
  31377. target: any;
  31378. }
  31379. /**
  31380. * Use this class to create coordinated animations on multiple targets
  31381. */
  31382. export class AnimationGroup implements IDisposable {
  31383. /** The name of the animation group */
  31384. name: string;
  31385. private _scene;
  31386. private _targetedAnimations;
  31387. private _animatables;
  31388. private _from;
  31389. private _to;
  31390. private _isStarted;
  31391. private _isPaused;
  31392. private _speedRatio;
  31393. /**
  31394. * Gets or sets the unique id of the node
  31395. */
  31396. uniqueId: number;
  31397. /**
  31398. * This observable will notify when one animation have ended
  31399. */
  31400. onAnimationEndObservable: Observable<TargetedAnimation>;
  31401. /**
  31402. * Observer raised when one animation loops
  31403. */
  31404. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31405. /**
  31406. * This observable will notify when all animations have ended.
  31407. */
  31408. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31409. /**
  31410. * This observable will notify when all animations have paused.
  31411. */
  31412. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31413. /**
  31414. * This observable will notify when all animations are playing.
  31415. */
  31416. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31417. /**
  31418. * Gets the first frame
  31419. */
  31420. readonly from: number;
  31421. /**
  31422. * Gets the last frame
  31423. */
  31424. readonly to: number;
  31425. /**
  31426. * Define if the animations are started
  31427. */
  31428. readonly isStarted: boolean;
  31429. /**
  31430. * Gets a value indicating that the current group is playing
  31431. */
  31432. readonly isPlaying: boolean;
  31433. /**
  31434. * Gets or sets the speed ratio to use for all animations
  31435. */
  31436. /**
  31437. * Gets or sets the speed ratio to use for all animations
  31438. */
  31439. speedRatio: number;
  31440. /**
  31441. * Gets the targeted animations for this animation group
  31442. */
  31443. readonly targetedAnimations: Array<TargetedAnimation>;
  31444. /**
  31445. * returning the list of animatables controlled by this animation group.
  31446. */
  31447. readonly animatables: Array<Animatable>;
  31448. /**
  31449. * Instantiates a new Animation Group.
  31450. * This helps managing several animations at once.
  31451. * @see http://doc.babylonjs.com/how_to/group
  31452. * @param name Defines the name of the group
  31453. * @param scene Defines the scene the group belongs to
  31454. */
  31455. constructor(
  31456. /** The name of the animation group */
  31457. name: string, scene?: Nullable<Scene>);
  31458. /**
  31459. * Add an animation (with its target) in the group
  31460. * @param animation defines the animation we want to add
  31461. * @param target defines the target of the animation
  31462. * @returns the TargetedAnimation object
  31463. */
  31464. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31465. /**
  31466. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31467. * It can add constant keys at begin or end
  31468. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31469. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31470. * @returns the animation group
  31471. */
  31472. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31473. /**
  31474. * Start all animations on given targets
  31475. * @param loop defines if animations must loop
  31476. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31477. * @param from defines the from key (optional)
  31478. * @param to defines the to key (optional)
  31479. * @returns the current animation group
  31480. */
  31481. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31482. /**
  31483. * Pause all animations
  31484. * @returns the animation group
  31485. */
  31486. pause(): AnimationGroup;
  31487. /**
  31488. * Play all animations to initial state
  31489. * This function will start() the animations if they were not started or will restart() them if they were paused
  31490. * @param loop defines if animations must loop
  31491. * @returns the animation group
  31492. */
  31493. play(loop?: boolean): AnimationGroup;
  31494. /**
  31495. * Reset all animations to initial state
  31496. * @returns the animation group
  31497. */
  31498. reset(): AnimationGroup;
  31499. /**
  31500. * Restart animations from key 0
  31501. * @returns the animation group
  31502. */
  31503. restart(): AnimationGroup;
  31504. /**
  31505. * Stop all animations
  31506. * @returns the animation group
  31507. */
  31508. stop(): AnimationGroup;
  31509. /**
  31510. * Set animation weight for all animatables
  31511. * @param weight defines the weight to use
  31512. * @return the animationGroup
  31513. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31514. */
  31515. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31516. /**
  31517. * Synchronize and normalize all animatables with a source animatable
  31518. * @param root defines the root animatable to synchronize with
  31519. * @return the animationGroup
  31520. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31521. */
  31522. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31523. /**
  31524. * Goes to a specific frame in this animation group
  31525. * @param frame the frame number to go to
  31526. * @return the animationGroup
  31527. */
  31528. goToFrame(frame: number): AnimationGroup;
  31529. /**
  31530. * Dispose all associated resources
  31531. */
  31532. dispose(): void;
  31533. private _checkAnimationGroupEnded;
  31534. /**
  31535. * Returns a new AnimationGroup object parsed from the source provided.
  31536. * @param parsedAnimationGroup defines the source
  31537. * @param scene defines the scene that will receive the animationGroup
  31538. * @returns a new AnimationGroup
  31539. */
  31540. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31541. /**
  31542. * Returns the string "AnimationGroup"
  31543. * @returns "AnimationGroup"
  31544. */
  31545. getClassName(): string;
  31546. /**
  31547. * Creates a detailled string about the object
  31548. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31549. * @returns a string representing the object
  31550. */
  31551. toString(fullDetails?: boolean): string;
  31552. }
  31553. }
  31554. declare module "babylonjs/scene" {
  31555. import { Nullable } from "babylonjs/types";
  31556. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31557. import { Observable } from "babylonjs/Misc/observable";
  31558. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31559. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31560. import { Geometry } from "babylonjs/Meshes/geometry";
  31561. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31562. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31564. import { Mesh } from "babylonjs/Meshes/mesh";
  31565. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31566. import { Bone } from "babylonjs/Bones/bone";
  31567. import { Skeleton } from "babylonjs/Bones/skeleton";
  31568. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31569. import { Camera } from "babylonjs/Cameras/camera";
  31570. import { AbstractScene } from "babylonjs/abstractScene";
  31571. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31572. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31573. import { Material } from "babylonjs/Materials/material";
  31574. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31575. import { Effect } from "babylonjs/Materials/effect";
  31576. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31577. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31578. import { Light } from "babylonjs/Lights/light";
  31579. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31580. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31581. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31582. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31583. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31584. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31585. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31586. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31587. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31588. import { Engine } from "babylonjs/Engines/engine";
  31589. import { Node } from "babylonjs/node";
  31590. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31591. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31592. import { Ray } from "babylonjs/Culling/ray";
  31593. import { Animation } from "babylonjs/Animations/animation";
  31594. import { Animatable } from "babylonjs/Animations/animatable";
  31595. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31596. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31597. import { Collider } from "babylonjs/Collisions/collider";
  31598. /**
  31599. * Define an interface for all classes that will hold resources
  31600. */
  31601. export interface IDisposable {
  31602. /**
  31603. * Releases all held resources
  31604. */
  31605. dispose(): void;
  31606. }
  31607. /** Interface defining initialization parameters for Scene class */
  31608. export interface SceneOptions {
  31609. /**
  31610. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31611. * It will improve performance when the number of geometries becomes important.
  31612. */
  31613. useGeometryUniqueIdsMap?: boolean;
  31614. /**
  31615. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31616. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31617. */
  31618. useMaterialMeshMap?: boolean;
  31619. /**
  31620. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31621. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31622. */
  31623. useClonedMeshhMap?: boolean;
  31624. }
  31625. /**
  31626. * Represents a scene to be rendered by the engine.
  31627. * @see http://doc.babylonjs.com/features/scene
  31628. */
  31629. export class Scene extends AbstractScene implements IAnimatable {
  31630. private static _uniqueIdCounter;
  31631. /** The fog is deactivated */
  31632. static readonly FOGMODE_NONE: number;
  31633. /** The fog density is following an exponential function */
  31634. static readonly FOGMODE_EXP: number;
  31635. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31636. static readonly FOGMODE_EXP2: number;
  31637. /** The fog density is following a linear function. */
  31638. static readonly FOGMODE_LINEAR: number;
  31639. /**
  31640. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31641. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31642. */
  31643. static MinDeltaTime: number;
  31644. /**
  31645. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31646. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31647. */
  31648. static MaxDeltaTime: number;
  31649. /**
  31650. * Factory used to create the default material.
  31651. * @param name The name of the material to create
  31652. * @param scene The scene to create the material for
  31653. * @returns The default material
  31654. */
  31655. static DefaultMaterialFactory(scene: Scene): Material;
  31656. /**
  31657. * Factory used to create the a collision coordinator.
  31658. * @returns The collision coordinator
  31659. */
  31660. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31661. /** @hidden */
  31662. readonly _isScene: boolean;
  31663. /**
  31664. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31665. */
  31666. autoClear: boolean;
  31667. /**
  31668. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31669. */
  31670. autoClearDepthAndStencil: boolean;
  31671. /**
  31672. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31673. */
  31674. clearColor: Color4;
  31675. /**
  31676. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31677. */
  31678. ambientColor: Color3;
  31679. /** @hidden */
  31680. _environmentBRDFTexture: BaseTexture;
  31681. /** @hidden */
  31682. protected _environmentTexture: Nullable<BaseTexture>;
  31683. /**
  31684. * Texture used in all pbr material as the reflection texture.
  31685. * As in the majority of the scene they are the same (exception for multi room and so on),
  31686. * this is easier to reference from here than from all the materials.
  31687. */
  31688. /**
  31689. * Texture used in all pbr material as the reflection texture.
  31690. * As in the majority of the scene they are the same (exception for multi room and so on),
  31691. * this is easier to set here than in all the materials.
  31692. */
  31693. environmentTexture: Nullable<BaseTexture>;
  31694. /** @hidden */
  31695. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31696. /**
  31697. * Default image processing configuration used either in the rendering
  31698. * Forward main pass or through the imageProcessingPostProcess if present.
  31699. * As in the majority of the scene they are the same (exception for multi camera),
  31700. * this is easier to reference from here than from all the materials and post process.
  31701. *
  31702. * No setter as we it is a shared configuration, you can set the values instead.
  31703. */
  31704. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31705. private _forceWireframe;
  31706. /**
  31707. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31708. */
  31709. forceWireframe: boolean;
  31710. private _forcePointsCloud;
  31711. /**
  31712. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31713. */
  31714. forcePointsCloud: boolean;
  31715. /**
  31716. * Gets or sets the active clipplane 1
  31717. */
  31718. clipPlane: Nullable<Plane>;
  31719. /**
  31720. * Gets or sets the active clipplane 2
  31721. */
  31722. clipPlane2: Nullable<Plane>;
  31723. /**
  31724. * Gets or sets the active clipplane 3
  31725. */
  31726. clipPlane3: Nullable<Plane>;
  31727. /**
  31728. * Gets or sets the active clipplane 4
  31729. */
  31730. clipPlane4: Nullable<Plane>;
  31731. /**
  31732. * Gets or sets a boolean indicating if animations are enabled
  31733. */
  31734. animationsEnabled: boolean;
  31735. private _animationPropertiesOverride;
  31736. /**
  31737. * Gets or sets the animation properties override
  31738. */
  31739. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31740. /**
  31741. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31742. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31743. */
  31744. useConstantAnimationDeltaTime: boolean;
  31745. /**
  31746. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31747. * Please note that it requires to run a ray cast through the scene on every frame
  31748. */
  31749. constantlyUpdateMeshUnderPointer: boolean;
  31750. /**
  31751. * Defines the HTML cursor to use when hovering over interactive elements
  31752. */
  31753. hoverCursor: string;
  31754. /**
  31755. * Defines the HTML default cursor to use (empty by default)
  31756. */
  31757. defaultCursor: string;
  31758. /**
  31759. * This is used to call preventDefault() on pointer down
  31760. * in order to block unwanted artifacts like system double clicks
  31761. */
  31762. preventDefaultOnPointerDown: boolean;
  31763. /**
  31764. * This is used to call preventDefault() on pointer up
  31765. * in order to block unwanted artifacts like system double clicks
  31766. */
  31767. preventDefaultOnPointerUp: boolean;
  31768. /**
  31769. * Gets or sets user defined metadata
  31770. */
  31771. metadata: any;
  31772. /**
  31773. * For internal use only. Please do not use.
  31774. */
  31775. reservedDataStore: any;
  31776. /**
  31777. * Gets the name of the plugin used to load this scene (null by default)
  31778. */
  31779. loadingPluginName: string;
  31780. /**
  31781. * Use this array to add regular expressions used to disable offline support for specific urls
  31782. */
  31783. disableOfflineSupportExceptionRules: RegExp[];
  31784. /**
  31785. * An event triggered when the scene is disposed.
  31786. */
  31787. onDisposeObservable: Observable<Scene>;
  31788. private _onDisposeObserver;
  31789. /** Sets a function to be executed when this scene is disposed. */
  31790. onDispose: () => void;
  31791. /**
  31792. * An event triggered before rendering the scene (right after animations and physics)
  31793. */
  31794. onBeforeRenderObservable: Observable<Scene>;
  31795. private _onBeforeRenderObserver;
  31796. /** Sets a function to be executed before rendering this scene */
  31797. beforeRender: Nullable<() => void>;
  31798. /**
  31799. * An event triggered after rendering the scene
  31800. */
  31801. onAfterRenderObservable: Observable<Scene>;
  31802. private _onAfterRenderObserver;
  31803. /** Sets a function to be executed after rendering this scene */
  31804. afterRender: Nullable<() => void>;
  31805. /**
  31806. * An event triggered before animating the scene
  31807. */
  31808. onBeforeAnimationsObservable: Observable<Scene>;
  31809. /**
  31810. * An event triggered after animations processing
  31811. */
  31812. onAfterAnimationsObservable: Observable<Scene>;
  31813. /**
  31814. * An event triggered before draw calls are ready to be sent
  31815. */
  31816. onBeforeDrawPhaseObservable: Observable<Scene>;
  31817. /**
  31818. * An event triggered after draw calls have been sent
  31819. */
  31820. onAfterDrawPhaseObservable: Observable<Scene>;
  31821. /**
  31822. * An event triggered when the scene is ready
  31823. */
  31824. onReadyObservable: Observable<Scene>;
  31825. /**
  31826. * An event triggered before rendering a camera
  31827. */
  31828. onBeforeCameraRenderObservable: Observable<Camera>;
  31829. private _onBeforeCameraRenderObserver;
  31830. /** Sets a function to be executed before rendering a camera*/
  31831. beforeCameraRender: () => void;
  31832. /**
  31833. * An event triggered after rendering a camera
  31834. */
  31835. onAfterCameraRenderObservable: Observable<Camera>;
  31836. private _onAfterCameraRenderObserver;
  31837. /** Sets a function to be executed after rendering a camera*/
  31838. afterCameraRender: () => void;
  31839. /**
  31840. * An event triggered when active meshes evaluation is about to start
  31841. */
  31842. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31843. /**
  31844. * An event triggered when active meshes evaluation is done
  31845. */
  31846. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31847. /**
  31848. * An event triggered when particles rendering is about to start
  31849. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31850. */
  31851. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31852. /**
  31853. * An event triggered when particles rendering is done
  31854. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31855. */
  31856. onAfterParticlesRenderingObservable: Observable<Scene>;
  31857. /**
  31858. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31859. */
  31860. onDataLoadedObservable: Observable<Scene>;
  31861. /**
  31862. * An event triggered when a camera is created
  31863. */
  31864. onNewCameraAddedObservable: Observable<Camera>;
  31865. /**
  31866. * An event triggered when a camera is removed
  31867. */
  31868. onCameraRemovedObservable: Observable<Camera>;
  31869. /**
  31870. * An event triggered when a light is created
  31871. */
  31872. onNewLightAddedObservable: Observable<Light>;
  31873. /**
  31874. * An event triggered when a light is removed
  31875. */
  31876. onLightRemovedObservable: Observable<Light>;
  31877. /**
  31878. * An event triggered when a geometry is created
  31879. */
  31880. onNewGeometryAddedObservable: Observable<Geometry>;
  31881. /**
  31882. * An event triggered when a geometry is removed
  31883. */
  31884. onGeometryRemovedObservable: Observable<Geometry>;
  31885. /**
  31886. * An event triggered when a transform node is created
  31887. */
  31888. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31889. /**
  31890. * An event triggered when a transform node is removed
  31891. */
  31892. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31893. /**
  31894. * An event triggered when a mesh is created
  31895. */
  31896. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31897. /**
  31898. * An event triggered when a mesh is removed
  31899. */
  31900. onMeshRemovedObservable: Observable<AbstractMesh>;
  31901. /**
  31902. * An event triggered when a material is created
  31903. */
  31904. onNewMaterialAddedObservable: Observable<Material>;
  31905. /**
  31906. * An event triggered when a material is removed
  31907. */
  31908. onMaterialRemovedObservable: Observable<Material>;
  31909. /**
  31910. * An event triggered when a texture is created
  31911. */
  31912. onNewTextureAddedObservable: Observable<BaseTexture>;
  31913. /**
  31914. * An event triggered when a texture is removed
  31915. */
  31916. onTextureRemovedObservable: Observable<BaseTexture>;
  31917. /**
  31918. * An event triggered when render targets are about to be rendered
  31919. * Can happen multiple times per frame.
  31920. */
  31921. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31922. /**
  31923. * An event triggered when render targets were rendered.
  31924. * Can happen multiple times per frame.
  31925. */
  31926. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31927. /**
  31928. * An event triggered before calculating deterministic simulation step
  31929. */
  31930. onBeforeStepObservable: Observable<Scene>;
  31931. /**
  31932. * An event triggered after calculating deterministic simulation step
  31933. */
  31934. onAfterStepObservable: Observable<Scene>;
  31935. /**
  31936. * An event triggered when the activeCamera property is updated
  31937. */
  31938. onActiveCameraChanged: Observable<Scene>;
  31939. /**
  31940. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31941. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31942. * 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)
  31943. */
  31944. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31945. /**
  31946. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31947. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31948. * 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)
  31949. */
  31950. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31951. /**
  31952. * This Observable will when a mesh has been imported into the scene.
  31953. */
  31954. onMeshImportedObservable: Observable<AbstractMesh>;
  31955. /** @hidden */
  31956. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31957. /**
  31958. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31959. */
  31960. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31961. /**
  31962. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31963. */
  31964. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31965. /**
  31966. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31967. */
  31968. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31969. private _onPointerMove;
  31970. private _onPointerDown;
  31971. private _onPointerUp;
  31972. /** Callback called when a pointer move is detected */
  31973. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31974. /** Callback called when a pointer down is detected */
  31975. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31976. /** Callback called when a pointer up is detected */
  31977. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31978. /** Callback called when a pointer pick is detected */
  31979. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31980. /**
  31981. * 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).
  31982. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  31983. */
  31984. onPrePointerObservable: Observable<PointerInfoPre>;
  31985. /**
  31986. * Observable event triggered each time an input event is received from the rendering canvas
  31987. */
  31988. onPointerObservable: Observable<PointerInfo>;
  31989. /**
  31990. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  31991. */
  31992. readonly unTranslatedPointer: Vector2;
  31993. /** The distance in pixel that you have to move to prevent some events */
  31994. static DragMovementThreshold: number;
  31995. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31996. static LongPressDelay: number;
  31997. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31998. static DoubleClickDelay: number;
  31999. /** If you need to check double click without raising a single click at first click, enable this flag */
  32000. static ExclusiveDoubleClickMode: boolean;
  32001. private _initClickEvent;
  32002. private _initActionManager;
  32003. private _delayedSimpleClick;
  32004. private _delayedSimpleClickTimeout;
  32005. private _previousDelayedSimpleClickTimeout;
  32006. private _meshPickProceed;
  32007. private _previousButtonPressed;
  32008. private _currentPickResult;
  32009. private _previousPickResult;
  32010. private _totalPointersPressed;
  32011. private _doubleClickOccured;
  32012. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32013. cameraToUseForPointers: Nullable<Camera>;
  32014. private _pointerX;
  32015. private _pointerY;
  32016. private _unTranslatedPointerX;
  32017. private _unTranslatedPointerY;
  32018. private _startingPointerPosition;
  32019. private _previousStartingPointerPosition;
  32020. private _startingPointerTime;
  32021. private _previousStartingPointerTime;
  32022. private _pointerCaptures;
  32023. private _timeAccumulator;
  32024. private _currentStepId;
  32025. private _currentInternalStep;
  32026. /** @hidden */
  32027. _mirroredCameraPosition: Nullable<Vector3>;
  32028. /**
  32029. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32030. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32031. */
  32032. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32033. /**
  32034. * Observable event triggered each time an keyboard event is received from the hosting window
  32035. */
  32036. onKeyboardObservable: Observable<KeyboardInfo>;
  32037. private _onKeyDown;
  32038. private _onKeyUp;
  32039. private _onCanvasFocusObserver;
  32040. private _onCanvasBlurObserver;
  32041. private _useRightHandedSystem;
  32042. /**
  32043. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32044. */
  32045. useRightHandedSystem: boolean;
  32046. /**
  32047. * Sets the step Id used by deterministic lock step
  32048. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32049. * @param newStepId defines the step Id
  32050. */
  32051. setStepId(newStepId: number): void;
  32052. /**
  32053. * Gets the step Id used by deterministic lock step
  32054. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32055. * @returns the step Id
  32056. */
  32057. getStepId(): number;
  32058. /**
  32059. * Gets the internal step used by deterministic lock step
  32060. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32061. * @returns the internal step
  32062. */
  32063. getInternalStep(): number;
  32064. private _fogEnabled;
  32065. /**
  32066. * Gets or sets a boolean indicating if fog is enabled on this scene
  32067. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32068. * (Default is true)
  32069. */
  32070. fogEnabled: boolean;
  32071. private _fogMode;
  32072. /**
  32073. * Gets or sets the fog mode to use
  32074. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32075. * | mode | value |
  32076. * | --- | --- |
  32077. * | FOGMODE_NONE | 0 |
  32078. * | FOGMODE_EXP | 1 |
  32079. * | FOGMODE_EXP2 | 2 |
  32080. * | FOGMODE_LINEAR | 3 |
  32081. */
  32082. fogMode: number;
  32083. /**
  32084. * Gets or sets the fog color to use
  32085. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32086. * (Default is Color3(0.2, 0.2, 0.3))
  32087. */
  32088. fogColor: Color3;
  32089. /**
  32090. * Gets or sets the fog density to use
  32091. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32092. * (Default is 0.1)
  32093. */
  32094. fogDensity: number;
  32095. /**
  32096. * Gets or sets the fog start distance to use
  32097. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32098. * (Default is 0)
  32099. */
  32100. fogStart: number;
  32101. /**
  32102. * Gets or sets the fog end distance to use
  32103. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32104. * (Default is 1000)
  32105. */
  32106. fogEnd: number;
  32107. private _shadowsEnabled;
  32108. /**
  32109. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32110. */
  32111. shadowsEnabled: boolean;
  32112. private _lightsEnabled;
  32113. /**
  32114. * Gets or sets a boolean indicating if lights are enabled on this scene
  32115. */
  32116. lightsEnabled: boolean;
  32117. /** All of the active cameras added to this scene. */
  32118. activeCameras: Camera[];
  32119. private _activeCamera;
  32120. /** Gets or sets the current active camera */
  32121. activeCamera: Nullable<Camera>;
  32122. private _defaultMaterial;
  32123. /** The default material used on meshes when no material is affected */
  32124. /** The default material used on meshes when no material is affected */
  32125. defaultMaterial: Material;
  32126. private _texturesEnabled;
  32127. /**
  32128. * Gets or sets a boolean indicating if textures are enabled on this scene
  32129. */
  32130. texturesEnabled: boolean;
  32131. /**
  32132. * Gets or sets a boolean indicating if particles are enabled on this scene
  32133. */
  32134. particlesEnabled: boolean;
  32135. /**
  32136. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32137. */
  32138. spritesEnabled: boolean;
  32139. private _skeletonsEnabled;
  32140. /**
  32141. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32142. */
  32143. skeletonsEnabled: boolean;
  32144. /**
  32145. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32146. */
  32147. lensFlaresEnabled: boolean;
  32148. /**
  32149. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32150. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32151. */
  32152. collisionsEnabled: boolean;
  32153. private _collisionCoordinator;
  32154. /** @hidden */
  32155. readonly collisionCoordinator: ICollisionCoordinator;
  32156. /**
  32157. * Defines the gravity applied to this scene (used only for collisions)
  32158. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32159. */
  32160. gravity: Vector3;
  32161. /**
  32162. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32163. */
  32164. postProcessesEnabled: boolean;
  32165. /**
  32166. * The list of postprocesses added to the scene
  32167. */
  32168. postProcesses: PostProcess[];
  32169. /**
  32170. * Gets the current postprocess manager
  32171. */
  32172. postProcessManager: PostProcessManager;
  32173. /**
  32174. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32175. */
  32176. renderTargetsEnabled: boolean;
  32177. /**
  32178. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32179. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32180. */
  32181. dumpNextRenderTargets: boolean;
  32182. /**
  32183. * The list of user defined render targets added to the scene
  32184. */
  32185. customRenderTargets: RenderTargetTexture[];
  32186. /**
  32187. * Defines if texture loading must be delayed
  32188. * If true, textures will only be loaded when they need to be rendered
  32189. */
  32190. useDelayedTextureLoading: boolean;
  32191. /**
  32192. * Gets the list of meshes imported to the scene through SceneLoader
  32193. */
  32194. importedMeshesFiles: String[];
  32195. /**
  32196. * Gets or sets a boolean indicating if probes are enabled on this scene
  32197. */
  32198. probesEnabled: boolean;
  32199. /**
  32200. * Gets or sets the current offline provider to use to store scene data
  32201. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32202. */
  32203. offlineProvider: IOfflineProvider;
  32204. /**
  32205. * Gets or sets the action manager associated with the scene
  32206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32207. */
  32208. actionManager: AbstractActionManager;
  32209. private _meshesForIntersections;
  32210. /**
  32211. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32212. */
  32213. proceduralTexturesEnabled: boolean;
  32214. private _engine;
  32215. private _totalVertices;
  32216. /** @hidden */
  32217. _activeIndices: PerfCounter;
  32218. /** @hidden */
  32219. _activeParticles: PerfCounter;
  32220. /** @hidden */
  32221. _activeBones: PerfCounter;
  32222. private _animationRatio;
  32223. /** @hidden */
  32224. _animationTimeLast: number;
  32225. /** @hidden */
  32226. _animationTime: number;
  32227. /**
  32228. * Gets or sets a general scale for animation speed
  32229. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32230. */
  32231. animationTimeScale: number;
  32232. /** @hidden */
  32233. _cachedMaterial: Nullable<Material>;
  32234. /** @hidden */
  32235. _cachedEffect: Nullable<Effect>;
  32236. /** @hidden */
  32237. _cachedVisibility: Nullable<number>;
  32238. private _renderId;
  32239. private _frameId;
  32240. private _executeWhenReadyTimeoutId;
  32241. private _intermediateRendering;
  32242. private _viewUpdateFlag;
  32243. private _projectionUpdateFlag;
  32244. private _alternateViewUpdateFlag;
  32245. private _alternateProjectionUpdateFlag;
  32246. /** @hidden */
  32247. _toBeDisposed: Nullable<IDisposable>[];
  32248. private _activeRequests;
  32249. /** @hidden */
  32250. _pendingData: any[];
  32251. private _isDisposed;
  32252. /**
  32253. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32254. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32255. */
  32256. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32257. private _activeMeshes;
  32258. private _processedMaterials;
  32259. private _renderTargets;
  32260. /** @hidden */
  32261. _activeParticleSystems: SmartArray<IParticleSystem>;
  32262. private _activeSkeletons;
  32263. private _softwareSkinnedMeshes;
  32264. private _renderingManager;
  32265. /** @hidden */
  32266. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32267. private _transformMatrix;
  32268. private _sceneUbo;
  32269. private _alternateSceneUbo;
  32270. private _viewMatrix;
  32271. private _projectionMatrix;
  32272. private _alternateViewMatrix;
  32273. private _alternateProjectionMatrix;
  32274. private _alternateTransformMatrix;
  32275. private _useAlternateCameraConfiguration;
  32276. private _alternateRendering;
  32277. private _wheelEventName;
  32278. /** @hidden */
  32279. _forcedViewPosition: Nullable<Vector3>;
  32280. /** @hidden */
  32281. readonly _isAlternateRenderingEnabled: boolean;
  32282. private _frustumPlanes;
  32283. /**
  32284. * Gets the list of frustum planes (built from the active camera)
  32285. */
  32286. readonly frustumPlanes: Plane[];
  32287. /**
  32288. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32289. * This is useful if there are more lights that the maximum simulteanous authorized
  32290. */
  32291. requireLightSorting: boolean;
  32292. /** @hidden */
  32293. readonly useMaterialMeshMap: boolean;
  32294. /** @hidden */
  32295. readonly useClonedMeshhMap: boolean;
  32296. private _pointerOverMesh;
  32297. private _pickedDownMesh;
  32298. private _pickedUpMesh;
  32299. private _externalData;
  32300. private _uid;
  32301. /**
  32302. * @hidden
  32303. * Backing store of defined scene components.
  32304. */
  32305. _components: ISceneComponent[];
  32306. /**
  32307. * @hidden
  32308. * Backing store of defined scene components.
  32309. */
  32310. _serializableComponents: ISceneSerializableComponent[];
  32311. /**
  32312. * List of components to register on the next registration step.
  32313. */
  32314. private _transientComponents;
  32315. /**
  32316. * Registers the transient components if needed.
  32317. */
  32318. private _registerTransientComponents;
  32319. /**
  32320. * @hidden
  32321. * Add a component to the scene.
  32322. * Note that the ccomponent could be registered on th next frame if this is called after
  32323. * the register component stage.
  32324. * @param component Defines the component to add to the scene
  32325. */
  32326. _addComponent(component: ISceneComponent): void;
  32327. /**
  32328. * @hidden
  32329. * Gets a component from the scene.
  32330. * @param name defines the name of the component to retrieve
  32331. * @returns the component or null if not present
  32332. */
  32333. _getComponent(name: string): Nullable<ISceneComponent>;
  32334. /**
  32335. * @hidden
  32336. * Defines the actions happening before camera updates.
  32337. */
  32338. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32339. /**
  32340. * @hidden
  32341. * Defines the actions happening before clear the canvas.
  32342. */
  32343. _beforeClearStage: Stage<SimpleStageAction>;
  32344. /**
  32345. * @hidden
  32346. * Defines the actions when collecting render targets for the frame.
  32347. */
  32348. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32349. /**
  32350. * @hidden
  32351. * Defines the actions happening for one camera in the frame.
  32352. */
  32353. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32354. /**
  32355. * @hidden
  32356. * Defines the actions happening during the per mesh ready checks.
  32357. */
  32358. _isReadyForMeshStage: Stage<MeshStageAction>;
  32359. /**
  32360. * @hidden
  32361. * Defines the actions happening before evaluate active mesh checks.
  32362. */
  32363. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32364. /**
  32365. * @hidden
  32366. * Defines the actions happening during the evaluate sub mesh checks.
  32367. */
  32368. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32369. /**
  32370. * @hidden
  32371. * Defines the actions happening during the active mesh stage.
  32372. */
  32373. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32374. /**
  32375. * @hidden
  32376. * Defines the actions happening during the per camera render target step.
  32377. */
  32378. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32379. /**
  32380. * @hidden
  32381. * Defines the actions happening just before the active camera is drawing.
  32382. */
  32383. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32384. /**
  32385. * @hidden
  32386. * Defines the actions happening just before a render target is drawing.
  32387. */
  32388. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32389. /**
  32390. * @hidden
  32391. * Defines the actions happening just before a rendering group is drawing.
  32392. */
  32393. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32394. /**
  32395. * @hidden
  32396. * Defines the actions happening just before a mesh is drawing.
  32397. */
  32398. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32399. /**
  32400. * @hidden
  32401. * Defines the actions happening just after a mesh has been drawn.
  32402. */
  32403. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32404. /**
  32405. * @hidden
  32406. * Defines the actions happening just after a rendering group has been drawn.
  32407. */
  32408. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32409. /**
  32410. * @hidden
  32411. * Defines the actions happening just after the active camera has been drawn.
  32412. */
  32413. _afterCameraDrawStage: Stage<CameraStageAction>;
  32414. /**
  32415. * @hidden
  32416. * Defines the actions happening just after a render target has been drawn.
  32417. */
  32418. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32419. /**
  32420. * @hidden
  32421. * Defines the actions happening just after rendering all cameras and computing intersections.
  32422. */
  32423. _afterRenderStage: Stage<SimpleStageAction>;
  32424. /**
  32425. * @hidden
  32426. * Defines the actions happening when a pointer move event happens.
  32427. */
  32428. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32429. /**
  32430. * @hidden
  32431. * Defines the actions happening when a pointer down event happens.
  32432. */
  32433. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32434. /**
  32435. * @hidden
  32436. * Defines the actions happening when a pointer up event happens.
  32437. */
  32438. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32439. /**
  32440. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32441. */
  32442. private geometriesByUniqueId;
  32443. /**
  32444. * Creates a new Scene
  32445. * @param engine defines the engine to use to render this scene
  32446. * @param options defines the scene options
  32447. */
  32448. constructor(engine: Engine, options?: SceneOptions);
  32449. private _defaultMeshCandidates;
  32450. /**
  32451. * @hidden
  32452. */
  32453. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32454. private _defaultSubMeshCandidates;
  32455. /**
  32456. * @hidden
  32457. */
  32458. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32459. /**
  32460. * Sets the default candidate providers for the scene.
  32461. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32462. * and getCollidingSubMeshCandidates to their default function
  32463. */
  32464. setDefaultCandidateProviders(): void;
  32465. /**
  32466. * Gets the mesh that is currently under the pointer
  32467. */
  32468. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32469. /**
  32470. * Gets or sets the current on-screen X position of the pointer
  32471. */
  32472. pointerX: number;
  32473. /**
  32474. * Gets or sets the current on-screen Y position of the pointer
  32475. */
  32476. pointerY: number;
  32477. /**
  32478. * Gets the cached material (ie. the latest rendered one)
  32479. * @returns the cached material
  32480. */
  32481. getCachedMaterial(): Nullable<Material>;
  32482. /**
  32483. * Gets the cached effect (ie. the latest rendered one)
  32484. * @returns the cached effect
  32485. */
  32486. getCachedEffect(): Nullable<Effect>;
  32487. /**
  32488. * Gets the cached visibility state (ie. the latest rendered one)
  32489. * @returns the cached visibility state
  32490. */
  32491. getCachedVisibility(): Nullable<number>;
  32492. /**
  32493. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32494. * @param material defines the current material
  32495. * @param effect defines the current effect
  32496. * @param visibility defines the current visibility state
  32497. * @returns true if one parameter is not cached
  32498. */
  32499. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32500. /**
  32501. * Gets the engine associated with the scene
  32502. * @returns an Engine
  32503. */
  32504. getEngine(): Engine;
  32505. /**
  32506. * Gets the total number of vertices rendered per frame
  32507. * @returns the total number of vertices rendered per frame
  32508. */
  32509. getTotalVertices(): number;
  32510. /**
  32511. * Gets the performance counter for total vertices
  32512. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32513. */
  32514. readonly totalVerticesPerfCounter: PerfCounter;
  32515. /**
  32516. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32517. * @returns the total number of active indices rendered per frame
  32518. */
  32519. getActiveIndices(): number;
  32520. /**
  32521. * Gets the performance counter for active indices
  32522. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32523. */
  32524. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32525. /**
  32526. * Gets the total number of active particles rendered per frame
  32527. * @returns the total number of active particles rendered per frame
  32528. */
  32529. getActiveParticles(): number;
  32530. /**
  32531. * Gets the performance counter for active particles
  32532. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32533. */
  32534. readonly activeParticlesPerfCounter: PerfCounter;
  32535. /**
  32536. * Gets the total number of active bones rendered per frame
  32537. * @returns the total number of active bones rendered per frame
  32538. */
  32539. getActiveBones(): number;
  32540. /**
  32541. * Gets the performance counter for active bones
  32542. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32543. */
  32544. readonly activeBonesPerfCounter: PerfCounter;
  32545. /**
  32546. * Gets the array of active meshes
  32547. * @returns an array of AbstractMesh
  32548. */
  32549. getActiveMeshes(): SmartArray<AbstractMesh>;
  32550. /**
  32551. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32552. * @returns a number
  32553. */
  32554. getAnimationRatio(): number;
  32555. /**
  32556. * Gets an unique Id for the current render phase
  32557. * @returns a number
  32558. */
  32559. getRenderId(): number;
  32560. /**
  32561. * Gets an unique Id for the current frame
  32562. * @returns a number
  32563. */
  32564. getFrameId(): number;
  32565. /** Call this function if you want to manually increment the render Id*/
  32566. incrementRenderId(): void;
  32567. private _updatePointerPosition;
  32568. private _createUbo;
  32569. private _createAlternateUbo;
  32570. private _setRayOnPointerInfo;
  32571. /**
  32572. * Use this method to simulate a pointer move on a mesh
  32573. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32574. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32575. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32576. * @returns the current scene
  32577. */
  32578. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32579. private _processPointerMove;
  32580. private _checkPrePointerObservable;
  32581. /**
  32582. * Use this method to simulate a pointer down on a mesh
  32583. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32584. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32585. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32586. * @returns the current scene
  32587. */
  32588. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32589. private _processPointerDown;
  32590. /**
  32591. * Use this method to simulate a pointer up on a mesh
  32592. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32593. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32594. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32595. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32596. * @returns the current scene
  32597. */
  32598. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32599. private _processPointerUp;
  32600. /**
  32601. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32602. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32603. * @returns true if the pointer was captured
  32604. */
  32605. isPointerCaptured(pointerId?: number): boolean;
  32606. /** @hidden */
  32607. _isPointerSwiping(): boolean;
  32608. /**
  32609. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32610. * @param attachUp defines if you want to attach events to pointerup
  32611. * @param attachDown defines if you want to attach events to pointerdown
  32612. * @param attachMove defines if you want to attach events to pointermove
  32613. */
  32614. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32615. /** Detaches all event handlers*/
  32616. detachControl(): void;
  32617. /**
  32618. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32619. * Delay loaded resources are not taking in account
  32620. * @return true if all required resources are ready
  32621. */
  32622. isReady(): boolean;
  32623. /** Resets all cached information relative to material (including effect and visibility) */
  32624. resetCachedMaterial(): void;
  32625. /**
  32626. * Registers a function to be called before every frame render
  32627. * @param func defines the function to register
  32628. */
  32629. registerBeforeRender(func: () => void): void;
  32630. /**
  32631. * Unregisters a function called before every frame render
  32632. * @param func defines the function to unregister
  32633. */
  32634. unregisterBeforeRender(func: () => void): void;
  32635. /**
  32636. * Registers a function to be called after every frame render
  32637. * @param func defines the function to register
  32638. */
  32639. registerAfterRender(func: () => void): void;
  32640. /**
  32641. * Unregisters a function called after every frame render
  32642. * @param func defines the function to unregister
  32643. */
  32644. unregisterAfterRender(func: () => void): void;
  32645. private _executeOnceBeforeRender;
  32646. /**
  32647. * The provided function will run before render once and will be disposed afterwards.
  32648. * A timeout delay can be provided so that the function will be executed in N ms.
  32649. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32650. * @param func The function to be executed.
  32651. * @param timeout optional delay in ms
  32652. */
  32653. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32654. /** @hidden */
  32655. _addPendingData(data: any): void;
  32656. /** @hidden */
  32657. _removePendingData(data: any): void;
  32658. /**
  32659. * Returns the number of items waiting to be loaded
  32660. * @returns the number of items waiting to be loaded
  32661. */
  32662. getWaitingItemsCount(): number;
  32663. /**
  32664. * Returns a boolean indicating if the scene is still loading data
  32665. */
  32666. readonly isLoading: boolean;
  32667. /**
  32668. * Registers a function to be executed when the scene is ready
  32669. * @param {Function} func - the function to be executed
  32670. */
  32671. executeWhenReady(func: () => void): void;
  32672. /**
  32673. * Returns a promise that resolves when the scene is ready
  32674. * @returns A promise that resolves when the scene is ready
  32675. */
  32676. whenReadyAsync(): Promise<void>;
  32677. /** @hidden */
  32678. _checkIsReady(): void;
  32679. /**
  32680. * Gets all animatable attached to the scene
  32681. */
  32682. readonly animatables: Animatable[];
  32683. /**
  32684. * Resets the last animation time frame.
  32685. * Useful to override when animations start running when loading a scene for the first time.
  32686. */
  32687. resetLastAnimationTimeFrame(): void;
  32688. /** @hidden */
  32689. _switchToAlternateCameraConfiguration(active: boolean): void;
  32690. /**
  32691. * Gets the current view matrix
  32692. * @returns a Matrix
  32693. */
  32694. getViewMatrix(): Matrix;
  32695. /**
  32696. * Gets the current projection matrix
  32697. * @returns a Matrix
  32698. */
  32699. getProjectionMatrix(): Matrix;
  32700. /**
  32701. * Gets the current transform matrix
  32702. * @returns a Matrix made of View * Projection
  32703. */
  32704. getTransformMatrix(): Matrix;
  32705. /**
  32706. * Sets the current transform matrix
  32707. * @param view defines the View matrix to use
  32708. * @param projection defines the Projection matrix to use
  32709. */
  32710. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32711. /** @hidden */
  32712. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32713. /**
  32714. * Gets the uniform buffer used to store scene data
  32715. * @returns a UniformBuffer
  32716. */
  32717. getSceneUniformBuffer(): UniformBuffer;
  32718. /**
  32719. * Gets an unique (relatively to the current scene) Id
  32720. * @returns an unique number for the scene
  32721. */
  32722. getUniqueId(): number;
  32723. /**
  32724. * Add a mesh to the list of scene's meshes
  32725. * @param newMesh defines the mesh to add
  32726. * @param recursive if all child meshes should also be added to the scene
  32727. */
  32728. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32729. /**
  32730. * Remove a mesh for the list of scene's meshes
  32731. * @param toRemove defines the mesh to remove
  32732. * @param recursive if all child meshes should also be removed from the scene
  32733. * @returns the index where the mesh was in the mesh list
  32734. */
  32735. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32736. /**
  32737. * Add a transform node to the list of scene's transform nodes
  32738. * @param newTransformNode defines the transform node to add
  32739. */
  32740. addTransformNode(newTransformNode: TransformNode): void;
  32741. /**
  32742. * Remove a transform node for the list of scene's transform nodes
  32743. * @param toRemove defines the transform node to remove
  32744. * @returns the index where the transform node was in the transform node list
  32745. */
  32746. removeTransformNode(toRemove: TransformNode): number;
  32747. /**
  32748. * Remove a skeleton for the list of scene's skeletons
  32749. * @param toRemove defines the skeleton to remove
  32750. * @returns the index where the skeleton was in the skeleton list
  32751. */
  32752. removeSkeleton(toRemove: Skeleton): number;
  32753. /**
  32754. * Remove a morph target for the list of scene's morph targets
  32755. * @param toRemove defines the morph target to remove
  32756. * @returns the index where the morph target was in the morph target list
  32757. */
  32758. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32759. /**
  32760. * Remove a light for the list of scene's lights
  32761. * @param toRemove defines the light to remove
  32762. * @returns the index where the light was in the light list
  32763. */
  32764. removeLight(toRemove: Light): number;
  32765. /**
  32766. * Remove a camera for the list of scene's cameras
  32767. * @param toRemove defines the camera to remove
  32768. * @returns the index where the camera was in the camera list
  32769. */
  32770. removeCamera(toRemove: Camera): number;
  32771. /**
  32772. * Remove a particle system for the list of scene's particle systems
  32773. * @param toRemove defines the particle system to remove
  32774. * @returns the index where the particle system was in the particle system list
  32775. */
  32776. removeParticleSystem(toRemove: IParticleSystem): number;
  32777. /**
  32778. * Remove a animation for the list of scene's animations
  32779. * @param toRemove defines the animation to remove
  32780. * @returns the index where the animation was in the animation list
  32781. */
  32782. removeAnimation(toRemove: Animation): number;
  32783. /**
  32784. * Removes the given animation group from this scene.
  32785. * @param toRemove The animation group to remove
  32786. * @returns The index of the removed animation group
  32787. */
  32788. removeAnimationGroup(toRemove: AnimationGroup): number;
  32789. /**
  32790. * Removes the given multi-material from this scene.
  32791. * @param toRemove The multi-material to remove
  32792. * @returns The index of the removed multi-material
  32793. */
  32794. removeMultiMaterial(toRemove: MultiMaterial): number;
  32795. /**
  32796. * Removes the given material from this scene.
  32797. * @param toRemove The material to remove
  32798. * @returns The index of the removed material
  32799. */
  32800. removeMaterial(toRemove: Material): number;
  32801. /**
  32802. * Removes the given action manager from this scene.
  32803. * @param toRemove The action manager to remove
  32804. * @returns The index of the removed action manager
  32805. */
  32806. removeActionManager(toRemove: AbstractActionManager): number;
  32807. /**
  32808. * Removes the given texture from this scene.
  32809. * @param toRemove The texture to remove
  32810. * @returns The index of the removed texture
  32811. */
  32812. removeTexture(toRemove: BaseTexture): number;
  32813. /**
  32814. * Adds the given light to this scene
  32815. * @param newLight The light to add
  32816. */
  32817. addLight(newLight: Light): void;
  32818. /**
  32819. * Sorts the list list based on light priorities
  32820. */
  32821. sortLightsByPriority(): void;
  32822. /**
  32823. * Adds the given camera to this scene
  32824. * @param newCamera The camera to add
  32825. */
  32826. addCamera(newCamera: Camera): void;
  32827. /**
  32828. * Adds the given skeleton to this scene
  32829. * @param newSkeleton The skeleton to add
  32830. */
  32831. addSkeleton(newSkeleton: Skeleton): void;
  32832. /**
  32833. * Adds the given particle system to this scene
  32834. * @param newParticleSystem The particle system to add
  32835. */
  32836. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32837. /**
  32838. * Adds the given animation to this scene
  32839. * @param newAnimation The animation to add
  32840. */
  32841. addAnimation(newAnimation: Animation): void;
  32842. /**
  32843. * Adds the given animation group to this scene.
  32844. * @param newAnimationGroup The animation group to add
  32845. */
  32846. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32847. /**
  32848. * Adds the given multi-material to this scene
  32849. * @param newMultiMaterial The multi-material to add
  32850. */
  32851. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32852. /**
  32853. * Adds the given material to this scene
  32854. * @param newMaterial The material to add
  32855. */
  32856. addMaterial(newMaterial: Material): void;
  32857. /**
  32858. * Adds the given morph target to this scene
  32859. * @param newMorphTargetManager The morph target to add
  32860. */
  32861. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32862. /**
  32863. * Adds the given geometry to this scene
  32864. * @param newGeometry The geometry to add
  32865. */
  32866. addGeometry(newGeometry: Geometry): void;
  32867. /**
  32868. * Adds the given action manager to this scene
  32869. * @param newActionManager The action manager to add
  32870. */
  32871. addActionManager(newActionManager: AbstractActionManager): void;
  32872. /**
  32873. * Adds the given texture to this scene.
  32874. * @param newTexture The texture to add
  32875. */
  32876. addTexture(newTexture: BaseTexture): void;
  32877. /**
  32878. * Switch active camera
  32879. * @param newCamera defines the new active camera
  32880. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32881. */
  32882. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32883. /**
  32884. * sets the active camera of the scene using its ID
  32885. * @param id defines the camera's ID
  32886. * @return the new active camera or null if none found.
  32887. */
  32888. setActiveCameraByID(id: string): Nullable<Camera>;
  32889. /**
  32890. * sets the active camera of the scene using its name
  32891. * @param name defines the camera's name
  32892. * @returns the new active camera or null if none found.
  32893. */
  32894. setActiveCameraByName(name: string): Nullable<Camera>;
  32895. /**
  32896. * get an animation group using its name
  32897. * @param name defines the material's name
  32898. * @return the animation group or null if none found.
  32899. */
  32900. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32901. /**
  32902. * get a material using its id
  32903. * @param id defines the material's ID
  32904. * @return the material or null if none found.
  32905. */
  32906. getMaterialByID(id: string): Nullable<Material>;
  32907. /**
  32908. * Gets a material using its name
  32909. * @param name defines the material's name
  32910. * @return the material or null if none found.
  32911. */
  32912. getMaterialByName(name: string): Nullable<Material>;
  32913. /**
  32914. * Gets a camera using its id
  32915. * @param id defines the id to look for
  32916. * @returns the camera or null if not found
  32917. */
  32918. getCameraByID(id: string): Nullable<Camera>;
  32919. /**
  32920. * Gets a camera using its unique id
  32921. * @param uniqueId defines the unique id to look for
  32922. * @returns the camera or null if not found
  32923. */
  32924. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32925. /**
  32926. * Gets a camera using its name
  32927. * @param name defines the camera's name
  32928. * @return the camera or null if none found.
  32929. */
  32930. getCameraByName(name: string): Nullable<Camera>;
  32931. /**
  32932. * Gets a bone using its id
  32933. * @param id defines the bone's id
  32934. * @return the bone or null if not found
  32935. */
  32936. getBoneByID(id: string): Nullable<Bone>;
  32937. /**
  32938. * Gets a bone using its id
  32939. * @param name defines the bone's name
  32940. * @return the bone or null if not found
  32941. */
  32942. getBoneByName(name: string): Nullable<Bone>;
  32943. /**
  32944. * Gets a light node using its name
  32945. * @param name defines the the light's name
  32946. * @return the light or null if none found.
  32947. */
  32948. getLightByName(name: string): Nullable<Light>;
  32949. /**
  32950. * Gets a light node using its id
  32951. * @param id defines the light's id
  32952. * @return the light or null if none found.
  32953. */
  32954. getLightByID(id: string): Nullable<Light>;
  32955. /**
  32956. * Gets a light node using its scene-generated unique ID
  32957. * @param uniqueId defines the light's unique id
  32958. * @return the light or null if none found.
  32959. */
  32960. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32961. /**
  32962. * Gets a particle system by id
  32963. * @param id defines the particle system id
  32964. * @return the corresponding system or null if none found
  32965. */
  32966. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32967. /**
  32968. * Gets a geometry using its ID
  32969. * @param id defines the geometry's id
  32970. * @return the geometry or null if none found.
  32971. */
  32972. getGeometryByID(id: string): Nullable<Geometry>;
  32973. private _getGeometryByUniqueID;
  32974. /**
  32975. * Add a new geometry to this scene
  32976. * @param geometry defines the geometry to be added to the scene.
  32977. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32978. * @return a boolean defining if the geometry was added or not
  32979. */
  32980. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32981. /**
  32982. * Removes an existing geometry
  32983. * @param geometry defines the geometry to be removed from the scene
  32984. * @return a boolean defining if the geometry was removed or not
  32985. */
  32986. removeGeometry(geometry: Geometry): boolean;
  32987. /**
  32988. * Gets the list of geometries attached to the scene
  32989. * @returns an array of Geometry
  32990. */
  32991. getGeometries(): Geometry[];
  32992. /**
  32993. * Gets the first added mesh found of a given ID
  32994. * @param id defines the id to search for
  32995. * @return the mesh found or null if not found at all
  32996. */
  32997. getMeshByID(id: string): Nullable<AbstractMesh>;
  32998. /**
  32999. * Gets a list of meshes using their id
  33000. * @param id defines the id to search for
  33001. * @returns a list of meshes
  33002. */
  33003. getMeshesByID(id: string): Array<AbstractMesh>;
  33004. /**
  33005. * Gets the first added transform node found of a given ID
  33006. * @param id defines the id to search for
  33007. * @return the found transform node or null if not found at all.
  33008. */
  33009. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33010. /**
  33011. * Gets a list of transform nodes using their id
  33012. * @param id defines the id to search for
  33013. * @returns a list of transform nodes
  33014. */
  33015. getTransformNodesByID(id: string): Array<TransformNode>;
  33016. /**
  33017. * Gets a mesh with its auto-generated unique id
  33018. * @param uniqueId defines the unique id to search for
  33019. * @return the found mesh or null if not found at all.
  33020. */
  33021. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33022. /**
  33023. * Gets a the last added mesh using a given id
  33024. * @param id defines the id to search for
  33025. * @return the found mesh or null if not found at all.
  33026. */
  33027. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33028. /**
  33029. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33030. * @param id defines the id to search for
  33031. * @return the found node or null if not found at all
  33032. */
  33033. getLastEntryByID(id: string): Nullable<Node>;
  33034. /**
  33035. * Gets a node (Mesh, Camera, Light) using a given id
  33036. * @param id defines the id to search for
  33037. * @return the found node or null if not found at all
  33038. */
  33039. getNodeByID(id: string): Nullable<Node>;
  33040. /**
  33041. * Gets a node (Mesh, Camera, Light) using a given name
  33042. * @param name defines the name to search for
  33043. * @return the found node or null if not found at all.
  33044. */
  33045. getNodeByName(name: string): Nullable<Node>;
  33046. /**
  33047. * Gets a mesh using a given name
  33048. * @param name defines the name to search for
  33049. * @return the found mesh or null if not found at all.
  33050. */
  33051. getMeshByName(name: string): Nullable<AbstractMesh>;
  33052. /**
  33053. * Gets a transform node using a given name
  33054. * @param name defines the name to search for
  33055. * @return the found transform node or null if not found at all.
  33056. */
  33057. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33058. /**
  33059. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33060. * @param id defines the id to search for
  33061. * @return the found skeleton or null if not found at all.
  33062. */
  33063. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33064. /**
  33065. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33066. * @param id defines the id to search for
  33067. * @return the found skeleton or null if not found at all.
  33068. */
  33069. getSkeletonById(id: string): Nullable<Skeleton>;
  33070. /**
  33071. * Gets a skeleton using a given name
  33072. * @param name defines the name to search for
  33073. * @return the found skeleton or null if not found at all.
  33074. */
  33075. getSkeletonByName(name: string): Nullable<Skeleton>;
  33076. /**
  33077. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33078. * @param id defines the id to search for
  33079. * @return the found morph target manager or null if not found at all.
  33080. */
  33081. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33082. /**
  33083. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33084. * @param id defines the id to search for
  33085. * @return the found morph target or null if not found at all.
  33086. */
  33087. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33088. /**
  33089. * Gets a boolean indicating if the given mesh is active
  33090. * @param mesh defines the mesh to look for
  33091. * @returns true if the mesh is in the active list
  33092. */
  33093. isActiveMesh(mesh: AbstractMesh): boolean;
  33094. /**
  33095. * Return a unique id as a string which can serve as an identifier for the scene
  33096. */
  33097. readonly uid: string;
  33098. /**
  33099. * Add an externaly attached data from its key.
  33100. * This method call will fail and return false, if such key already exists.
  33101. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33102. * @param key the unique key that identifies the data
  33103. * @param data the data object to associate to the key for this Engine instance
  33104. * @return true if no such key were already present and the data was added successfully, false otherwise
  33105. */
  33106. addExternalData<T>(key: string, data: T): boolean;
  33107. /**
  33108. * Get an externaly attached data from its key
  33109. * @param key the unique key that identifies the data
  33110. * @return the associated data, if present (can be null), or undefined if not present
  33111. */
  33112. getExternalData<T>(key: string): Nullable<T>;
  33113. /**
  33114. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33115. * @param key the unique key that identifies the data
  33116. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33117. * @return the associated data, can be null if the factory returned null.
  33118. */
  33119. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33120. /**
  33121. * Remove an externaly attached data from the Engine instance
  33122. * @param key the unique key that identifies the data
  33123. * @return true if the data was successfully removed, false if it doesn't exist
  33124. */
  33125. removeExternalData(key: string): boolean;
  33126. private _evaluateSubMesh;
  33127. /**
  33128. * Clear the processed materials smart array preventing retention point in material dispose.
  33129. */
  33130. freeProcessedMaterials(): void;
  33131. private _preventFreeActiveMeshesAndRenderingGroups;
  33132. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33133. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33134. * when disposing several meshes in a row or a hierarchy of meshes.
  33135. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33136. */
  33137. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33138. /**
  33139. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33140. */
  33141. freeActiveMeshes(): void;
  33142. /**
  33143. * Clear the info related to rendering groups preventing retention points during dispose.
  33144. */
  33145. freeRenderingGroups(): void;
  33146. /** @hidden */
  33147. _isInIntermediateRendering(): boolean;
  33148. /**
  33149. * Lambda returning the list of potentially active meshes.
  33150. */
  33151. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33152. /**
  33153. * Lambda returning the list of potentially active sub meshes.
  33154. */
  33155. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33156. /**
  33157. * Lambda returning the list of potentially intersecting sub meshes.
  33158. */
  33159. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33160. /**
  33161. * Lambda returning the list of potentially colliding sub meshes.
  33162. */
  33163. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33164. private _activeMeshesFrozen;
  33165. /**
  33166. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33167. * @returns the current scene
  33168. */
  33169. freezeActiveMeshes(): Scene;
  33170. /**
  33171. * Use this function to restart evaluating active meshes on every frame
  33172. * @returns the current scene
  33173. */
  33174. unfreezeActiveMeshes(): Scene;
  33175. private _evaluateActiveMeshes;
  33176. private _activeMesh;
  33177. /**
  33178. * Update the transform matrix to update from the current active camera
  33179. * @param force defines a boolean used to force the update even if cache is up to date
  33180. */
  33181. updateTransformMatrix(force?: boolean): void;
  33182. /**
  33183. * 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)
  33184. * @param alternateCamera defines the camera to use
  33185. */
  33186. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33187. /** @hidden */
  33188. _allowPostProcessClearColor: boolean;
  33189. private _renderForCamera;
  33190. private _processSubCameras;
  33191. private _checkIntersections;
  33192. /** @hidden */
  33193. _advancePhysicsEngineStep(step: number): void;
  33194. /**
  33195. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33196. */
  33197. getDeterministicFrameTime: () => number;
  33198. /** @hidden */
  33199. _animate(): void;
  33200. /**
  33201. * Render the scene
  33202. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33203. */
  33204. render(updateCameras?: boolean): void;
  33205. /**
  33206. * Freeze all materials
  33207. * A frozen material will not be updatable but should be faster to render
  33208. */
  33209. freezeMaterials(): void;
  33210. /**
  33211. * Unfreeze all materials
  33212. * A frozen material will not be updatable but should be faster to render
  33213. */
  33214. unfreezeMaterials(): void;
  33215. /**
  33216. * Releases all held ressources
  33217. */
  33218. dispose(): void;
  33219. /**
  33220. * Gets if the scene is already disposed
  33221. */
  33222. readonly isDisposed: boolean;
  33223. /**
  33224. * Call this function to reduce memory footprint of the scene.
  33225. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33226. */
  33227. clearCachedVertexData(): void;
  33228. /**
  33229. * This function will remove the local cached buffer data from texture.
  33230. * It will save memory but will prevent the texture from being rebuilt
  33231. */
  33232. cleanCachedTextureBuffer(): void;
  33233. /**
  33234. * Get the world extend vectors with an optional filter
  33235. *
  33236. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33237. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33238. */
  33239. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33240. min: Vector3;
  33241. max: Vector3;
  33242. };
  33243. /**
  33244. * Creates a ray that can be used to pick in the scene
  33245. * @param x defines the x coordinate of the origin (on-screen)
  33246. * @param y defines the y coordinate of the origin (on-screen)
  33247. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33248. * @param camera defines the camera to use for the picking
  33249. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33250. * @returns a Ray
  33251. */
  33252. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33253. /**
  33254. * Creates a ray that can be used to pick in the scene
  33255. * @param x defines the x coordinate of the origin (on-screen)
  33256. * @param y defines the y coordinate of the origin (on-screen)
  33257. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33258. * @param result defines the ray where to store the picking ray
  33259. * @param camera defines the camera to use for the picking
  33260. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33261. * @returns the current scene
  33262. */
  33263. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33264. /**
  33265. * Creates a ray that can be used to pick in the scene
  33266. * @param x defines the x coordinate of the origin (on-screen)
  33267. * @param y defines the y coordinate of the origin (on-screen)
  33268. * @param camera defines the camera to use for the picking
  33269. * @returns a Ray
  33270. */
  33271. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33272. /**
  33273. * Creates a ray that can be used to pick in the scene
  33274. * @param x defines the x coordinate of the origin (on-screen)
  33275. * @param y defines the y coordinate of the origin (on-screen)
  33276. * @param result defines the ray where to store the picking ray
  33277. * @param camera defines the camera to use for the picking
  33278. * @returns the current scene
  33279. */
  33280. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33281. /** Launch a ray to try to pick a mesh in the scene
  33282. * @param x position on screen
  33283. * @param y position on screen
  33284. * @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
  33285. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33286. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33287. * @returns a PickingInfo
  33288. */
  33289. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  33290. /** Use the given ray to pick a mesh in the scene
  33291. * @param ray The ray to use to pick meshes
  33292. * @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
  33293. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33294. * @returns a PickingInfo
  33295. */
  33296. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  33297. /**
  33298. * Launch a ray to try to pick a mesh in the scene
  33299. * @param x X position on screen
  33300. * @param y Y position on screen
  33301. * @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
  33302. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33303. * @returns an array of PickingInfo
  33304. */
  33305. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  33306. /**
  33307. * Launch a ray to try to pick a mesh in the scene
  33308. * @param ray Ray to use
  33309. * @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
  33310. * @returns an array of PickingInfo
  33311. */
  33312. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  33313. /**
  33314. * Force the value of meshUnderPointer
  33315. * @param mesh defines the mesh to use
  33316. */
  33317. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33318. /**
  33319. * Gets the mesh under the pointer
  33320. * @returns a Mesh or null if no mesh is under the pointer
  33321. */
  33322. getPointerOverMesh(): Nullable<AbstractMesh>;
  33323. /** @hidden */
  33324. _rebuildGeometries(): void;
  33325. /** @hidden */
  33326. _rebuildTextures(): void;
  33327. private _getByTags;
  33328. /**
  33329. * Get a list of meshes by tags
  33330. * @param tagsQuery defines the tags query to use
  33331. * @param forEach defines a predicate used to filter results
  33332. * @returns an array of Mesh
  33333. */
  33334. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33335. /**
  33336. * Get a list of cameras by tags
  33337. * @param tagsQuery defines the tags query to use
  33338. * @param forEach defines a predicate used to filter results
  33339. * @returns an array of Camera
  33340. */
  33341. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33342. /**
  33343. * Get a list of lights by tags
  33344. * @param tagsQuery defines the tags query to use
  33345. * @param forEach defines a predicate used to filter results
  33346. * @returns an array of Light
  33347. */
  33348. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33349. /**
  33350. * Get a list of materials by tags
  33351. * @param tagsQuery defines the tags query to use
  33352. * @param forEach defines a predicate used to filter results
  33353. * @returns an array of Material
  33354. */
  33355. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33356. /**
  33357. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33358. * This allowed control for front to back rendering or reversly depending of the special needs.
  33359. *
  33360. * @param renderingGroupId The rendering group id corresponding to its index
  33361. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33362. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33363. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33364. */
  33365. 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;
  33366. /**
  33367. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33368. *
  33369. * @param renderingGroupId The rendering group id corresponding to its index
  33370. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33371. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33372. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33373. */
  33374. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33375. /**
  33376. * Gets the current auto clear configuration for one rendering group of the rendering
  33377. * manager.
  33378. * @param index the rendering group index to get the information for
  33379. * @returns The auto clear setup for the requested rendering group
  33380. */
  33381. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33382. private _blockMaterialDirtyMechanism;
  33383. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33384. blockMaterialDirtyMechanism: boolean;
  33385. /**
  33386. * Will flag all materials as dirty to trigger new shader compilation
  33387. * @param flag defines the flag used to specify which material part must be marked as dirty
  33388. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33389. */
  33390. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33391. /** @hidden */
  33392. _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;
  33393. /** @hidden */
  33394. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33395. }
  33396. }
  33397. declare module "babylonjs/assetContainer" {
  33398. import { AbstractScene } from "babylonjs/abstractScene";
  33399. import { Scene } from "babylonjs/scene";
  33400. import { Mesh } from "babylonjs/Meshes/mesh";
  33401. /**
  33402. * Set of assets to keep when moving a scene into an asset container.
  33403. */
  33404. export class KeepAssets extends AbstractScene {
  33405. }
  33406. /**
  33407. * Container with a set of assets that can be added or removed from a scene.
  33408. */
  33409. export class AssetContainer extends AbstractScene {
  33410. /**
  33411. * The scene the AssetContainer belongs to.
  33412. */
  33413. scene: Scene;
  33414. /**
  33415. * Instantiates an AssetContainer.
  33416. * @param scene The scene the AssetContainer belongs to.
  33417. */
  33418. constructor(scene: Scene);
  33419. /**
  33420. * Adds all the assets from the container to the scene.
  33421. */
  33422. addAllToScene(): void;
  33423. /**
  33424. * Removes all the assets in the container from the scene
  33425. */
  33426. removeAllFromScene(): void;
  33427. /**
  33428. * Disposes all the assets in the container
  33429. */
  33430. dispose(): void;
  33431. private _moveAssets;
  33432. /**
  33433. * Removes all the assets contained in the scene and adds them to the container.
  33434. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33435. */
  33436. moveAllFromScene(keepAssets?: KeepAssets): void;
  33437. /**
  33438. * 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.
  33439. * @returns the root mesh
  33440. */
  33441. createRootMesh(): Mesh;
  33442. }
  33443. }
  33444. declare module "babylonjs/abstractScene" {
  33445. import { Scene } from "babylonjs/scene";
  33446. import { Nullable } from "babylonjs/types";
  33447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33448. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33449. import { Geometry } from "babylonjs/Meshes/geometry";
  33450. import { Skeleton } from "babylonjs/Bones/skeleton";
  33451. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33452. import { AssetContainer } from "babylonjs/assetContainer";
  33453. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33454. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33455. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33456. import { Material } from "babylonjs/Materials/material";
  33457. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33458. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33459. import { Camera } from "babylonjs/Cameras/camera";
  33460. import { Light } from "babylonjs/Lights/light";
  33461. import { Node } from "babylonjs/node";
  33462. import { Animation } from "babylonjs/Animations/animation";
  33463. /**
  33464. * Defines how the parser contract is defined.
  33465. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33466. */
  33467. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33468. /**
  33469. * Defines how the individual parser contract is defined.
  33470. * These parser can parse an individual asset
  33471. */
  33472. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33473. /**
  33474. * Base class of the scene acting as a container for the different elements composing a scene.
  33475. * This class is dynamically extended by the different components of the scene increasing
  33476. * flexibility and reducing coupling
  33477. */
  33478. export abstract class AbstractScene {
  33479. /**
  33480. * Stores the list of available parsers in the application.
  33481. */
  33482. private static _BabylonFileParsers;
  33483. /**
  33484. * Stores the list of available individual parsers in the application.
  33485. */
  33486. private static _IndividualBabylonFileParsers;
  33487. /**
  33488. * Adds a parser in the list of available ones
  33489. * @param name Defines the name of the parser
  33490. * @param parser Defines the parser to add
  33491. */
  33492. static AddParser(name: string, parser: BabylonFileParser): void;
  33493. /**
  33494. * Gets a general parser from the list of avaialble ones
  33495. * @param name Defines the name of the parser
  33496. * @returns the requested parser or null
  33497. */
  33498. static GetParser(name: string): Nullable<BabylonFileParser>;
  33499. /**
  33500. * Adds n individual parser in the list of available ones
  33501. * @param name Defines the name of the parser
  33502. * @param parser Defines the parser to add
  33503. */
  33504. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33505. /**
  33506. * Gets an individual parser from the list of avaialble ones
  33507. * @param name Defines the name of the parser
  33508. * @returns the requested parser or null
  33509. */
  33510. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33511. /**
  33512. * Parser json data and populate both a scene and its associated container object
  33513. * @param jsonData Defines the data to parse
  33514. * @param scene Defines the scene to parse the data for
  33515. * @param container Defines the container attached to the parsing sequence
  33516. * @param rootUrl Defines the root url of the data
  33517. */
  33518. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33519. /**
  33520. * Gets the list of root nodes (ie. nodes with no parent)
  33521. */
  33522. rootNodes: Node[];
  33523. /** All of the cameras added to this scene
  33524. * @see http://doc.babylonjs.com/babylon101/cameras
  33525. */
  33526. cameras: Camera[];
  33527. /**
  33528. * All of the lights added to this scene
  33529. * @see http://doc.babylonjs.com/babylon101/lights
  33530. */
  33531. lights: Light[];
  33532. /**
  33533. * All of the (abstract) meshes added to this scene
  33534. */
  33535. meshes: AbstractMesh[];
  33536. /**
  33537. * The list of skeletons added to the scene
  33538. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33539. */
  33540. skeletons: Skeleton[];
  33541. /**
  33542. * All of the particle systems added to this scene
  33543. * @see http://doc.babylonjs.com/babylon101/particles
  33544. */
  33545. particleSystems: IParticleSystem[];
  33546. /**
  33547. * Gets a list of Animations associated with the scene
  33548. */
  33549. animations: Animation[];
  33550. /**
  33551. * All of the animation groups added to this scene
  33552. * @see http://doc.babylonjs.com/how_to/group
  33553. */
  33554. animationGroups: AnimationGroup[];
  33555. /**
  33556. * All of the multi-materials added to this scene
  33557. * @see http://doc.babylonjs.com/how_to/multi_materials
  33558. */
  33559. multiMaterials: MultiMaterial[];
  33560. /**
  33561. * All of the materials added to this scene
  33562. * In the context of a Scene, it is not supposed to be modified manually.
  33563. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33564. * Note also that the order of the Material wihin the array is not significant and might change.
  33565. * @see http://doc.babylonjs.com/babylon101/materials
  33566. */
  33567. materials: Material[];
  33568. /**
  33569. * The list of morph target managers added to the scene
  33570. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33571. */
  33572. morphTargetManagers: MorphTargetManager[];
  33573. /**
  33574. * The list of geometries used in the scene.
  33575. */
  33576. geometries: Geometry[];
  33577. /**
  33578. * All of the tranform nodes added to this scene
  33579. * In the context of a Scene, it is not supposed to be modified manually.
  33580. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33581. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33582. * @see http://doc.babylonjs.com/how_to/transformnode
  33583. */
  33584. transformNodes: TransformNode[];
  33585. /**
  33586. * ActionManagers available on the scene.
  33587. */
  33588. actionManagers: AbstractActionManager[];
  33589. /**
  33590. * Textures to keep.
  33591. */
  33592. textures: BaseTexture[];
  33593. }
  33594. }
  33595. declare module "babylonjs/Audio/sound" {
  33596. import { Observable } from "babylonjs/Misc/observable";
  33597. import { Vector3 } from "babylonjs/Maths/math";
  33598. import { Nullable } from "babylonjs/types";
  33599. import { Scene } from "babylonjs/scene";
  33600. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33601. /**
  33602. * Defines a sound that can be played in the application.
  33603. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33605. */
  33606. export class Sound {
  33607. /**
  33608. * The name of the sound in the scene.
  33609. */
  33610. name: string;
  33611. /**
  33612. * Does the sound autoplay once loaded.
  33613. */
  33614. autoplay: boolean;
  33615. /**
  33616. * Does the sound loop after it finishes playing once.
  33617. */
  33618. loop: boolean;
  33619. /**
  33620. * Does the sound use a custom attenuation curve to simulate the falloff
  33621. * happening when the source gets further away from the camera.
  33622. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33623. */
  33624. useCustomAttenuation: boolean;
  33625. /**
  33626. * The sound track id this sound belongs to.
  33627. */
  33628. soundTrackId: number;
  33629. /**
  33630. * Is this sound currently played.
  33631. */
  33632. isPlaying: boolean;
  33633. /**
  33634. * Is this sound currently paused.
  33635. */
  33636. isPaused: boolean;
  33637. /**
  33638. * Does this sound enables spatial sound.
  33639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33640. */
  33641. spatialSound: boolean;
  33642. /**
  33643. * Define the reference distance the sound should be heard perfectly.
  33644. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33645. */
  33646. refDistance: number;
  33647. /**
  33648. * Define the roll off factor of spatial sounds.
  33649. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33650. */
  33651. rolloffFactor: number;
  33652. /**
  33653. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33654. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33655. */
  33656. maxDistance: number;
  33657. /**
  33658. * Define the distance attenuation model the sound will follow.
  33659. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33660. */
  33661. distanceModel: string;
  33662. /**
  33663. * @hidden
  33664. * Back Compat
  33665. **/
  33666. onended: () => any;
  33667. /**
  33668. * Observable event when the current playing sound finishes.
  33669. */
  33670. onEndedObservable: Observable<Sound>;
  33671. private _panningModel;
  33672. private _playbackRate;
  33673. private _streaming;
  33674. private _startTime;
  33675. private _startOffset;
  33676. private _position;
  33677. /** @hidden */
  33678. _positionInEmitterSpace: boolean;
  33679. private _localDirection;
  33680. private _volume;
  33681. private _isReadyToPlay;
  33682. private _isDirectional;
  33683. private _readyToPlayCallback;
  33684. private _audioBuffer;
  33685. private _soundSource;
  33686. private _streamingSource;
  33687. private _soundPanner;
  33688. private _soundGain;
  33689. private _inputAudioNode;
  33690. private _outputAudioNode;
  33691. private _coneInnerAngle;
  33692. private _coneOuterAngle;
  33693. private _coneOuterGain;
  33694. private _scene;
  33695. private _connectedTransformNode;
  33696. private _customAttenuationFunction;
  33697. private _registerFunc;
  33698. private _isOutputConnected;
  33699. private _htmlAudioElement;
  33700. private _urlType;
  33701. /** @hidden */
  33702. static _SceneComponentInitialization: (scene: Scene) => void;
  33703. /**
  33704. * Create a sound and attach it to a scene
  33705. * @param name Name of your sound
  33706. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33707. * @param scene defines the scene the sound belongs to
  33708. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33709. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33710. */
  33711. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33712. /**
  33713. * Release the sound and its associated resources
  33714. */
  33715. dispose(): void;
  33716. /**
  33717. * Gets if the sounds is ready to be played or not.
  33718. * @returns true if ready, otherwise false
  33719. */
  33720. isReady(): boolean;
  33721. private _soundLoaded;
  33722. /**
  33723. * Sets the data of the sound from an audiobuffer
  33724. * @param audioBuffer The audioBuffer containing the data
  33725. */
  33726. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33727. /**
  33728. * Updates the current sounds options such as maxdistance, loop...
  33729. * @param options A JSON object containing values named as the object properties
  33730. */
  33731. updateOptions(options: any): void;
  33732. private _createSpatialParameters;
  33733. private _updateSpatialParameters;
  33734. /**
  33735. * Switch the panning model to HRTF:
  33736. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33738. */
  33739. switchPanningModelToHRTF(): void;
  33740. /**
  33741. * Switch the panning model to Equal Power:
  33742. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33743. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33744. */
  33745. switchPanningModelToEqualPower(): void;
  33746. private _switchPanningModel;
  33747. /**
  33748. * Connect this sound to a sound track audio node like gain...
  33749. * @param soundTrackAudioNode the sound track audio node to connect to
  33750. */
  33751. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33752. /**
  33753. * Transform this sound into a directional source
  33754. * @param coneInnerAngle Size of the inner cone in degree
  33755. * @param coneOuterAngle Size of the outer cone in degree
  33756. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33757. */
  33758. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33759. /**
  33760. * Gets or sets the inner angle for the directional cone.
  33761. */
  33762. /**
  33763. * Gets or sets the inner angle for the directional cone.
  33764. */
  33765. directionalConeInnerAngle: number;
  33766. /**
  33767. * Gets or sets the outer angle for the directional cone.
  33768. */
  33769. /**
  33770. * Gets or sets the outer angle for the directional cone.
  33771. */
  33772. directionalConeOuterAngle: number;
  33773. /**
  33774. * Sets the position of the emitter if spatial sound is enabled
  33775. * @param newPosition Defines the new posisiton
  33776. */
  33777. setPosition(newPosition: Vector3): void;
  33778. /**
  33779. * Sets the local direction of the emitter if spatial sound is enabled
  33780. * @param newLocalDirection Defines the new local direction
  33781. */
  33782. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33783. private _updateDirection;
  33784. /** @hidden */
  33785. updateDistanceFromListener(): void;
  33786. /**
  33787. * Sets a new custom attenuation function for the sound.
  33788. * @param callback Defines the function used for the attenuation
  33789. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33790. */
  33791. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33792. /**
  33793. * Play the sound
  33794. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33795. * @param offset (optional) Start the sound setting it at a specific time
  33796. */
  33797. play(time?: number, offset?: number): void;
  33798. private _onended;
  33799. /**
  33800. * Stop the sound
  33801. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33802. */
  33803. stop(time?: number): void;
  33804. /**
  33805. * Put the sound in pause
  33806. */
  33807. pause(): void;
  33808. /**
  33809. * Sets a dedicated volume for this sounds
  33810. * @param newVolume Define the new volume of the sound
  33811. * @param time Define in how long the sound should be at this value
  33812. */
  33813. setVolume(newVolume: number, time?: number): void;
  33814. /**
  33815. * Set the sound play back rate
  33816. * @param newPlaybackRate Define the playback rate the sound should be played at
  33817. */
  33818. setPlaybackRate(newPlaybackRate: number): void;
  33819. /**
  33820. * Gets the volume of the sound.
  33821. * @returns the volume of the sound
  33822. */
  33823. getVolume(): number;
  33824. /**
  33825. * Attach the sound to a dedicated mesh
  33826. * @param transformNode The transform node to connect the sound with
  33827. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33828. */
  33829. attachToMesh(transformNode: TransformNode): void;
  33830. /**
  33831. * Detach the sound from the previously attached mesh
  33832. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33833. */
  33834. detachFromMesh(): void;
  33835. private _onRegisterAfterWorldMatrixUpdate;
  33836. /**
  33837. * Clone the current sound in the scene.
  33838. * @returns the new sound clone
  33839. */
  33840. clone(): Nullable<Sound>;
  33841. /**
  33842. * Gets the current underlying audio buffer containing the data
  33843. * @returns the audio buffer
  33844. */
  33845. getAudioBuffer(): Nullable<AudioBuffer>;
  33846. /**
  33847. * Serializes the Sound in a JSON representation
  33848. * @returns the JSON representation of the sound
  33849. */
  33850. serialize(): any;
  33851. /**
  33852. * Parse a JSON representation of a sound to innstantiate in a given scene
  33853. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33854. * @param scene Define the scene the new parsed sound should be created in
  33855. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33856. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33857. * @returns the newly parsed sound
  33858. */
  33859. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33860. }
  33861. }
  33862. declare module "babylonjs/Actions/directAudioActions" {
  33863. import { Action } from "babylonjs/Actions/action";
  33864. import { Condition } from "babylonjs/Actions/condition";
  33865. import { Sound } from "babylonjs/Audio/sound";
  33866. /**
  33867. * This defines an action helpful to play a defined sound on a triggered action.
  33868. */
  33869. export class PlaySoundAction extends Action {
  33870. private _sound;
  33871. /**
  33872. * Instantiate the action
  33873. * @param triggerOptions defines the trigger options
  33874. * @param sound defines the sound to play
  33875. * @param condition defines the trigger related conditions
  33876. */
  33877. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33878. /** @hidden */
  33879. _prepare(): void;
  33880. /**
  33881. * Execute the action and play the sound.
  33882. */
  33883. execute(): void;
  33884. /**
  33885. * Serializes the actions and its related information.
  33886. * @param parent defines the object to serialize in
  33887. * @returns the serialized object
  33888. */
  33889. serialize(parent: any): any;
  33890. }
  33891. /**
  33892. * This defines an action helpful to stop a defined sound on a triggered action.
  33893. */
  33894. export class StopSoundAction extends Action {
  33895. private _sound;
  33896. /**
  33897. * Instantiate the action
  33898. * @param triggerOptions defines the trigger options
  33899. * @param sound defines the sound to stop
  33900. * @param condition defines the trigger related conditions
  33901. */
  33902. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33903. /** @hidden */
  33904. _prepare(): void;
  33905. /**
  33906. * Execute the action and stop the sound.
  33907. */
  33908. execute(): void;
  33909. /**
  33910. * Serializes the actions and its related information.
  33911. * @param parent defines the object to serialize in
  33912. * @returns the serialized object
  33913. */
  33914. serialize(parent: any): any;
  33915. }
  33916. }
  33917. declare module "babylonjs/Actions/interpolateValueAction" {
  33918. import { Action } from "babylonjs/Actions/action";
  33919. import { Condition } from "babylonjs/Actions/condition";
  33920. import { Observable } from "babylonjs/Misc/observable";
  33921. /**
  33922. * This defines an action responsible to change the value of a property
  33923. * by interpolating between its current value and the newly set one once triggered.
  33924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33925. */
  33926. export class InterpolateValueAction extends Action {
  33927. /**
  33928. * Defines the path of the property where the value should be interpolated
  33929. */
  33930. propertyPath: string;
  33931. /**
  33932. * Defines the target value at the end of the interpolation.
  33933. */
  33934. value: any;
  33935. /**
  33936. * Defines the time it will take for the property to interpolate to the value.
  33937. */
  33938. duration: number;
  33939. /**
  33940. * Defines if the other scene animations should be stopped when the action has been triggered
  33941. */
  33942. stopOtherAnimations?: boolean;
  33943. /**
  33944. * Defines a callback raised once the interpolation animation has been done.
  33945. */
  33946. onInterpolationDone?: () => void;
  33947. /**
  33948. * Observable triggered once the interpolation animation has been done.
  33949. */
  33950. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33951. private _target;
  33952. private _effectiveTarget;
  33953. private _property;
  33954. /**
  33955. * Instantiate the action
  33956. * @param triggerOptions defines the trigger options
  33957. * @param target defines the object containing the value to interpolate
  33958. * @param propertyPath defines the path to the property in the target object
  33959. * @param value defines the target value at the end of the interpolation
  33960. * @param duration deines the time it will take for the property to interpolate to the value.
  33961. * @param condition defines the trigger related conditions
  33962. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33963. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33964. */
  33965. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33966. /** @hidden */
  33967. _prepare(): void;
  33968. /**
  33969. * Execute the action starts the value interpolation.
  33970. */
  33971. execute(): void;
  33972. /**
  33973. * Serializes the actions and its related information.
  33974. * @param parent defines the object to serialize in
  33975. * @returns the serialized object
  33976. */
  33977. serialize(parent: any): any;
  33978. }
  33979. }
  33980. declare module "babylonjs/Actions/index" {
  33981. export * from "babylonjs/Actions/action";
  33982. export * from "babylonjs/Actions/actionEvent";
  33983. export * from "babylonjs/Actions/actionManager";
  33984. export * from "babylonjs/Actions/condition";
  33985. export * from "babylonjs/Actions/directActions";
  33986. export * from "babylonjs/Actions/directAudioActions";
  33987. export * from "babylonjs/Actions/interpolateValueAction";
  33988. }
  33989. declare module "babylonjs/Animations/index" {
  33990. export * from "babylonjs/Animations/animatable";
  33991. export * from "babylonjs/Animations/animation";
  33992. export * from "babylonjs/Animations/animationGroup";
  33993. export * from "babylonjs/Animations/animationPropertiesOverride";
  33994. export * from "babylonjs/Animations/easing";
  33995. export * from "babylonjs/Animations/runtimeAnimation";
  33996. export * from "babylonjs/Animations/animationEvent";
  33997. export * from "babylonjs/Animations/animationGroup";
  33998. export * from "babylonjs/Animations/animationKey";
  33999. export * from "babylonjs/Animations/animationRange";
  34000. }
  34001. declare module "babylonjs/Audio/soundTrack" {
  34002. import { Sound } from "babylonjs/Audio/sound";
  34003. import { Analyser } from "babylonjs/Audio/analyser";
  34004. import { Scene } from "babylonjs/scene";
  34005. /**
  34006. * Options allowed during the creation of a sound track.
  34007. */
  34008. export interface ISoundTrackOptions {
  34009. /**
  34010. * The volume the sound track should take during creation
  34011. */
  34012. volume?: number;
  34013. /**
  34014. * Define if the sound track is the main sound track of the scene
  34015. */
  34016. mainTrack?: boolean;
  34017. }
  34018. /**
  34019. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34020. * It will be also used in a future release to apply effects on a specific track.
  34021. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34022. */
  34023. export class SoundTrack {
  34024. /**
  34025. * The unique identifier of the sound track in the scene.
  34026. */
  34027. id: number;
  34028. /**
  34029. * The list of sounds included in the sound track.
  34030. */
  34031. soundCollection: Array<Sound>;
  34032. private _outputAudioNode;
  34033. private _scene;
  34034. private _isMainTrack;
  34035. private _connectedAnalyser;
  34036. private _options;
  34037. private _isInitialized;
  34038. /**
  34039. * Creates a new sound track.
  34040. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34041. * @param scene Define the scene the sound track belongs to
  34042. * @param options
  34043. */
  34044. constructor(scene: Scene, options?: ISoundTrackOptions);
  34045. private _initializeSoundTrackAudioGraph;
  34046. /**
  34047. * Release the sound track and its associated resources
  34048. */
  34049. dispose(): void;
  34050. /**
  34051. * Adds a sound to this sound track
  34052. * @param sound define the cound to add
  34053. * @ignoreNaming
  34054. */
  34055. AddSound(sound: Sound): void;
  34056. /**
  34057. * Removes a sound to this sound track
  34058. * @param sound define the cound to remove
  34059. * @ignoreNaming
  34060. */
  34061. RemoveSound(sound: Sound): void;
  34062. /**
  34063. * Set a global volume for the full sound track.
  34064. * @param newVolume Define the new volume of the sound track
  34065. */
  34066. setVolume(newVolume: number): void;
  34067. /**
  34068. * Switch the panning model to HRTF:
  34069. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34070. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34071. */
  34072. switchPanningModelToHRTF(): void;
  34073. /**
  34074. * Switch the panning model to Equal Power:
  34075. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34076. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34077. */
  34078. switchPanningModelToEqualPower(): void;
  34079. /**
  34080. * Connect the sound track to an audio analyser allowing some amazing
  34081. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34082. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34083. * @param analyser The analyser to connect to the engine
  34084. */
  34085. connectToAnalyser(analyser: Analyser): void;
  34086. }
  34087. }
  34088. declare module "babylonjs/Audio/audioSceneComponent" {
  34089. import { Sound } from "babylonjs/Audio/sound";
  34090. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34091. import { Nullable } from "babylonjs/types";
  34092. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34093. import { Scene } from "babylonjs/scene";
  34094. import { AbstractScene } from "babylonjs/abstractScene";
  34095. module "babylonjs/abstractScene" {
  34096. interface AbstractScene {
  34097. /**
  34098. * The list of sounds used in the scene.
  34099. */
  34100. sounds: Nullable<Array<Sound>>;
  34101. }
  34102. }
  34103. module "babylonjs/scene" {
  34104. interface Scene {
  34105. /**
  34106. * @hidden
  34107. * Backing field
  34108. */
  34109. _mainSoundTrack: SoundTrack;
  34110. /**
  34111. * The main sound track played by the scene.
  34112. * It cotains your primary collection of sounds.
  34113. */
  34114. mainSoundTrack: SoundTrack;
  34115. /**
  34116. * The list of sound tracks added to the scene
  34117. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34118. */
  34119. soundTracks: Nullable<Array<SoundTrack>>;
  34120. /**
  34121. * Gets a sound using a given name
  34122. * @param name defines the name to search for
  34123. * @return the found sound or null if not found at all.
  34124. */
  34125. getSoundByName(name: string): Nullable<Sound>;
  34126. /**
  34127. * Gets or sets if audio support is enabled
  34128. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34129. */
  34130. audioEnabled: boolean;
  34131. /**
  34132. * Gets or sets if audio will be output to headphones
  34133. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34134. */
  34135. headphone: boolean;
  34136. }
  34137. }
  34138. /**
  34139. * Defines the sound scene component responsible to manage any sounds
  34140. * in a given scene.
  34141. */
  34142. export class AudioSceneComponent implements ISceneSerializableComponent {
  34143. /**
  34144. * The component name helpfull to identify the component in the list of scene components.
  34145. */
  34146. readonly name: string;
  34147. /**
  34148. * The scene the component belongs to.
  34149. */
  34150. scene: Scene;
  34151. private _audioEnabled;
  34152. /**
  34153. * Gets whether audio is enabled or not.
  34154. * Please use related enable/disable method to switch state.
  34155. */
  34156. readonly audioEnabled: boolean;
  34157. private _headphone;
  34158. /**
  34159. * Gets whether audio is outputing to headphone or not.
  34160. * Please use the according Switch methods to change output.
  34161. */
  34162. readonly headphone: boolean;
  34163. /**
  34164. * Creates a new instance of the component for the given scene
  34165. * @param scene Defines the scene to register the component in
  34166. */
  34167. constructor(scene: Scene);
  34168. /**
  34169. * Registers the component in a given scene
  34170. */
  34171. register(): void;
  34172. /**
  34173. * Rebuilds the elements related to this component in case of
  34174. * context lost for instance.
  34175. */
  34176. rebuild(): void;
  34177. /**
  34178. * Serializes the component data to the specified json object
  34179. * @param serializationObject The object to serialize to
  34180. */
  34181. serialize(serializationObject: any): void;
  34182. /**
  34183. * Adds all the element from the container to the scene
  34184. * @param container the container holding the elements
  34185. */
  34186. addFromContainer(container: AbstractScene): void;
  34187. /**
  34188. * Removes all the elements in the container from the scene
  34189. * @param container contains the elements to remove
  34190. */
  34191. removeFromContainer(container: AbstractScene): void;
  34192. /**
  34193. * Disposes the component and the associated ressources.
  34194. */
  34195. dispose(): void;
  34196. /**
  34197. * Disables audio in the associated scene.
  34198. */
  34199. disableAudio(): void;
  34200. /**
  34201. * Enables audio in the associated scene.
  34202. */
  34203. enableAudio(): void;
  34204. /**
  34205. * Switch audio to headphone output.
  34206. */
  34207. switchAudioModeForHeadphones(): void;
  34208. /**
  34209. * Switch audio to normal speakers.
  34210. */
  34211. switchAudioModeForNormalSpeakers(): void;
  34212. private _afterRender;
  34213. }
  34214. }
  34215. declare module "babylonjs/Audio/weightedsound" {
  34216. import { Sound } from "babylonjs/Audio/sound";
  34217. /**
  34218. * Wraps one or more Sound objects and selects one with random weight for playback.
  34219. */
  34220. export class WeightedSound {
  34221. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34222. loop: boolean;
  34223. private _coneInnerAngle;
  34224. private _coneOuterAngle;
  34225. private _volume;
  34226. /** A Sound is currently playing. */
  34227. isPlaying: boolean;
  34228. /** A Sound is currently paused. */
  34229. isPaused: boolean;
  34230. private _sounds;
  34231. private _weights;
  34232. private _currentIndex?;
  34233. /**
  34234. * Creates a new WeightedSound from the list of sounds given.
  34235. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34236. * @param sounds Array of Sounds that will be selected from.
  34237. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34238. */
  34239. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34240. /**
  34241. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34242. */
  34243. /**
  34244. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34245. */
  34246. directionalConeInnerAngle: number;
  34247. /**
  34248. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34249. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34250. */
  34251. /**
  34252. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34253. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34254. */
  34255. directionalConeOuterAngle: number;
  34256. /**
  34257. * Playback volume.
  34258. */
  34259. /**
  34260. * Playback volume.
  34261. */
  34262. volume: number;
  34263. private _onended;
  34264. /**
  34265. * Suspend playback
  34266. */
  34267. pause(): void;
  34268. /**
  34269. * Stop playback
  34270. */
  34271. stop(): void;
  34272. /**
  34273. * Start playback.
  34274. * @param startOffset Position the clip head at a specific time in seconds.
  34275. */
  34276. play(startOffset?: number): void;
  34277. }
  34278. }
  34279. declare module "babylonjs/Audio/index" {
  34280. export * from "babylonjs/Audio/analyser";
  34281. export * from "babylonjs/Audio/audioEngine";
  34282. export * from "babylonjs/Audio/audioSceneComponent";
  34283. export * from "babylonjs/Audio/sound";
  34284. export * from "babylonjs/Audio/soundTrack";
  34285. export * from "babylonjs/Audio/weightedsound";
  34286. }
  34287. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34288. import { Behavior } from "babylonjs/Behaviors/behavior";
  34289. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34290. import { BackEase } from "babylonjs/Animations/easing";
  34291. /**
  34292. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34293. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34294. */
  34295. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34296. /**
  34297. * Gets the name of the behavior.
  34298. */
  34299. readonly name: string;
  34300. /**
  34301. * The easing function used by animations
  34302. */
  34303. static EasingFunction: BackEase;
  34304. /**
  34305. * The easing mode used by animations
  34306. */
  34307. static EasingMode: number;
  34308. /**
  34309. * The duration of the animation, in milliseconds
  34310. */
  34311. transitionDuration: number;
  34312. /**
  34313. * Length of the distance animated by the transition when lower radius is reached
  34314. */
  34315. lowerRadiusTransitionRange: number;
  34316. /**
  34317. * Length of the distance animated by the transition when upper radius is reached
  34318. */
  34319. upperRadiusTransitionRange: number;
  34320. private _autoTransitionRange;
  34321. /**
  34322. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34323. */
  34324. /**
  34325. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34326. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34327. */
  34328. autoTransitionRange: boolean;
  34329. private _attachedCamera;
  34330. private _onAfterCheckInputsObserver;
  34331. private _onMeshTargetChangedObserver;
  34332. /**
  34333. * Initializes the behavior.
  34334. */
  34335. init(): void;
  34336. /**
  34337. * Attaches the behavior to its arc rotate camera.
  34338. * @param camera Defines the camera to attach the behavior to
  34339. */
  34340. attach(camera: ArcRotateCamera): void;
  34341. /**
  34342. * Detaches the behavior from its current arc rotate camera.
  34343. */
  34344. detach(): void;
  34345. private _radiusIsAnimating;
  34346. private _radiusBounceTransition;
  34347. private _animatables;
  34348. private _cachedWheelPrecision;
  34349. /**
  34350. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34351. * @param radiusLimit The limit to check against.
  34352. * @return Bool to indicate if at limit.
  34353. */
  34354. private _isRadiusAtLimit;
  34355. /**
  34356. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34357. * @param radiusDelta The delta by which to animate to. Can be negative.
  34358. */
  34359. private _applyBoundRadiusAnimation;
  34360. /**
  34361. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34362. */
  34363. protected _clearAnimationLocks(): void;
  34364. /**
  34365. * Stops and removes all animations that have been applied to the camera
  34366. */
  34367. stopAllAnimations(): void;
  34368. }
  34369. }
  34370. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34371. import { Behavior } from "babylonjs/Behaviors/behavior";
  34372. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34373. import { ExponentialEase } from "babylonjs/Animations/easing";
  34374. import { Nullable } from "babylonjs/types";
  34375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34376. import { Vector3 } from "babylonjs/Maths/math";
  34377. /**
  34378. * 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.
  34379. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34380. */
  34381. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34382. /**
  34383. * Gets the name of the behavior.
  34384. */
  34385. readonly name: string;
  34386. private _mode;
  34387. private _radiusScale;
  34388. private _positionScale;
  34389. private _defaultElevation;
  34390. private _elevationReturnTime;
  34391. private _elevationReturnWaitTime;
  34392. private _zoomStopsAnimation;
  34393. private _framingTime;
  34394. /**
  34395. * The easing function used by animations
  34396. */
  34397. static EasingFunction: ExponentialEase;
  34398. /**
  34399. * The easing mode used by animations
  34400. */
  34401. static EasingMode: number;
  34402. /**
  34403. * Sets the current mode used by the behavior
  34404. */
  34405. /**
  34406. * Gets current mode used by the behavior.
  34407. */
  34408. mode: number;
  34409. /**
  34410. * Sets the scale applied to the radius (1 by default)
  34411. */
  34412. /**
  34413. * Gets the scale applied to the radius
  34414. */
  34415. radiusScale: number;
  34416. /**
  34417. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34418. */
  34419. /**
  34420. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34421. */
  34422. positionScale: number;
  34423. /**
  34424. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34425. * behaviour is triggered, in radians.
  34426. */
  34427. /**
  34428. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34429. * behaviour is triggered, in radians.
  34430. */
  34431. defaultElevation: number;
  34432. /**
  34433. * Sets the time (in milliseconds) taken to return to the default beta position.
  34434. * Negative value indicates camera should not return to default.
  34435. */
  34436. /**
  34437. * Gets the time (in milliseconds) taken to return to the default beta position.
  34438. * Negative value indicates camera should not return to default.
  34439. */
  34440. elevationReturnTime: number;
  34441. /**
  34442. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34443. */
  34444. /**
  34445. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34446. */
  34447. elevationReturnWaitTime: number;
  34448. /**
  34449. * Sets the flag that indicates if user zooming should stop animation.
  34450. */
  34451. /**
  34452. * Gets the flag that indicates if user zooming should stop animation.
  34453. */
  34454. zoomStopsAnimation: boolean;
  34455. /**
  34456. * Sets the transition time when framing the mesh, in milliseconds
  34457. */
  34458. /**
  34459. * Gets the transition time when framing the mesh, in milliseconds
  34460. */
  34461. framingTime: number;
  34462. /**
  34463. * Define if the behavior should automatically change the configured
  34464. * camera limits and sensibilities.
  34465. */
  34466. autoCorrectCameraLimitsAndSensibility: boolean;
  34467. private _onPrePointerObservableObserver;
  34468. private _onAfterCheckInputsObserver;
  34469. private _onMeshTargetChangedObserver;
  34470. private _attachedCamera;
  34471. private _isPointerDown;
  34472. private _lastInteractionTime;
  34473. /**
  34474. * Initializes the behavior.
  34475. */
  34476. init(): void;
  34477. /**
  34478. * Attaches the behavior to its arc rotate camera.
  34479. * @param camera Defines the camera to attach the behavior to
  34480. */
  34481. attach(camera: ArcRotateCamera): void;
  34482. /**
  34483. * Detaches the behavior from its current arc rotate camera.
  34484. */
  34485. detach(): void;
  34486. private _animatables;
  34487. private _betaIsAnimating;
  34488. private _betaTransition;
  34489. private _radiusTransition;
  34490. private _vectorTransition;
  34491. /**
  34492. * Targets the given mesh and updates zoom level accordingly.
  34493. * @param mesh The mesh to target.
  34494. * @param radius Optional. If a cached radius position already exists, overrides default.
  34495. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34496. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34497. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34498. */
  34499. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34500. /**
  34501. * Targets the given mesh with its children and updates zoom level accordingly.
  34502. * @param mesh The mesh to target.
  34503. * @param radius Optional. If a cached radius position already exists, overrides default.
  34504. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34505. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34506. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34507. */
  34508. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34509. /**
  34510. * Targets the given meshes with their children and updates zoom level accordingly.
  34511. * @param meshes The mesh to target.
  34512. * @param radius Optional. If a cached radius position already exists, overrides default.
  34513. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34514. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34515. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34516. */
  34517. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34518. /**
  34519. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34520. * @param minimumWorld Determines the smaller position of the bounding box extend
  34521. * @param maximumWorld Determines the bigger position of the bounding box extend
  34522. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34523. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34524. */
  34525. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34526. /**
  34527. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34528. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34529. * frustum width.
  34530. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34531. * to fully enclose the mesh in the viewing frustum.
  34532. */
  34533. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34534. /**
  34535. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34536. * is automatically returned to its default position (expected to be above ground plane).
  34537. */
  34538. private _maintainCameraAboveGround;
  34539. /**
  34540. * Returns the frustum slope based on the canvas ratio and camera FOV
  34541. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34542. */
  34543. private _getFrustumSlope;
  34544. /**
  34545. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34546. */
  34547. private _clearAnimationLocks;
  34548. /**
  34549. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34550. */
  34551. private _applyUserInteraction;
  34552. /**
  34553. * Stops and removes all animations that have been applied to the camera
  34554. */
  34555. stopAllAnimations(): void;
  34556. /**
  34557. * Gets a value indicating if the user is moving the camera
  34558. */
  34559. readonly isUserIsMoving: boolean;
  34560. /**
  34561. * The camera can move all the way towards the mesh.
  34562. */
  34563. static IgnoreBoundsSizeMode: number;
  34564. /**
  34565. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34566. */
  34567. static FitFrustumSidesMode: number;
  34568. }
  34569. }
  34570. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34571. import { Nullable } from "babylonjs/types";
  34572. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34573. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34574. /**
  34575. * Manage the pointers inputs to control an arc rotate camera.
  34576. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34577. */
  34578. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  34579. /**
  34580. * Defines the camera the input is attached to.
  34581. */
  34582. camera: ArcRotateCamera;
  34583. /**
  34584. * Defines the buttons associated with the input to handle camera move.
  34585. */
  34586. buttons: number[];
  34587. /**
  34588. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34589. */
  34590. angularSensibilityX: number;
  34591. /**
  34592. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34593. */
  34594. angularSensibilityY: number;
  34595. /**
  34596. * Defines the pointer pinch precision or how fast is the camera zooming.
  34597. */
  34598. pinchPrecision: number;
  34599. /**
  34600. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  34601. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34602. */
  34603. pinchDeltaPercentage: number;
  34604. /**
  34605. * Defines the pointer panning sensibility or how fast is the camera moving.
  34606. */
  34607. panningSensibility: number;
  34608. /**
  34609. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34610. */
  34611. multiTouchPanning: boolean;
  34612. /**
  34613. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  34614. */
  34615. multiTouchPanAndZoom: boolean;
  34616. /**
  34617. * Revers pinch action direction.
  34618. */
  34619. pinchInwards: boolean;
  34620. private _isPanClick;
  34621. private _pointerInput;
  34622. private _observer;
  34623. private _onMouseMove;
  34624. private _onGestureStart;
  34625. private _onGesture;
  34626. private _MSGestureHandler;
  34627. private _onLostFocus;
  34628. private _onContextMenu;
  34629. /**
  34630. * Attach the input controls to a specific dom element to get the input from.
  34631. * @param element Defines the element the controls should be listened from
  34632. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34633. */
  34634. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34635. /**
  34636. * Detach the current controls from the specified dom element.
  34637. * @param element Defines the element to stop listening the inputs from
  34638. */
  34639. detachControl(element: Nullable<HTMLElement>): void;
  34640. /**
  34641. * Gets the class name of the current intput.
  34642. * @returns the class name
  34643. */
  34644. getClassName(): string;
  34645. /**
  34646. * Get the friendly name associated with the input class.
  34647. * @returns the input friendly name
  34648. */
  34649. getSimpleName(): string;
  34650. }
  34651. }
  34652. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  34653. import { Nullable } from "babylonjs/types";
  34654. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34655. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34656. /**
  34657. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34658. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34659. */
  34660. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34661. /**
  34662. * Defines the camera the input is attached to.
  34663. */
  34664. camera: ArcRotateCamera;
  34665. /**
  34666. * Defines the list of key codes associated with the up action (increase alpha)
  34667. */
  34668. keysUp: number[];
  34669. /**
  34670. * Defines the list of key codes associated with the down action (decrease alpha)
  34671. */
  34672. keysDown: number[];
  34673. /**
  34674. * Defines the list of key codes associated with the left action (increase beta)
  34675. */
  34676. keysLeft: number[];
  34677. /**
  34678. * Defines the list of key codes associated with the right action (decrease beta)
  34679. */
  34680. keysRight: number[];
  34681. /**
  34682. * Defines the list of key codes associated with the reset action.
  34683. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34684. */
  34685. keysReset: number[];
  34686. /**
  34687. * Defines the panning sensibility of the inputs.
  34688. * (How fast is the camera paning)
  34689. */
  34690. panningSensibility: number;
  34691. /**
  34692. * Defines the zooming sensibility of the inputs.
  34693. * (How fast is the camera zooming)
  34694. */
  34695. zoomingSensibility: number;
  34696. /**
  34697. * Defines wether maintaining the alt key down switch the movement mode from
  34698. * orientation to zoom.
  34699. */
  34700. useAltToZoom: boolean;
  34701. /**
  34702. * Rotation speed of the camera
  34703. */
  34704. angularSpeed: number;
  34705. private _keys;
  34706. private _ctrlPressed;
  34707. private _altPressed;
  34708. private _onCanvasBlurObserver;
  34709. private _onKeyboardObserver;
  34710. private _engine;
  34711. private _scene;
  34712. /**
  34713. * Attach the input controls to a specific dom element to get the input from.
  34714. * @param element Defines the element the controls should be listened from
  34715. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34716. */
  34717. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34718. /**
  34719. * Detach the current controls from the specified dom element.
  34720. * @param element Defines the element to stop listening the inputs from
  34721. */
  34722. detachControl(element: Nullable<HTMLElement>): void;
  34723. /**
  34724. * Update the current camera state depending on the inputs that have been used this frame.
  34725. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34726. */
  34727. checkInputs(): void;
  34728. /**
  34729. * Gets the class name of the current intput.
  34730. * @returns the class name
  34731. */
  34732. getClassName(): string;
  34733. /**
  34734. * Get the friendly name associated with the input class.
  34735. * @returns the input friendly name
  34736. */
  34737. getSimpleName(): string;
  34738. }
  34739. }
  34740. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  34741. import { Nullable } from "babylonjs/types";
  34742. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34743. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34744. /**
  34745. * Manage the mouse wheel inputs to control an arc rotate camera.
  34746. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34747. */
  34748. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34749. /**
  34750. * Defines the camera the input is attached to.
  34751. */
  34752. camera: ArcRotateCamera;
  34753. /**
  34754. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34755. */
  34756. wheelPrecision: number;
  34757. /**
  34758. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34759. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34760. */
  34761. wheelDeltaPercentage: number;
  34762. private _wheel;
  34763. private _observer;
  34764. /**
  34765. * Attach the input controls to a specific dom element to get the input from.
  34766. * @param element Defines the element the controls should be listened from
  34767. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34768. */
  34769. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34770. /**
  34771. * Detach the current controls from the specified dom element.
  34772. * @param element Defines the element to stop listening the inputs from
  34773. */
  34774. detachControl(element: Nullable<HTMLElement>): void;
  34775. /**
  34776. * Gets the class name of the current intput.
  34777. * @returns the class name
  34778. */
  34779. getClassName(): string;
  34780. /**
  34781. * Get the friendly name associated with the input class.
  34782. * @returns the input friendly name
  34783. */
  34784. getSimpleName(): string;
  34785. }
  34786. }
  34787. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  34788. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34789. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  34790. /**
  34791. * Default Inputs manager for the ArcRotateCamera.
  34792. * It groups all the default supported inputs for ease of use.
  34793. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34794. */
  34795. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34796. /**
  34797. * Instantiates a new ArcRotateCameraInputsManager.
  34798. * @param camera Defines the camera the inputs belong to
  34799. */
  34800. constructor(camera: ArcRotateCamera);
  34801. /**
  34802. * Add mouse wheel input support to the input manager.
  34803. * @returns the current input manager
  34804. */
  34805. addMouseWheel(): ArcRotateCameraInputsManager;
  34806. /**
  34807. * Add pointers input support to the input manager.
  34808. * @returns the current input manager
  34809. */
  34810. addPointers(): ArcRotateCameraInputsManager;
  34811. /**
  34812. * Add keyboard input support to the input manager.
  34813. * @returns the current input manager
  34814. */
  34815. addKeyboard(): ArcRotateCameraInputsManager;
  34816. }
  34817. }
  34818. declare module "babylonjs/Cameras/arcRotateCamera" {
  34819. import { Observable } from "babylonjs/Misc/observable";
  34820. import { Nullable } from "babylonjs/types";
  34821. import { Scene } from "babylonjs/scene";
  34822. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  34823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34824. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  34825. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  34826. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  34827. import { Camera } from "babylonjs/Cameras/camera";
  34828. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  34829. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  34830. import { Collider } from "babylonjs/Collisions/collider";
  34831. /**
  34832. * This represents an orbital type of camera.
  34833. *
  34834. * 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.
  34835. * 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.
  34836. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34837. */
  34838. export class ArcRotateCamera extends TargetCamera {
  34839. /**
  34840. * Defines the rotation angle of the camera along the longitudinal axis.
  34841. */
  34842. alpha: number;
  34843. /**
  34844. * Defines the rotation angle of the camera along the latitudinal axis.
  34845. */
  34846. beta: number;
  34847. /**
  34848. * Defines the radius of the camera from it s target point.
  34849. */
  34850. radius: number;
  34851. protected _target: Vector3;
  34852. protected _targetHost: Nullable<AbstractMesh>;
  34853. /**
  34854. * Defines the target point of the camera.
  34855. * The camera looks towards it form the radius distance.
  34856. */
  34857. target: Vector3;
  34858. /**
  34859. * Current inertia value on the longitudinal axis.
  34860. * The bigger this number the longer it will take for the camera to stop.
  34861. */
  34862. inertialAlphaOffset: number;
  34863. /**
  34864. * Current inertia value on the latitudinal axis.
  34865. * The bigger this number the longer it will take for the camera to stop.
  34866. */
  34867. inertialBetaOffset: number;
  34868. /**
  34869. * Current inertia value on the radius axis.
  34870. * The bigger this number the longer it will take for the camera to stop.
  34871. */
  34872. inertialRadiusOffset: number;
  34873. /**
  34874. * Minimum allowed angle on the longitudinal axis.
  34875. * This can help limiting how the Camera is able to move in the scene.
  34876. */
  34877. lowerAlphaLimit: Nullable<number>;
  34878. /**
  34879. * Maximum allowed angle on the longitudinal axis.
  34880. * This can help limiting how the Camera is able to move in the scene.
  34881. */
  34882. upperAlphaLimit: Nullable<number>;
  34883. /**
  34884. * Minimum allowed angle on the latitudinal axis.
  34885. * This can help limiting how the Camera is able to move in the scene.
  34886. */
  34887. lowerBetaLimit: number;
  34888. /**
  34889. * Maximum allowed angle on the latitudinal axis.
  34890. * This can help limiting how the Camera is able to move in the scene.
  34891. */
  34892. upperBetaLimit: number;
  34893. /**
  34894. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34895. * This can help limiting how the Camera is able to move in the scene.
  34896. */
  34897. lowerRadiusLimit: Nullable<number>;
  34898. /**
  34899. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34900. * This can help limiting how the Camera is able to move in the scene.
  34901. */
  34902. upperRadiusLimit: Nullable<number>;
  34903. /**
  34904. * Defines the current inertia value used during panning of the camera along the X axis.
  34905. */
  34906. inertialPanningX: number;
  34907. /**
  34908. * Defines the current inertia value used during panning of the camera along the Y axis.
  34909. */
  34910. inertialPanningY: number;
  34911. /**
  34912. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34913. * Basically if your fingers moves away from more than this distance you will be considered
  34914. * in pinch mode.
  34915. */
  34916. pinchToPanMaxDistance: number;
  34917. /**
  34918. * Defines the maximum distance the camera can pan.
  34919. * This could help keeping the cammera always in your scene.
  34920. */
  34921. panningDistanceLimit: Nullable<number>;
  34922. /**
  34923. * Defines the target of the camera before paning.
  34924. */
  34925. panningOriginTarget: Vector3;
  34926. /**
  34927. * Defines the value of the inertia used during panning.
  34928. * 0 would mean stop inertia and one would mean no decelleration at all.
  34929. */
  34930. panningInertia: number;
  34931. /**
  34932. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34933. */
  34934. angularSensibilityX: number;
  34935. /**
  34936. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34937. */
  34938. angularSensibilityY: number;
  34939. /**
  34940. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34941. */
  34942. pinchPrecision: number;
  34943. /**
  34944. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34945. * It will be used instead of pinchDeltaPrecision if different from 0.
  34946. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34947. */
  34948. pinchDeltaPercentage: number;
  34949. /**
  34950. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34951. */
  34952. panningSensibility: number;
  34953. /**
  34954. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34955. */
  34956. keysUp: number[];
  34957. /**
  34958. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34959. */
  34960. keysDown: number[];
  34961. /**
  34962. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34963. */
  34964. keysLeft: number[];
  34965. /**
  34966. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34967. */
  34968. keysRight: number[];
  34969. /**
  34970. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34971. */
  34972. wheelPrecision: number;
  34973. /**
  34974. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34975. * It will be used instead of pinchDeltaPrecision if different from 0.
  34976. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34977. */
  34978. wheelDeltaPercentage: number;
  34979. /**
  34980. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34981. */
  34982. zoomOnFactor: number;
  34983. /**
  34984. * Defines a screen offset for the camera position.
  34985. */
  34986. targetScreenOffset: Vector2;
  34987. /**
  34988. * Allows the camera to be completely reversed.
  34989. * If false the camera can not arrive upside down.
  34990. */
  34991. allowUpsideDown: boolean;
  34992. /**
  34993. * Define if double tap/click is used to restore the previously saved state of the camera.
  34994. */
  34995. useInputToRestoreState: boolean;
  34996. /** @hidden */
  34997. _viewMatrix: Matrix;
  34998. /** @hidden */
  34999. _useCtrlForPanning: boolean;
  35000. /** @hidden */
  35001. _panningMouseButton: number;
  35002. /**
  35003. * Defines the input associated to the camera.
  35004. */
  35005. inputs: ArcRotateCameraInputsManager;
  35006. /** @hidden */
  35007. _reset: () => void;
  35008. /**
  35009. * Defines the allowed panning axis.
  35010. */
  35011. panningAxis: Vector3;
  35012. protected _localDirection: Vector3;
  35013. protected _transformedDirection: Vector3;
  35014. private _bouncingBehavior;
  35015. /**
  35016. * Gets the bouncing behavior of the camera if it has been enabled.
  35017. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35018. */
  35019. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35020. /**
  35021. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35022. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35023. */
  35024. useBouncingBehavior: boolean;
  35025. private _framingBehavior;
  35026. /**
  35027. * Gets the framing behavior of the camera if it has been enabled.
  35028. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35029. */
  35030. readonly framingBehavior: Nullable<FramingBehavior>;
  35031. /**
  35032. * Defines if the framing behavior of the camera is enabled on the camera.
  35033. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35034. */
  35035. useFramingBehavior: boolean;
  35036. private _autoRotationBehavior;
  35037. /**
  35038. * Gets the auto rotation behavior of the camera if it has been enabled.
  35039. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35040. */
  35041. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35042. /**
  35043. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35044. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35045. */
  35046. useAutoRotationBehavior: boolean;
  35047. /**
  35048. * Observable triggered when the mesh target has been changed on the camera.
  35049. */
  35050. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35051. /**
  35052. * Event raised when the camera is colliding with a mesh.
  35053. */
  35054. onCollide: (collidedMesh: AbstractMesh) => void;
  35055. /**
  35056. * Defines whether the camera should check collision with the objects oh the scene.
  35057. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35058. */
  35059. checkCollisions: boolean;
  35060. /**
  35061. * Defines the collision radius of the camera.
  35062. * This simulates a sphere around the camera.
  35063. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35064. */
  35065. collisionRadius: Vector3;
  35066. protected _collider: Collider;
  35067. protected _previousPosition: Vector3;
  35068. protected _collisionVelocity: Vector3;
  35069. protected _newPosition: Vector3;
  35070. protected _previousAlpha: number;
  35071. protected _previousBeta: number;
  35072. protected _previousRadius: number;
  35073. protected _collisionTriggered: boolean;
  35074. protected _targetBoundingCenter: Nullable<Vector3>;
  35075. private _computationVector;
  35076. private _tempAxisVector;
  35077. private _tempAxisRotationMatrix;
  35078. /**
  35079. * Instantiates a new ArcRotateCamera in a given scene
  35080. * @param name Defines the name of the camera
  35081. * @param alpha Defines the camera rotation along the logitudinal axis
  35082. * @param beta Defines the camera rotation along the latitudinal axis
  35083. * @param radius Defines the camera distance from its target
  35084. * @param target Defines the camera target
  35085. * @param scene Defines the scene the camera belongs to
  35086. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35087. */
  35088. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35089. /** @hidden */
  35090. _initCache(): void;
  35091. /** @hidden */
  35092. _updateCache(ignoreParentClass?: boolean): void;
  35093. protected _getTargetPosition(): Vector3;
  35094. private _storedAlpha;
  35095. private _storedBeta;
  35096. private _storedRadius;
  35097. private _storedTarget;
  35098. /**
  35099. * Stores the current state of the camera (alpha, beta, radius and target)
  35100. * @returns the camera itself
  35101. */
  35102. storeState(): Camera;
  35103. /**
  35104. * @hidden
  35105. * Restored camera state. You must call storeState() first
  35106. */
  35107. _restoreStateValues(): boolean;
  35108. /** @hidden */
  35109. _isSynchronizedViewMatrix(): boolean;
  35110. /**
  35111. * Attached controls to the current camera.
  35112. * @param element Defines the element the controls should be listened from
  35113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35114. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35115. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35116. */
  35117. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35118. /**
  35119. * Detach the current controls from the camera.
  35120. * The camera will stop reacting to inputs.
  35121. * @param element Defines the element to stop listening the inputs from
  35122. */
  35123. detachControl(element: HTMLElement): void;
  35124. /** @hidden */
  35125. _checkInputs(): void;
  35126. protected _checkLimits(): void;
  35127. /**
  35128. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  35129. */
  35130. rebuildAnglesAndRadius(): void;
  35131. /**
  35132. * Use a position to define the current camera related information like aplha, beta and radius
  35133. * @param position Defines the position to set the camera at
  35134. */
  35135. setPosition(position: Vector3): void;
  35136. /**
  35137. * Defines the target the camera should look at.
  35138. * This will automatically adapt alpha beta and radius to fit within the new target.
  35139. * @param target Defines the new target as a Vector or a mesh
  35140. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35141. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35142. */
  35143. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35144. /** @hidden */
  35145. _getViewMatrix(): Matrix;
  35146. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35147. /**
  35148. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35149. * @param meshes Defines the mesh to zoom on
  35150. * @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)
  35151. */
  35152. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35153. /**
  35154. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35155. * The target will be changed but the radius
  35156. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35157. * @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)
  35158. */
  35159. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35160. min: Vector3;
  35161. max: Vector3;
  35162. distance: number;
  35163. }, doNotUpdateMaxZ?: boolean): void;
  35164. /**
  35165. * @override
  35166. * Override Camera.createRigCamera
  35167. */
  35168. createRigCamera(name: string, cameraIndex: number): Camera;
  35169. /**
  35170. * @hidden
  35171. * @override
  35172. * Override Camera._updateRigCameras
  35173. */
  35174. _updateRigCameras(): void;
  35175. /**
  35176. * Destroy the camera and release the current resources hold by it.
  35177. */
  35178. dispose(): void;
  35179. /**
  35180. * Gets the current object class name.
  35181. * @return the class name
  35182. */
  35183. getClassName(): string;
  35184. }
  35185. }
  35186. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35187. import { Behavior } from "babylonjs/Behaviors/behavior";
  35188. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35189. /**
  35190. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35191. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35192. */
  35193. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35194. /**
  35195. * Gets the name of the behavior.
  35196. */
  35197. readonly name: string;
  35198. private _zoomStopsAnimation;
  35199. private _idleRotationSpeed;
  35200. private _idleRotationWaitTime;
  35201. private _idleRotationSpinupTime;
  35202. /**
  35203. * Sets the flag that indicates if user zooming should stop animation.
  35204. */
  35205. /**
  35206. * Gets the flag that indicates if user zooming should stop animation.
  35207. */
  35208. zoomStopsAnimation: boolean;
  35209. /**
  35210. * Sets the default speed at which the camera rotates around the model.
  35211. */
  35212. /**
  35213. * Gets the default speed at which the camera rotates around the model.
  35214. */
  35215. idleRotationSpeed: number;
  35216. /**
  35217. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35218. */
  35219. /**
  35220. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35221. */
  35222. idleRotationWaitTime: number;
  35223. /**
  35224. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35225. */
  35226. /**
  35227. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35228. */
  35229. idleRotationSpinupTime: number;
  35230. /**
  35231. * Gets a value indicating if the camera is currently rotating because of this behavior
  35232. */
  35233. readonly rotationInProgress: boolean;
  35234. private _onPrePointerObservableObserver;
  35235. private _onAfterCheckInputsObserver;
  35236. private _attachedCamera;
  35237. private _isPointerDown;
  35238. private _lastFrameTime;
  35239. private _lastInteractionTime;
  35240. private _cameraRotationSpeed;
  35241. /**
  35242. * Initializes the behavior.
  35243. */
  35244. init(): void;
  35245. /**
  35246. * Attaches the behavior to its arc rotate camera.
  35247. * @param camera Defines the camera to attach the behavior to
  35248. */
  35249. attach(camera: ArcRotateCamera): void;
  35250. /**
  35251. * Detaches the behavior from its current arc rotate camera.
  35252. */
  35253. detach(): void;
  35254. /**
  35255. * Returns true if user is scrolling.
  35256. * @return true if user is scrolling.
  35257. */
  35258. private _userIsZooming;
  35259. private _lastFrameRadius;
  35260. private _shouldAnimationStopForInteraction;
  35261. /**
  35262. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35263. */
  35264. private _applyUserInteraction;
  35265. private _userIsMoving;
  35266. }
  35267. }
  35268. declare module "babylonjs/Behaviors/Cameras/index" {
  35269. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35270. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35271. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35272. }
  35273. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35274. import { Mesh } from "babylonjs/Meshes/mesh";
  35275. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35276. import { Behavior } from "babylonjs/Behaviors/behavior";
  35277. /**
  35278. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35279. */
  35280. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35281. private ui;
  35282. /**
  35283. * The name of the behavior
  35284. */
  35285. name: string;
  35286. /**
  35287. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35288. */
  35289. distanceAwayFromFace: number;
  35290. /**
  35291. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35292. */
  35293. distanceAwayFromBottomOfFace: number;
  35294. private _faceVectors;
  35295. private _target;
  35296. private _scene;
  35297. private _onRenderObserver;
  35298. private _tmpMatrix;
  35299. private _tmpVector;
  35300. /**
  35301. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35302. * @param ui The transform node that should be attched to the mesh
  35303. */
  35304. constructor(ui: TransformNode);
  35305. /**
  35306. * Initializes the behavior
  35307. */
  35308. init(): void;
  35309. private _closestFace;
  35310. private _zeroVector;
  35311. private _lookAtTmpMatrix;
  35312. private _lookAtToRef;
  35313. /**
  35314. * Attaches the AttachToBoxBehavior to the passed in mesh
  35315. * @param target The mesh that the specified node will be attached to
  35316. */
  35317. attach(target: Mesh): void;
  35318. /**
  35319. * Detaches the behavior from the mesh
  35320. */
  35321. detach(): void;
  35322. }
  35323. }
  35324. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35325. import { Behavior } from "babylonjs/Behaviors/behavior";
  35326. import { Mesh } from "babylonjs/Meshes/mesh";
  35327. /**
  35328. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35329. */
  35330. export class FadeInOutBehavior implements Behavior<Mesh> {
  35331. /**
  35332. * Time in milliseconds to delay before fading in (Default: 0)
  35333. */
  35334. delay: number;
  35335. /**
  35336. * Time in milliseconds for the mesh to fade in (Default: 300)
  35337. */
  35338. fadeInTime: number;
  35339. private _millisecondsPerFrame;
  35340. private _hovered;
  35341. private _hoverValue;
  35342. private _ownerNode;
  35343. /**
  35344. * Instatiates the FadeInOutBehavior
  35345. */
  35346. constructor();
  35347. /**
  35348. * The name of the behavior
  35349. */
  35350. readonly name: string;
  35351. /**
  35352. * Initializes the behavior
  35353. */
  35354. init(): void;
  35355. /**
  35356. * Attaches the fade behavior on the passed in mesh
  35357. * @param ownerNode The mesh that will be faded in/out once attached
  35358. */
  35359. attach(ownerNode: Mesh): void;
  35360. /**
  35361. * Detaches the behavior from the mesh
  35362. */
  35363. detach(): void;
  35364. /**
  35365. * Triggers the mesh to begin fading in or out
  35366. * @param value if the object should fade in or out (true to fade in)
  35367. */
  35368. fadeIn(value: boolean): void;
  35369. private _update;
  35370. private _setAllVisibility;
  35371. }
  35372. }
  35373. declare module "babylonjs/Misc/pivotTools" {
  35374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35375. /**
  35376. * Class containing a set of static utilities functions for managing Pivots
  35377. * @hidden
  35378. */
  35379. export class PivotTools {
  35380. private static _PivotCached;
  35381. private static _OldPivotPoint;
  35382. private static _PivotTranslation;
  35383. private static _PivotTmpVector;
  35384. /** @hidden */
  35385. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35386. /** @hidden */
  35387. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35388. }
  35389. }
  35390. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35391. import { Scene } from "babylonjs/scene";
  35392. import { Vector4, Plane } from "babylonjs/Maths/math";
  35393. import { Mesh } from "babylonjs/Meshes/mesh";
  35394. /**
  35395. * Class containing static functions to help procedurally build meshes
  35396. */
  35397. export class PlaneBuilder {
  35398. /**
  35399. * Creates a plane mesh
  35400. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35401. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35402. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35404. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35406. * @param name defines the name of the mesh
  35407. * @param options defines the options used to create the mesh
  35408. * @param scene defines the hosting scene
  35409. * @returns the plane mesh
  35410. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35411. */
  35412. static CreatePlane(name: string, options: {
  35413. size?: number;
  35414. width?: number;
  35415. height?: number;
  35416. sideOrientation?: number;
  35417. frontUVs?: Vector4;
  35418. backUVs?: Vector4;
  35419. updatable?: boolean;
  35420. sourcePlane?: Plane;
  35421. }, scene: Scene): Mesh;
  35422. }
  35423. }
  35424. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35425. import { Behavior } from "babylonjs/Behaviors/behavior";
  35426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35427. import { Observable } from "babylonjs/Misc/observable";
  35428. import { Vector3 } from "babylonjs/Maths/math";
  35429. import { Ray } from "babylonjs/Culling/ray";
  35430. import "babylonjs/Meshes/Builders/planeBuilder";
  35431. /**
  35432. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35433. */
  35434. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35435. private static _AnyMouseID;
  35436. private _attachedNode;
  35437. private _dragPlane;
  35438. private _scene;
  35439. private _pointerObserver;
  35440. private _beforeRenderObserver;
  35441. private static _planeScene;
  35442. /**
  35443. * 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)
  35444. */
  35445. maxDragAngle: number;
  35446. /**
  35447. * @hidden
  35448. */
  35449. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35450. /**
  35451. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35452. */
  35453. currentDraggingPointerID: number;
  35454. /**
  35455. * The last position where the pointer hit the drag plane in world space
  35456. */
  35457. lastDragPosition: Vector3;
  35458. /**
  35459. * If the behavior is currently in a dragging state
  35460. */
  35461. dragging: boolean;
  35462. /**
  35463. * 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)
  35464. */
  35465. dragDeltaRatio: number;
  35466. /**
  35467. * If the drag plane orientation should be updated during the dragging (Default: true)
  35468. */
  35469. updateDragPlane: boolean;
  35470. private _debugMode;
  35471. private _moving;
  35472. /**
  35473. * Fires each time the attached mesh is dragged with the pointer
  35474. * * delta between last drag position and current drag position in world space
  35475. * * dragDistance along the drag axis
  35476. * * dragPlaneNormal normal of the current drag plane used during the drag
  35477. * * dragPlanePoint in world space where the drag intersects the drag plane
  35478. */
  35479. onDragObservable: Observable<{
  35480. delta: Vector3;
  35481. dragPlanePoint: Vector3;
  35482. dragPlaneNormal: Vector3;
  35483. dragDistance: number;
  35484. pointerId: number;
  35485. }>;
  35486. /**
  35487. * Fires each time a drag begins (eg. mouse down on mesh)
  35488. */
  35489. onDragStartObservable: Observable<{
  35490. dragPlanePoint: Vector3;
  35491. pointerId: number;
  35492. }>;
  35493. /**
  35494. * Fires each time a drag ends (eg. mouse release after drag)
  35495. */
  35496. onDragEndObservable: Observable<{
  35497. dragPlanePoint: Vector3;
  35498. pointerId: number;
  35499. }>;
  35500. /**
  35501. * If the attached mesh should be moved when dragged
  35502. */
  35503. moveAttached: boolean;
  35504. /**
  35505. * If the drag behavior will react to drag events (Default: true)
  35506. */
  35507. enabled: boolean;
  35508. /**
  35509. * If camera controls should be detached during the drag
  35510. */
  35511. detachCameraControls: boolean;
  35512. /**
  35513. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35514. */
  35515. useObjectOrienationForDragging: boolean;
  35516. private _options;
  35517. /**
  35518. * Creates a pointer drag behavior that can be attached to a mesh
  35519. * @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)
  35520. */
  35521. constructor(options?: {
  35522. dragAxis?: Vector3;
  35523. dragPlaneNormal?: Vector3;
  35524. });
  35525. /**
  35526. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35527. */
  35528. validateDrag: (targetPosition: Vector3) => boolean;
  35529. /**
  35530. * The name of the behavior
  35531. */
  35532. readonly name: string;
  35533. /**
  35534. * Initializes the behavior
  35535. */
  35536. init(): void;
  35537. private _tmpVector;
  35538. private _alternatePickedPoint;
  35539. private _worldDragAxis;
  35540. private _targetPosition;
  35541. private _attachedElement;
  35542. /**
  35543. * Attaches the drag behavior the passed in mesh
  35544. * @param ownerNode The mesh that will be dragged around once attached
  35545. */
  35546. attach(ownerNode: AbstractMesh): void;
  35547. /**
  35548. * Force relase the drag action by code.
  35549. */
  35550. releaseDrag(): void;
  35551. private _startDragRay;
  35552. private _lastPointerRay;
  35553. /**
  35554. * Simulates the start of a pointer drag event on the behavior
  35555. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35556. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35557. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35558. */
  35559. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35560. private _startDrag;
  35561. private _dragDelta;
  35562. private _moveDrag;
  35563. private _pickWithRayOnDragPlane;
  35564. private _pointA;
  35565. private _pointB;
  35566. private _pointC;
  35567. private _lineA;
  35568. private _lineB;
  35569. private _localAxis;
  35570. private _lookAt;
  35571. private _updateDragPlanePosition;
  35572. /**
  35573. * Detaches the behavior from the mesh
  35574. */
  35575. detach(): void;
  35576. }
  35577. }
  35578. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35579. import { Mesh } from "babylonjs/Meshes/mesh";
  35580. import { Behavior } from "babylonjs/Behaviors/behavior";
  35581. /**
  35582. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35583. */
  35584. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35585. private _dragBehaviorA;
  35586. private _dragBehaviorB;
  35587. private _startDistance;
  35588. private _initialScale;
  35589. private _targetScale;
  35590. private _ownerNode;
  35591. private _sceneRenderObserver;
  35592. /**
  35593. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35594. */
  35595. constructor();
  35596. /**
  35597. * The name of the behavior
  35598. */
  35599. readonly name: string;
  35600. /**
  35601. * Initializes the behavior
  35602. */
  35603. init(): void;
  35604. private _getCurrentDistance;
  35605. /**
  35606. * Attaches the scale behavior the passed in mesh
  35607. * @param ownerNode The mesh that will be scaled around once attached
  35608. */
  35609. attach(ownerNode: Mesh): void;
  35610. /**
  35611. * Detaches the behavior from the mesh
  35612. */
  35613. detach(): void;
  35614. }
  35615. }
  35616. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  35617. import { Behavior } from "babylonjs/Behaviors/behavior";
  35618. import { Mesh } from "babylonjs/Meshes/mesh";
  35619. import { Observable } from "babylonjs/Misc/observable";
  35620. /**
  35621. * 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
  35622. */
  35623. export class SixDofDragBehavior implements Behavior<Mesh> {
  35624. private static _virtualScene;
  35625. private _ownerNode;
  35626. private _sceneRenderObserver;
  35627. private _scene;
  35628. private _targetPosition;
  35629. private _virtualOriginMesh;
  35630. private _virtualDragMesh;
  35631. private _pointerObserver;
  35632. private _moving;
  35633. private _startingOrientation;
  35634. /**
  35635. * 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)
  35636. */
  35637. private zDragFactor;
  35638. /**
  35639. * If the object should rotate to face the drag origin
  35640. */
  35641. rotateDraggedObject: boolean;
  35642. /**
  35643. * If the behavior is currently in a dragging state
  35644. */
  35645. dragging: boolean;
  35646. /**
  35647. * 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)
  35648. */
  35649. dragDeltaRatio: number;
  35650. /**
  35651. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35652. */
  35653. currentDraggingPointerID: number;
  35654. /**
  35655. * If camera controls should be detached during the drag
  35656. */
  35657. detachCameraControls: boolean;
  35658. /**
  35659. * Fires each time a drag starts
  35660. */
  35661. onDragStartObservable: Observable<{}>;
  35662. /**
  35663. * Fires each time a drag ends (eg. mouse release after drag)
  35664. */
  35665. onDragEndObservable: Observable<{}>;
  35666. /**
  35667. * 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
  35668. */
  35669. constructor();
  35670. /**
  35671. * The name of the behavior
  35672. */
  35673. readonly name: string;
  35674. /**
  35675. * Initializes the behavior
  35676. */
  35677. init(): void;
  35678. /**
  35679. * Attaches the scale behavior the passed in mesh
  35680. * @param ownerNode The mesh that will be scaled around once attached
  35681. */
  35682. attach(ownerNode: Mesh): void;
  35683. /**
  35684. * Detaches the behavior from the mesh
  35685. */
  35686. detach(): void;
  35687. }
  35688. }
  35689. declare module "babylonjs/Behaviors/Meshes/index" {
  35690. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  35691. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  35692. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  35693. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  35694. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  35695. }
  35696. declare module "babylonjs/Behaviors/index" {
  35697. export * from "babylonjs/Behaviors/behavior";
  35698. export * from "babylonjs/Behaviors/Cameras/index";
  35699. export * from "babylonjs/Behaviors/Meshes/index";
  35700. }
  35701. declare module "babylonjs/Bones/boneIKController" {
  35702. import { Bone } from "babylonjs/Bones/bone";
  35703. import { Vector3 } from "babylonjs/Maths/math";
  35704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35705. import { Nullable } from "babylonjs/types";
  35706. /**
  35707. * Class used to apply inverse kinematics to bones
  35708. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35709. */
  35710. export class BoneIKController {
  35711. private static _tmpVecs;
  35712. private static _tmpQuat;
  35713. private static _tmpMats;
  35714. /**
  35715. * Gets or sets the target mesh
  35716. */
  35717. targetMesh: AbstractMesh;
  35718. /** Gets or sets the mesh used as pole */
  35719. poleTargetMesh: AbstractMesh;
  35720. /**
  35721. * Gets or sets the bone used as pole
  35722. */
  35723. poleTargetBone: Nullable<Bone>;
  35724. /**
  35725. * Gets or sets the target position
  35726. */
  35727. targetPosition: Vector3;
  35728. /**
  35729. * Gets or sets the pole target position
  35730. */
  35731. poleTargetPosition: Vector3;
  35732. /**
  35733. * Gets or sets the pole target local offset
  35734. */
  35735. poleTargetLocalOffset: Vector3;
  35736. /**
  35737. * Gets or sets the pole angle
  35738. */
  35739. poleAngle: number;
  35740. /**
  35741. * Gets or sets the mesh associated with the controller
  35742. */
  35743. mesh: AbstractMesh;
  35744. /**
  35745. * 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)
  35746. */
  35747. slerpAmount: number;
  35748. private _bone1Quat;
  35749. private _bone1Mat;
  35750. private _bone2Ang;
  35751. private _bone1;
  35752. private _bone2;
  35753. private _bone1Length;
  35754. private _bone2Length;
  35755. private _maxAngle;
  35756. private _maxReach;
  35757. private _rightHandedSystem;
  35758. private _bendAxis;
  35759. private _slerping;
  35760. private _adjustRoll;
  35761. /**
  35762. * Gets or sets maximum allowed angle
  35763. */
  35764. maxAngle: number;
  35765. /**
  35766. * Creates a new BoneIKController
  35767. * @param mesh defines the mesh to control
  35768. * @param bone defines the bone to control
  35769. * @param options defines options to set up the controller
  35770. */
  35771. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35772. targetMesh?: AbstractMesh;
  35773. poleTargetMesh?: AbstractMesh;
  35774. poleTargetBone?: Bone;
  35775. poleTargetLocalOffset?: Vector3;
  35776. poleAngle?: number;
  35777. bendAxis?: Vector3;
  35778. maxAngle?: number;
  35779. slerpAmount?: number;
  35780. });
  35781. private _setMaxAngle;
  35782. /**
  35783. * Force the controller to update the bones
  35784. */
  35785. update(): void;
  35786. }
  35787. }
  35788. declare module "babylonjs/Bones/boneLookController" {
  35789. import { Vector3, Space } from "babylonjs/Maths/math";
  35790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35791. import { Bone } from "babylonjs/Bones/bone";
  35792. /**
  35793. * Class used to make a bone look toward a point in space
  35794. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35795. */
  35796. export class BoneLookController {
  35797. private static _tmpVecs;
  35798. private static _tmpQuat;
  35799. private static _tmpMats;
  35800. /**
  35801. * The target Vector3 that the bone will look at
  35802. */
  35803. target: Vector3;
  35804. /**
  35805. * The mesh that the bone is attached to
  35806. */
  35807. mesh: AbstractMesh;
  35808. /**
  35809. * The bone that will be looking to the target
  35810. */
  35811. bone: Bone;
  35812. /**
  35813. * The up axis of the coordinate system that is used when the bone is rotated
  35814. */
  35815. upAxis: Vector3;
  35816. /**
  35817. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35818. */
  35819. upAxisSpace: Space;
  35820. /**
  35821. * Used to make an adjustment to the yaw of the bone
  35822. */
  35823. adjustYaw: number;
  35824. /**
  35825. * Used to make an adjustment to the pitch of the bone
  35826. */
  35827. adjustPitch: number;
  35828. /**
  35829. * Used to make an adjustment to the roll of the bone
  35830. */
  35831. adjustRoll: number;
  35832. /**
  35833. * 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)
  35834. */
  35835. slerpAmount: number;
  35836. private _minYaw;
  35837. private _maxYaw;
  35838. private _minPitch;
  35839. private _maxPitch;
  35840. private _minYawSin;
  35841. private _minYawCos;
  35842. private _maxYawSin;
  35843. private _maxYawCos;
  35844. private _midYawConstraint;
  35845. private _minPitchTan;
  35846. private _maxPitchTan;
  35847. private _boneQuat;
  35848. private _slerping;
  35849. private _transformYawPitch;
  35850. private _transformYawPitchInv;
  35851. private _firstFrameSkipped;
  35852. private _yawRange;
  35853. private _fowardAxis;
  35854. /**
  35855. * Gets or sets the minimum yaw angle that the bone can look to
  35856. */
  35857. minYaw: number;
  35858. /**
  35859. * Gets or sets the maximum yaw angle that the bone can look to
  35860. */
  35861. maxYaw: number;
  35862. /**
  35863. * Gets or sets the minimum pitch angle that the bone can look to
  35864. */
  35865. minPitch: number;
  35866. /**
  35867. * Gets or sets the maximum pitch angle that the bone can look to
  35868. */
  35869. maxPitch: number;
  35870. /**
  35871. * Create a BoneLookController
  35872. * @param mesh the mesh that the bone belongs to
  35873. * @param bone the bone that will be looking to the target
  35874. * @param target the target Vector3 to look at
  35875. * @param options optional settings:
  35876. * * maxYaw: the maximum angle the bone will yaw to
  35877. * * minYaw: the minimum angle the bone will yaw to
  35878. * * maxPitch: the maximum angle the bone will pitch to
  35879. * * minPitch: the minimum angle the bone will yaw to
  35880. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35881. * * upAxis: the up axis of the coordinate system
  35882. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35883. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35884. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35885. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35886. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35887. * * adjustRoll: used to make an adjustment to the roll of the bone
  35888. **/
  35889. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35890. maxYaw?: number;
  35891. minYaw?: number;
  35892. maxPitch?: number;
  35893. minPitch?: number;
  35894. slerpAmount?: number;
  35895. upAxis?: Vector3;
  35896. upAxisSpace?: Space;
  35897. yawAxis?: Vector3;
  35898. pitchAxis?: Vector3;
  35899. adjustYaw?: number;
  35900. adjustPitch?: number;
  35901. adjustRoll?: number;
  35902. });
  35903. /**
  35904. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35905. */
  35906. update(): void;
  35907. private _getAngleDiff;
  35908. private _getAngleBetween;
  35909. private _isAngleBetween;
  35910. }
  35911. }
  35912. declare module "babylonjs/Bones/index" {
  35913. export * from "babylonjs/Bones/bone";
  35914. export * from "babylonjs/Bones/boneIKController";
  35915. export * from "babylonjs/Bones/boneLookController";
  35916. export * from "babylonjs/Bones/skeleton";
  35917. }
  35918. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  35919. import { Nullable } from "babylonjs/types";
  35920. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35921. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35922. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  35923. /**
  35924. * Manage the gamepad inputs to control an arc rotate camera.
  35925. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35926. */
  35927. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35928. /**
  35929. * Defines the camera the input is attached to.
  35930. */
  35931. camera: ArcRotateCamera;
  35932. /**
  35933. * Defines the gamepad the input is gathering event from.
  35934. */
  35935. gamepad: Nullable<Gamepad>;
  35936. /**
  35937. * Defines the gamepad rotation sensiblity.
  35938. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35939. */
  35940. gamepadRotationSensibility: number;
  35941. /**
  35942. * Defines the gamepad move sensiblity.
  35943. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35944. */
  35945. gamepadMoveSensibility: number;
  35946. private _onGamepadConnectedObserver;
  35947. private _onGamepadDisconnectedObserver;
  35948. /**
  35949. * Attach the input controls to a specific dom element to get the input from.
  35950. * @param element Defines the element the controls should be listened from
  35951. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35952. */
  35953. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35954. /**
  35955. * Detach the current controls from the specified dom element.
  35956. * @param element Defines the element to stop listening the inputs from
  35957. */
  35958. detachControl(element: Nullable<HTMLElement>): void;
  35959. /**
  35960. * Update the current camera state depending on the inputs that have been used this frame.
  35961. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35962. */
  35963. checkInputs(): void;
  35964. /**
  35965. * Gets the class name of the current intput.
  35966. * @returns the class name
  35967. */
  35968. getClassName(): string;
  35969. /**
  35970. * Get the friendly name associated with the input class.
  35971. * @returns the input friendly name
  35972. */
  35973. getSimpleName(): string;
  35974. }
  35975. }
  35976. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  35977. import { Nullable } from "babylonjs/types";
  35978. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35979. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35980. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35981. interface ArcRotateCameraInputsManager {
  35982. /**
  35983. * Add orientation input support to the input manager.
  35984. * @returns the current input manager
  35985. */
  35986. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35987. }
  35988. }
  35989. /**
  35990. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35991. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35992. */
  35993. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35994. /**
  35995. * Defines the camera the input is attached to.
  35996. */
  35997. camera: ArcRotateCamera;
  35998. /**
  35999. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36000. */
  36001. alphaCorrection: number;
  36002. /**
  36003. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36004. */
  36005. gammaCorrection: number;
  36006. private _alpha;
  36007. private _gamma;
  36008. private _dirty;
  36009. private _deviceOrientationHandler;
  36010. /**
  36011. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36012. */
  36013. constructor();
  36014. /**
  36015. * Attach the input controls to a specific dom element to get the input from.
  36016. * @param element Defines the element the controls should be listened from
  36017. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36018. */
  36019. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36020. /** @hidden */
  36021. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36022. /**
  36023. * Update the current camera state depending on the inputs that have been used this frame.
  36024. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36025. */
  36026. checkInputs(): void;
  36027. /**
  36028. * Detach the current controls from the specified dom element.
  36029. * @param element Defines the element to stop listening the inputs from
  36030. */
  36031. detachControl(element: Nullable<HTMLElement>): void;
  36032. /**
  36033. * Gets the class name of the current intput.
  36034. * @returns the class name
  36035. */
  36036. getClassName(): string;
  36037. /**
  36038. * Get the friendly name associated with the input class.
  36039. * @returns the input friendly name
  36040. */
  36041. getSimpleName(): string;
  36042. }
  36043. }
  36044. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36045. import { Nullable } from "babylonjs/types";
  36046. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36047. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36048. /**
  36049. * Listen to mouse events to control the camera.
  36050. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36051. */
  36052. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36053. /**
  36054. * Defines the camera the input is attached to.
  36055. */
  36056. camera: FlyCamera;
  36057. /**
  36058. * Defines if touch is enabled. (Default is true.)
  36059. */
  36060. touchEnabled: boolean;
  36061. /**
  36062. * Defines the buttons associated with the input to handle camera rotation.
  36063. */
  36064. buttons: number[];
  36065. /**
  36066. * Assign buttons for Yaw control.
  36067. */
  36068. buttonsYaw: number[];
  36069. /**
  36070. * Assign buttons for Pitch control.
  36071. */
  36072. buttonsPitch: number[];
  36073. /**
  36074. * Assign buttons for Roll control.
  36075. */
  36076. buttonsRoll: number[];
  36077. /**
  36078. * Detect if any button is being pressed while mouse is moved.
  36079. * -1 = Mouse locked.
  36080. * 0 = Left button.
  36081. * 1 = Middle Button.
  36082. * 2 = Right Button.
  36083. */
  36084. activeButton: number;
  36085. /**
  36086. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36087. * Higher values reduce its sensitivity.
  36088. */
  36089. angularSensibility: number;
  36090. private _mousemoveCallback;
  36091. private _observer;
  36092. private _rollObserver;
  36093. private previousPosition;
  36094. private noPreventDefault;
  36095. private element;
  36096. /**
  36097. * Listen to mouse events to control the camera.
  36098. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36099. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36100. */
  36101. constructor(touchEnabled?: boolean);
  36102. /**
  36103. * Attach the mouse control to the HTML DOM element.
  36104. * @param element Defines the element that listens to the input events.
  36105. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36106. */
  36107. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36108. /**
  36109. * Detach the current controls from the specified dom element.
  36110. * @param element Defines the element to stop listening the inputs from
  36111. */
  36112. detachControl(element: Nullable<HTMLElement>): void;
  36113. /**
  36114. * Gets the class name of the current input.
  36115. * @returns the class name.
  36116. */
  36117. getClassName(): string;
  36118. /**
  36119. * Get the friendly name associated with the input class.
  36120. * @returns the input's friendly name.
  36121. */
  36122. getSimpleName(): string;
  36123. private _pointerInput;
  36124. private _onMouseMove;
  36125. /**
  36126. * Rotate camera by mouse offset.
  36127. */
  36128. private rotateCamera;
  36129. }
  36130. }
  36131. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36132. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36133. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36134. /**
  36135. * Default Inputs manager for the FlyCamera.
  36136. * It groups all the default supported inputs for ease of use.
  36137. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36138. */
  36139. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36140. /**
  36141. * Instantiates a new FlyCameraInputsManager.
  36142. * @param camera Defines the camera the inputs belong to.
  36143. */
  36144. constructor(camera: FlyCamera);
  36145. /**
  36146. * Add keyboard input support to the input manager.
  36147. * @returns the new FlyCameraKeyboardMoveInput().
  36148. */
  36149. addKeyboard(): FlyCameraInputsManager;
  36150. /**
  36151. * Add mouse input support to the input manager.
  36152. * @param touchEnabled Enable touch screen support.
  36153. * @returns the new FlyCameraMouseInput().
  36154. */
  36155. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36156. }
  36157. }
  36158. declare module "babylonjs/Cameras/flyCamera" {
  36159. import { Scene } from "babylonjs/scene";
  36160. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36162. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36163. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36164. /**
  36165. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36166. * such as in a 3D Space Shooter or a Flight Simulator.
  36167. */
  36168. export class FlyCamera extends TargetCamera {
  36169. /**
  36170. * Define the collision ellipsoid of the camera.
  36171. * This is helpful for simulating a camera body, like a player's body.
  36172. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36173. */
  36174. ellipsoid: Vector3;
  36175. /**
  36176. * Define an offset for the position of the ellipsoid around the camera.
  36177. * This can be helpful if the camera is attached away from the player's body center,
  36178. * such as at its head.
  36179. */
  36180. ellipsoidOffset: Vector3;
  36181. /**
  36182. * Enable or disable collisions of the camera with the rest of the scene objects.
  36183. */
  36184. checkCollisions: boolean;
  36185. /**
  36186. * Enable or disable gravity on the camera.
  36187. */
  36188. applyGravity: boolean;
  36189. /**
  36190. * Define the current direction the camera is moving to.
  36191. */
  36192. cameraDirection: Vector3;
  36193. /**
  36194. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36195. * This overrides and empties cameraRotation.
  36196. */
  36197. rotationQuaternion: Quaternion;
  36198. /**
  36199. * Track Roll to maintain the wanted Rolling when looking around.
  36200. */
  36201. _trackRoll: number;
  36202. /**
  36203. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36204. */
  36205. rollCorrect: number;
  36206. /**
  36207. * Mimic a banked turn, Rolling the camera when Yawing.
  36208. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36209. */
  36210. bankedTurn: boolean;
  36211. /**
  36212. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36213. */
  36214. bankedTurnLimit: number;
  36215. /**
  36216. * Value of 0 disables the banked Roll.
  36217. * Value of 1 is equal to the Yaw angle in radians.
  36218. */
  36219. bankedTurnMultiplier: number;
  36220. /**
  36221. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36222. */
  36223. inputs: FlyCameraInputsManager;
  36224. /**
  36225. * Gets the input sensibility for mouse input.
  36226. * Higher values reduce sensitivity.
  36227. */
  36228. /**
  36229. * Sets the input sensibility for a mouse input.
  36230. * Higher values reduce sensitivity.
  36231. */
  36232. angularSensibility: number;
  36233. /**
  36234. * Get the keys for camera movement forward.
  36235. */
  36236. /**
  36237. * Set the keys for camera movement forward.
  36238. */
  36239. keysForward: number[];
  36240. /**
  36241. * Get the keys for camera movement backward.
  36242. */
  36243. keysBackward: number[];
  36244. /**
  36245. * Get the keys for camera movement up.
  36246. */
  36247. /**
  36248. * Set the keys for camera movement up.
  36249. */
  36250. keysUp: number[];
  36251. /**
  36252. * Get the keys for camera movement down.
  36253. */
  36254. /**
  36255. * Set the keys for camera movement down.
  36256. */
  36257. keysDown: number[];
  36258. /**
  36259. * Get the keys for camera movement left.
  36260. */
  36261. /**
  36262. * Set the keys for camera movement left.
  36263. */
  36264. keysLeft: number[];
  36265. /**
  36266. * Set the keys for camera movement right.
  36267. */
  36268. /**
  36269. * Set the keys for camera movement right.
  36270. */
  36271. keysRight: number[];
  36272. /**
  36273. * Event raised when the camera collides with a mesh in the scene.
  36274. */
  36275. onCollide: (collidedMesh: AbstractMesh) => void;
  36276. private _collider;
  36277. private _needMoveForGravity;
  36278. private _oldPosition;
  36279. private _diffPosition;
  36280. private _newPosition;
  36281. /** @hidden */
  36282. _localDirection: Vector3;
  36283. /** @hidden */
  36284. _transformedDirection: Vector3;
  36285. /**
  36286. * Instantiates a FlyCamera.
  36287. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36288. * such as in a 3D Space Shooter or a Flight Simulator.
  36289. * @param name Define the name of the camera in the scene.
  36290. * @param position Define the starting position of the camera in the scene.
  36291. * @param scene Define the scene the camera belongs to.
  36292. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36293. */
  36294. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36295. /**
  36296. * Attach a control to the HTML DOM element.
  36297. * @param element Defines the element that listens to the input events.
  36298. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36299. */
  36300. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36301. /**
  36302. * Detach a control from the HTML DOM element.
  36303. * The camera will stop reacting to that input.
  36304. * @param element Defines the element that listens to the input events.
  36305. */
  36306. detachControl(element: HTMLElement): void;
  36307. private _collisionMask;
  36308. /**
  36309. * Get the mask that the camera ignores in collision events.
  36310. */
  36311. /**
  36312. * Set the mask that the camera ignores in collision events.
  36313. */
  36314. collisionMask: number;
  36315. /** @hidden */
  36316. _collideWithWorld(displacement: Vector3): void;
  36317. /** @hidden */
  36318. private _onCollisionPositionChange;
  36319. /** @hidden */
  36320. _checkInputs(): void;
  36321. /** @hidden */
  36322. _decideIfNeedsToMove(): boolean;
  36323. /** @hidden */
  36324. _updatePosition(): void;
  36325. /**
  36326. * Restore the Roll to its target value at the rate specified.
  36327. * @param rate - Higher means slower restoring.
  36328. * @hidden
  36329. */
  36330. restoreRoll(rate: number): void;
  36331. /**
  36332. * Destroy the camera and release the current resources held by it.
  36333. */
  36334. dispose(): void;
  36335. /**
  36336. * Get the current object class name.
  36337. * @returns the class name.
  36338. */
  36339. getClassName(): string;
  36340. }
  36341. }
  36342. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36343. import { Nullable } from "babylonjs/types";
  36344. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36345. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36346. /**
  36347. * Listen to keyboard events to control the camera.
  36348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36349. */
  36350. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36351. /**
  36352. * Defines the camera the input is attached to.
  36353. */
  36354. camera: FlyCamera;
  36355. /**
  36356. * The list of keyboard keys used to control the forward move of the camera.
  36357. */
  36358. keysForward: number[];
  36359. /**
  36360. * The list of keyboard keys used to control the backward move of the camera.
  36361. */
  36362. keysBackward: number[];
  36363. /**
  36364. * The list of keyboard keys used to control the forward move of the camera.
  36365. */
  36366. keysUp: number[];
  36367. /**
  36368. * The list of keyboard keys used to control the backward move of the camera.
  36369. */
  36370. keysDown: number[];
  36371. /**
  36372. * The list of keyboard keys used to control the right strafe move of the camera.
  36373. */
  36374. keysRight: number[];
  36375. /**
  36376. * The list of keyboard keys used to control the left strafe move of the camera.
  36377. */
  36378. keysLeft: number[];
  36379. private _keys;
  36380. private _onCanvasBlurObserver;
  36381. private _onKeyboardObserver;
  36382. private _engine;
  36383. private _scene;
  36384. /**
  36385. * Attach the input controls to a specific dom element to get the input from.
  36386. * @param element Defines the element the controls should be listened from
  36387. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36388. */
  36389. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36390. /**
  36391. * Detach the current controls from the specified dom element.
  36392. * @param element Defines the element to stop listening the inputs from
  36393. */
  36394. detachControl(element: Nullable<HTMLElement>): void;
  36395. /**
  36396. * Gets the class name of the current intput.
  36397. * @returns the class name
  36398. */
  36399. getClassName(): string;
  36400. /** @hidden */
  36401. _onLostFocus(e: FocusEvent): void;
  36402. /**
  36403. * Get the friendly name associated with the input class.
  36404. * @returns the input friendly name
  36405. */
  36406. getSimpleName(): string;
  36407. /**
  36408. * Update the current camera state depending on the inputs that have been used this frame.
  36409. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36410. */
  36411. checkInputs(): void;
  36412. }
  36413. }
  36414. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  36415. import { Nullable } from "babylonjs/types";
  36416. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36417. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36418. module "babylonjs/Cameras/freeCameraInputsManager" {
  36419. interface FreeCameraInputsManager {
  36420. /**
  36421. * Add orientation input support to the input manager.
  36422. * @returns the current input manager
  36423. */
  36424. addDeviceOrientation(): FreeCameraInputsManager;
  36425. }
  36426. }
  36427. /**
  36428. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36429. * Screen rotation is taken into account.
  36430. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36431. */
  36432. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36433. private _camera;
  36434. private _screenOrientationAngle;
  36435. private _constantTranform;
  36436. private _screenQuaternion;
  36437. private _alpha;
  36438. private _beta;
  36439. private _gamma;
  36440. /**
  36441. * Instantiates a new input
  36442. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36443. */
  36444. constructor();
  36445. /**
  36446. * Define the camera controlled by the input.
  36447. */
  36448. camera: FreeCamera;
  36449. /**
  36450. * Attach the input controls to a specific dom element to get the input from.
  36451. * @param element Defines the element the controls should be listened from
  36452. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36453. */
  36454. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36455. private _orientationChanged;
  36456. private _deviceOrientation;
  36457. /**
  36458. * Detach the current controls from the specified dom element.
  36459. * @param element Defines the element to stop listening the inputs from
  36460. */
  36461. detachControl(element: Nullable<HTMLElement>): void;
  36462. /**
  36463. * Update the current camera state depending on the inputs that have been used this frame.
  36464. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36465. */
  36466. checkInputs(): void;
  36467. /**
  36468. * Gets the class name of the current intput.
  36469. * @returns the class name
  36470. */
  36471. getClassName(): string;
  36472. /**
  36473. * Get the friendly name associated with the input class.
  36474. * @returns the input friendly name
  36475. */
  36476. getSimpleName(): string;
  36477. }
  36478. }
  36479. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  36480. import { Nullable } from "babylonjs/types";
  36481. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36482. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36483. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36484. /**
  36485. * Manage the gamepad inputs to control a free camera.
  36486. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36487. */
  36488. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36489. /**
  36490. * Define the camera the input is attached to.
  36491. */
  36492. camera: FreeCamera;
  36493. /**
  36494. * Define the Gamepad controlling the input
  36495. */
  36496. gamepad: Nullable<Gamepad>;
  36497. /**
  36498. * Defines the gamepad rotation sensiblity.
  36499. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36500. */
  36501. gamepadAngularSensibility: number;
  36502. /**
  36503. * Defines the gamepad move sensiblity.
  36504. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36505. */
  36506. gamepadMoveSensibility: number;
  36507. private _onGamepadConnectedObserver;
  36508. private _onGamepadDisconnectedObserver;
  36509. private _cameraTransform;
  36510. private _deltaTransform;
  36511. private _vector3;
  36512. private _vector2;
  36513. /**
  36514. * Attach the input controls to a specific dom element to get the input from.
  36515. * @param element Defines the element the controls should be listened from
  36516. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36517. */
  36518. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36519. /**
  36520. * Detach the current controls from the specified dom element.
  36521. * @param element Defines the element to stop listening the inputs from
  36522. */
  36523. detachControl(element: Nullable<HTMLElement>): void;
  36524. /**
  36525. * Update the current camera state depending on the inputs that have been used this frame.
  36526. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36527. */
  36528. checkInputs(): void;
  36529. /**
  36530. * Gets the class name of the current intput.
  36531. * @returns the class name
  36532. */
  36533. getClassName(): string;
  36534. /**
  36535. * Get the friendly name associated with the input class.
  36536. * @returns the input friendly name
  36537. */
  36538. getSimpleName(): string;
  36539. }
  36540. }
  36541. declare module "babylonjs/Misc/virtualJoystick" {
  36542. import { Nullable } from "babylonjs/types";
  36543. import { Vector3 } from "babylonjs/Maths/math";
  36544. /**
  36545. * Defines the potential axis of a Joystick
  36546. */
  36547. export enum JoystickAxis {
  36548. /** X axis */
  36549. X = 0,
  36550. /** Y axis */
  36551. Y = 1,
  36552. /** Z axis */
  36553. Z = 2
  36554. }
  36555. /**
  36556. * Class used to define virtual joystick (used in touch mode)
  36557. */
  36558. export class VirtualJoystick {
  36559. /**
  36560. * Gets or sets a boolean indicating that left and right values must be inverted
  36561. */
  36562. reverseLeftRight: boolean;
  36563. /**
  36564. * Gets or sets a boolean indicating that up and down values must be inverted
  36565. */
  36566. reverseUpDown: boolean;
  36567. /**
  36568. * Gets the offset value for the position (ie. the change of the position value)
  36569. */
  36570. deltaPosition: Vector3;
  36571. /**
  36572. * Gets a boolean indicating if the virtual joystick was pressed
  36573. */
  36574. pressed: boolean;
  36575. /**
  36576. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36577. */
  36578. static Canvas: Nullable<HTMLCanvasElement>;
  36579. private static _globalJoystickIndex;
  36580. private static vjCanvasContext;
  36581. private static vjCanvasWidth;
  36582. private static vjCanvasHeight;
  36583. private static halfWidth;
  36584. private _action;
  36585. private _axisTargetedByLeftAndRight;
  36586. private _axisTargetedByUpAndDown;
  36587. private _joystickSensibility;
  36588. private _inversedSensibility;
  36589. private _joystickPointerID;
  36590. private _joystickColor;
  36591. private _joystickPointerPos;
  36592. private _joystickPreviousPointerPos;
  36593. private _joystickPointerStartPos;
  36594. private _deltaJoystickVector;
  36595. private _leftJoystick;
  36596. private _touches;
  36597. private _onPointerDownHandlerRef;
  36598. private _onPointerMoveHandlerRef;
  36599. private _onPointerUpHandlerRef;
  36600. private _onResize;
  36601. /**
  36602. * Creates a new virtual joystick
  36603. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36604. */
  36605. constructor(leftJoystick?: boolean);
  36606. /**
  36607. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36608. * @param newJoystickSensibility defines the new sensibility
  36609. */
  36610. setJoystickSensibility(newJoystickSensibility: number): void;
  36611. private _onPointerDown;
  36612. private _onPointerMove;
  36613. private _onPointerUp;
  36614. /**
  36615. * Change the color of the virtual joystick
  36616. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36617. */
  36618. setJoystickColor(newColor: string): void;
  36619. /**
  36620. * Defines a callback to call when the joystick is touched
  36621. * @param action defines the callback
  36622. */
  36623. setActionOnTouch(action: () => any): void;
  36624. /**
  36625. * Defines which axis you'd like to control for left & right
  36626. * @param axis defines the axis to use
  36627. */
  36628. setAxisForLeftRight(axis: JoystickAxis): void;
  36629. /**
  36630. * Defines which axis you'd like to control for up & down
  36631. * @param axis defines the axis to use
  36632. */
  36633. setAxisForUpDown(axis: JoystickAxis): void;
  36634. private _drawVirtualJoystick;
  36635. /**
  36636. * Release internal HTML canvas
  36637. */
  36638. releaseCanvas(): void;
  36639. }
  36640. }
  36641. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  36642. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  36643. import { Nullable } from "babylonjs/types";
  36644. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36645. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36646. module "babylonjs/Cameras/freeCameraInputsManager" {
  36647. interface FreeCameraInputsManager {
  36648. /**
  36649. * Add virtual joystick input support to the input manager.
  36650. * @returns the current input manager
  36651. */
  36652. addVirtualJoystick(): FreeCameraInputsManager;
  36653. }
  36654. }
  36655. /**
  36656. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36658. */
  36659. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36660. /**
  36661. * Defines the camera the input is attached to.
  36662. */
  36663. camera: FreeCamera;
  36664. private _leftjoystick;
  36665. private _rightjoystick;
  36666. /**
  36667. * Gets the left stick of the virtual joystick.
  36668. * @returns The virtual Joystick
  36669. */
  36670. getLeftJoystick(): VirtualJoystick;
  36671. /**
  36672. * Gets the right stick of the virtual joystick.
  36673. * @returns The virtual Joystick
  36674. */
  36675. getRightJoystick(): VirtualJoystick;
  36676. /**
  36677. * Update the current camera state depending on the inputs that have been used this frame.
  36678. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36679. */
  36680. checkInputs(): void;
  36681. /**
  36682. * Attach the input controls to a specific dom element to get the input from.
  36683. * @param element Defines the element the controls should be listened from
  36684. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36685. */
  36686. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36687. /**
  36688. * Detach the current controls from the specified dom element.
  36689. * @param element Defines the element to stop listening the inputs from
  36690. */
  36691. detachControl(element: Nullable<HTMLElement>): void;
  36692. /**
  36693. * Gets the class name of the current intput.
  36694. * @returns the class name
  36695. */
  36696. getClassName(): string;
  36697. /**
  36698. * Get the friendly name associated with the input class.
  36699. * @returns the input friendly name
  36700. */
  36701. getSimpleName(): string;
  36702. }
  36703. }
  36704. declare module "babylonjs/Cameras/Inputs/index" {
  36705. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  36706. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  36707. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  36708. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  36709. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  36710. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  36711. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  36712. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  36713. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  36714. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  36715. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  36716. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  36717. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  36718. }
  36719. declare module "babylonjs/Cameras/touchCamera" {
  36720. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36721. import { Scene } from "babylonjs/scene";
  36722. import { Vector3 } from "babylonjs/Maths/math";
  36723. /**
  36724. * This represents a FPS type of camera controlled by touch.
  36725. * This is like a universal camera minus the Gamepad controls.
  36726. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36727. */
  36728. export class TouchCamera extends FreeCamera {
  36729. /**
  36730. * Defines the touch sensibility for rotation.
  36731. * The higher the faster.
  36732. */
  36733. touchAngularSensibility: number;
  36734. /**
  36735. * Defines the touch sensibility for move.
  36736. * The higher the faster.
  36737. */
  36738. touchMoveSensibility: number;
  36739. /**
  36740. * Instantiates a new touch camera.
  36741. * This represents a FPS type of camera controlled by touch.
  36742. * This is like a universal camera minus the Gamepad controls.
  36743. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36744. * @param name Define the name of the camera in the scene
  36745. * @param position Define the start position of the camera in the scene
  36746. * @param scene Define the scene the camera belongs to
  36747. */
  36748. constructor(name: string, position: Vector3, scene: Scene);
  36749. /**
  36750. * Gets the current object class name.
  36751. * @return the class name
  36752. */
  36753. getClassName(): string;
  36754. /** @hidden */
  36755. _setupInputs(): void;
  36756. }
  36757. }
  36758. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  36759. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36760. import { Scene } from "babylonjs/scene";
  36761. import { Vector3, Axis } from "babylonjs/Maths/math";
  36762. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  36763. /**
  36764. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36765. * being tilted forward or back and left or right.
  36766. */
  36767. export class DeviceOrientationCamera extends FreeCamera {
  36768. private _initialQuaternion;
  36769. private _quaternionCache;
  36770. /**
  36771. * Creates a new device orientation camera
  36772. * @param name The name of the camera
  36773. * @param position The start position camera
  36774. * @param scene The scene the camera belongs to
  36775. */
  36776. constructor(name: string, position: Vector3, scene: Scene);
  36777. /**
  36778. * Gets the current instance class name ("DeviceOrientationCamera").
  36779. * This helps avoiding instanceof at run time.
  36780. * @returns the class name
  36781. */
  36782. getClassName(): string;
  36783. /**
  36784. * @hidden
  36785. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36786. */
  36787. _checkInputs(): void;
  36788. /**
  36789. * Reset the camera to its default orientation on the specified axis only.
  36790. * @param axis The axis to reset
  36791. */
  36792. resetToCurrentRotation(axis?: Axis): void;
  36793. }
  36794. }
  36795. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  36796. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36797. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36798. import { Nullable } from "babylonjs/types";
  36799. /**
  36800. * Manage the keyboard inputs to control the movement of a follow camera.
  36801. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36802. */
  36803. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36804. /**
  36805. * Defines the camera the input is attached to.
  36806. */
  36807. camera: FollowCamera;
  36808. /**
  36809. * Defines the list of key codes associated with the up action (increase heightOffset)
  36810. */
  36811. keysHeightOffsetIncr: number[];
  36812. /**
  36813. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36814. */
  36815. keysHeightOffsetDecr: number[];
  36816. /**
  36817. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36818. */
  36819. keysHeightOffsetModifierAlt: boolean;
  36820. /**
  36821. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36822. */
  36823. keysHeightOffsetModifierCtrl: boolean;
  36824. /**
  36825. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36826. */
  36827. keysHeightOffsetModifierShift: boolean;
  36828. /**
  36829. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36830. */
  36831. keysRotationOffsetIncr: number[];
  36832. /**
  36833. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36834. */
  36835. keysRotationOffsetDecr: number[];
  36836. /**
  36837. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36838. */
  36839. keysRotationOffsetModifierAlt: boolean;
  36840. /**
  36841. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36842. */
  36843. keysRotationOffsetModifierCtrl: boolean;
  36844. /**
  36845. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36846. */
  36847. keysRotationOffsetModifierShift: boolean;
  36848. /**
  36849. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36850. */
  36851. keysRadiusIncr: number[];
  36852. /**
  36853. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36854. */
  36855. keysRadiusDecr: number[];
  36856. /**
  36857. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36858. */
  36859. keysRadiusModifierAlt: boolean;
  36860. /**
  36861. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36862. */
  36863. keysRadiusModifierCtrl: boolean;
  36864. /**
  36865. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36866. */
  36867. keysRadiusModifierShift: boolean;
  36868. /**
  36869. * Defines the rate of change of heightOffset.
  36870. */
  36871. heightSensibility: number;
  36872. /**
  36873. * Defines the rate of change of rotationOffset.
  36874. */
  36875. rotationSensibility: number;
  36876. /**
  36877. * Defines the rate of change of radius.
  36878. */
  36879. radiusSensibility: number;
  36880. private _keys;
  36881. private _ctrlPressed;
  36882. private _altPressed;
  36883. private _shiftPressed;
  36884. private _onCanvasBlurObserver;
  36885. private _onKeyboardObserver;
  36886. private _engine;
  36887. private _scene;
  36888. /**
  36889. * Attach the input controls to a specific dom element to get the input from.
  36890. * @param element Defines the element the controls should be listened from
  36891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36892. */
  36893. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36894. /**
  36895. * Detach the current controls from the specified dom element.
  36896. * @param element Defines the element to stop listening the inputs from
  36897. */
  36898. detachControl(element: Nullable<HTMLElement>): void;
  36899. /**
  36900. * Update the current camera state depending on the inputs that have been used this frame.
  36901. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36902. */
  36903. checkInputs(): void;
  36904. /**
  36905. * Gets the class name of the current input.
  36906. * @returns the class name
  36907. */
  36908. getClassName(): string;
  36909. /**
  36910. * Get the friendly name associated with the input class.
  36911. * @returns the input friendly name
  36912. */
  36913. getSimpleName(): string;
  36914. /**
  36915. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36916. * allow modification of the heightOffset value.
  36917. */
  36918. private _modifierHeightOffset;
  36919. /**
  36920. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36921. * allow modification of the rotationOffset value.
  36922. */
  36923. private _modifierRotationOffset;
  36924. /**
  36925. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36926. * allow modification of the radius value.
  36927. */
  36928. private _modifierRadius;
  36929. }
  36930. }
  36931. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36932. import { Nullable } from "babylonjs/types";
  36933. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36934. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36935. /**
  36936. * Manage the mouse wheel inputs to control a follow camera.
  36937. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36938. */
  36939. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36940. /**
  36941. * Defines the camera the input is attached to.
  36942. */
  36943. camera: FollowCamera;
  36944. /**
  36945. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  36946. */
  36947. axisControlRadius: boolean;
  36948. /**
  36949. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  36950. */
  36951. axisControlHeight: boolean;
  36952. /**
  36953. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  36954. */
  36955. axisControlRotation: boolean;
  36956. /**
  36957. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36958. * relation to mouseWheel events.
  36959. */
  36960. wheelPrecision: number;
  36961. /**
  36962. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36963. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36964. */
  36965. wheelDeltaPercentage: number;
  36966. private _wheel;
  36967. private _observer;
  36968. /**
  36969. * Attach the input controls to a specific dom element to get the input from.
  36970. * @param element Defines the element the controls should be listened from
  36971. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36972. */
  36973. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36974. /**
  36975. * Detach the current controls from the specified dom element.
  36976. * @param element Defines the element to stop listening the inputs from
  36977. */
  36978. detachControl(element: Nullable<HTMLElement>): void;
  36979. /**
  36980. * Gets the class name of the current intput.
  36981. * @returns the class name
  36982. */
  36983. getClassName(): string;
  36984. /**
  36985. * Get the friendly name associated with the input class.
  36986. * @returns the input friendly name
  36987. */
  36988. getSimpleName(): string;
  36989. }
  36990. }
  36991. declare module "babylonjs/Cameras/followCameraInputsManager" {
  36992. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36993. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36994. /**
  36995. * Default Inputs manager for the FollowCamera.
  36996. * It groups all the default supported inputs for ease of use.
  36997. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36998. */
  36999. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37000. /**
  37001. * Instantiates a new FollowCameraInputsManager.
  37002. * @param camera Defines the camera the inputs belong to
  37003. */
  37004. constructor(camera: FollowCamera);
  37005. /**
  37006. * Add keyboard input support to the input manager.
  37007. * @returns the current input manager
  37008. */
  37009. addKeyboard(): FollowCameraInputsManager;
  37010. /**
  37011. * Add mouse wheel input support to the input manager.
  37012. * @returns the current input manager
  37013. */
  37014. addMouseWheel(): FollowCameraInputsManager;
  37015. /**
  37016. * Add pointers input support to the input manager.
  37017. * @returns the current input manager
  37018. */
  37019. addPointers(): FollowCameraInputsManager;
  37020. /**
  37021. * Add orientation input support to the input manager.
  37022. * @returns the current input manager
  37023. */
  37024. addVRDeviceOrientation(): FollowCameraInputsManager;
  37025. }
  37026. }
  37027. declare module "babylonjs/Cameras/followCamera" {
  37028. import { Nullable } from "babylonjs/types";
  37029. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37030. import { Scene } from "babylonjs/scene";
  37031. import { Vector3 } from "babylonjs/Maths/math";
  37032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37033. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37034. /**
  37035. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37036. * an arc rotate version arcFollowCamera are available.
  37037. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37038. */
  37039. export class FollowCamera extends TargetCamera {
  37040. /**
  37041. * Distance the follow camera should follow an object at
  37042. */
  37043. radius: number;
  37044. /**
  37045. * Minimum allowed distance of the camera to the axis of rotation
  37046. * (The camera can not get closer).
  37047. * This can help limiting how the Camera is able to move in the scene.
  37048. */
  37049. lowerRadiusLimit: Nullable<number>;
  37050. /**
  37051. * Maximum allowed distance of the camera to the axis of rotation
  37052. * (The camera can not get further).
  37053. * This can help limiting how the Camera is able to move in the scene.
  37054. */
  37055. upperRadiusLimit: Nullable<number>;
  37056. /**
  37057. * Define a rotation offset between the camera and the object it follows
  37058. */
  37059. rotationOffset: number;
  37060. /**
  37061. * Minimum allowed angle to camera position relative to target object.
  37062. * This can help limiting how the Camera is able to move in the scene.
  37063. */
  37064. lowerRotationOffsetLimit: Nullable<number>;
  37065. /**
  37066. * Maximum allowed angle to camera position relative to target object.
  37067. * This can help limiting how the Camera is able to move in the scene.
  37068. */
  37069. upperRotationOffsetLimit: Nullable<number>;
  37070. /**
  37071. * Define a height offset between the camera and the object it follows.
  37072. * It can help following an object from the top (like a car chaing a plane)
  37073. */
  37074. heightOffset: number;
  37075. /**
  37076. * Minimum allowed height of camera position relative to target object.
  37077. * This can help limiting how the Camera is able to move in the scene.
  37078. */
  37079. lowerHeightOffsetLimit: Nullable<number>;
  37080. /**
  37081. * Maximum allowed height of camera position relative to target object.
  37082. * This can help limiting how the Camera is able to move in the scene.
  37083. */
  37084. upperHeightOffsetLimit: Nullable<number>;
  37085. /**
  37086. * Define how fast the camera can accelerate to follow it s target.
  37087. */
  37088. cameraAcceleration: number;
  37089. /**
  37090. * Define the speed limit of the camera following an object.
  37091. */
  37092. maxCameraSpeed: number;
  37093. /**
  37094. * Define the target of the camera.
  37095. */
  37096. lockedTarget: Nullable<AbstractMesh>;
  37097. /**
  37098. * Defines the input associated with the camera.
  37099. */
  37100. inputs: FollowCameraInputsManager;
  37101. /**
  37102. * Instantiates the follow camera.
  37103. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37104. * @param name Define the name of the camera in the scene
  37105. * @param position Define the position of the camera
  37106. * @param scene Define the scene the camera belong to
  37107. * @param lockedTarget Define the target of the camera
  37108. */
  37109. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37110. private _follow;
  37111. /**
  37112. * Attached controls to the current camera.
  37113. * @param element Defines the element the controls should be listened from
  37114. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37115. */
  37116. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37117. /**
  37118. * Detach the current controls from the camera.
  37119. * The camera will stop reacting to inputs.
  37120. * @param element Defines the element to stop listening the inputs from
  37121. */
  37122. detachControl(element: HTMLElement): void;
  37123. /** @hidden */
  37124. _checkInputs(): void;
  37125. private _checkLimits;
  37126. /**
  37127. * Gets the camera class name.
  37128. * @returns the class name
  37129. */
  37130. getClassName(): string;
  37131. }
  37132. /**
  37133. * Arc Rotate version of the follow camera.
  37134. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37135. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37136. */
  37137. export class ArcFollowCamera extends TargetCamera {
  37138. /** The longitudinal angle of the camera */
  37139. alpha: number;
  37140. /** The latitudinal angle of the camera */
  37141. beta: number;
  37142. /** The radius of the camera from its target */
  37143. radius: number;
  37144. /** Define the camera target (the messh it should follow) */
  37145. target: Nullable<AbstractMesh>;
  37146. private _cartesianCoordinates;
  37147. /**
  37148. * Instantiates a new ArcFollowCamera
  37149. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37150. * @param name Define the name of the camera
  37151. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37152. * @param beta Define the rotation angle of the camera around the elevation axis
  37153. * @param radius Define the radius of the camera from its target point
  37154. * @param target Define the target of the camera
  37155. * @param scene Define the scene the camera belongs to
  37156. */
  37157. constructor(name: string,
  37158. /** The longitudinal angle of the camera */
  37159. alpha: number,
  37160. /** The latitudinal angle of the camera */
  37161. beta: number,
  37162. /** The radius of the camera from its target */
  37163. radius: number,
  37164. /** Define the camera target (the messh it should follow) */
  37165. target: Nullable<AbstractMesh>, scene: Scene);
  37166. private _follow;
  37167. /** @hidden */
  37168. _checkInputs(): void;
  37169. /**
  37170. * Returns the class name of the object.
  37171. * It is mostly used internally for serialization purposes.
  37172. */
  37173. getClassName(): string;
  37174. }
  37175. }
  37176. declare module "babylonjs/Cameras/universalCamera" {
  37177. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37178. import { Scene } from "babylonjs/scene";
  37179. import { Vector3 } from "babylonjs/Maths/math";
  37180. /**
  37181. * 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,
  37182. * which still works and will still be found in many Playgrounds.
  37183. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37184. */
  37185. export class UniversalCamera extends TouchCamera {
  37186. /**
  37187. * Defines the gamepad rotation sensiblity.
  37188. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37189. */
  37190. gamepadAngularSensibility: number;
  37191. /**
  37192. * Defines the gamepad move sensiblity.
  37193. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37194. */
  37195. gamepadMoveSensibility: number;
  37196. /**
  37197. * 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,
  37198. * which still works and will still be found in many Playgrounds.
  37199. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37200. * @param name Define the name of the camera in the scene
  37201. * @param position Define the start position of the camera in the scene
  37202. * @param scene Define the scene the camera belongs to
  37203. */
  37204. constructor(name: string, position: Vector3, scene: Scene);
  37205. /**
  37206. * Gets the current object class name.
  37207. * @return the class name
  37208. */
  37209. getClassName(): string;
  37210. }
  37211. }
  37212. declare module "babylonjs/Cameras/gamepadCamera" {
  37213. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37214. import { Scene } from "babylonjs/scene";
  37215. import { Vector3 } from "babylonjs/Maths/math";
  37216. /**
  37217. * This represents a FPS type of camera. This is only here for back compat purpose.
  37218. * Please use the UniversalCamera instead as both are identical.
  37219. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37220. */
  37221. export class GamepadCamera extends UniversalCamera {
  37222. /**
  37223. * Instantiates a new Gamepad Camera
  37224. * This represents a FPS type of camera. This is only here for back compat purpose.
  37225. * Please use the UniversalCamera instead as both are identical.
  37226. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37227. * @param name Define the name of the camera in the scene
  37228. * @param position Define the start position of the camera in the scene
  37229. * @param scene Define the scene the camera belongs to
  37230. */
  37231. constructor(name: string, position: Vector3, scene: Scene);
  37232. /**
  37233. * Gets the current object class name.
  37234. * @return the class name
  37235. */
  37236. getClassName(): string;
  37237. }
  37238. }
  37239. declare module "babylonjs/Shaders/pass.fragment" {
  37240. /** @hidden */
  37241. export var passPixelShader: {
  37242. name: string;
  37243. shader: string;
  37244. };
  37245. }
  37246. declare module "babylonjs/Shaders/passCube.fragment" {
  37247. /** @hidden */
  37248. export var passCubePixelShader: {
  37249. name: string;
  37250. shader: string;
  37251. };
  37252. }
  37253. declare module "babylonjs/PostProcesses/passPostProcess" {
  37254. import { Nullable } from "babylonjs/types";
  37255. import { Camera } from "babylonjs/Cameras/camera";
  37256. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37257. import { Engine } from "babylonjs/Engines/engine";
  37258. import "babylonjs/Shaders/pass.fragment";
  37259. import "babylonjs/Shaders/passCube.fragment";
  37260. /**
  37261. * PassPostProcess which produces an output the same as it's input
  37262. */
  37263. export class PassPostProcess extends PostProcess {
  37264. /**
  37265. * Creates the PassPostProcess
  37266. * @param name The name of the effect.
  37267. * @param options The required width/height ratio to downsize to before computing the render pass.
  37268. * @param camera The camera to apply the render pass to.
  37269. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37270. * @param engine The engine which the post process will be applied. (default: current engine)
  37271. * @param reusable If the post process can be reused on the same frame. (default: false)
  37272. * @param textureType The type of texture to be used when performing the post processing.
  37273. * @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)
  37274. */
  37275. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37276. }
  37277. /**
  37278. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37279. */
  37280. export class PassCubePostProcess extends PostProcess {
  37281. private _face;
  37282. /**
  37283. * Gets or sets the cube face to display.
  37284. * * 0 is +X
  37285. * * 1 is -X
  37286. * * 2 is +Y
  37287. * * 3 is -Y
  37288. * * 4 is +Z
  37289. * * 5 is -Z
  37290. */
  37291. face: number;
  37292. /**
  37293. * Creates the PassCubePostProcess
  37294. * @param name The name of the effect.
  37295. * @param options The required width/height ratio to downsize to before computing the render pass.
  37296. * @param camera The camera to apply the render pass to.
  37297. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37298. * @param engine The engine which the post process will be applied. (default: current engine)
  37299. * @param reusable If the post process can be reused on the same frame. (default: false)
  37300. * @param textureType The type of texture to be used when performing the post processing.
  37301. * @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)
  37302. */
  37303. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37304. }
  37305. }
  37306. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37307. /** @hidden */
  37308. export var anaglyphPixelShader: {
  37309. name: string;
  37310. shader: string;
  37311. };
  37312. }
  37313. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37314. import { Engine } from "babylonjs/Engines/engine";
  37315. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37316. import { Camera } from "babylonjs/Cameras/camera";
  37317. import "babylonjs/Shaders/anaglyph.fragment";
  37318. /**
  37319. * Postprocess used to generate anaglyphic rendering
  37320. */
  37321. export class AnaglyphPostProcess extends PostProcess {
  37322. private _passedProcess;
  37323. /**
  37324. * Creates a new AnaglyphPostProcess
  37325. * @param name defines postprocess name
  37326. * @param options defines creation options or target ratio scale
  37327. * @param rigCameras defines cameras using this postprocess
  37328. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37329. * @param engine defines hosting engine
  37330. * @param reusable defines if the postprocess will be reused multiple times per frame
  37331. */
  37332. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37333. }
  37334. }
  37335. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37336. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37337. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37338. import { Scene } from "babylonjs/scene";
  37339. import { Vector3 } from "babylonjs/Maths/math";
  37340. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37341. /**
  37342. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37343. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37344. */
  37345. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37346. /**
  37347. * Creates a new AnaglyphArcRotateCamera
  37348. * @param name defines camera name
  37349. * @param alpha defines alpha angle (in radians)
  37350. * @param beta defines beta angle (in radians)
  37351. * @param radius defines radius
  37352. * @param target defines camera target
  37353. * @param interaxialDistance defines distance between each color axis
  37354. * @param scene defines the hosting scene
  37355. */
  37356. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37357. /**
  37358. * Gets camera class name
  37359. * @returns AnaglyphArcRotateCamera
  37360. */
  37361. getClassName(): string;
  37362. }
  37363. }
  37364. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37365. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37366. import { Scene } from "babylonjs/scene";
  37367. import { Vector3 } from "babylonjs/Maths/math";
  37368. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37369. /**
  37370. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37371. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37372. */
  37373. export class AnaglyphFreeCamera extends FreeCamera {
  37374. /**
  37375. * Creates a new AnaglyphFreeCamera
  37376. * @param name defines camera name
  37377. * @param position defines initial position
  37378. * @param interaxialDistance defines distance between each color axis
  37379. * @param scene defines the hosting scene
  37380. */
  37381. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37382. /**
  37383. * Gets camera class name
  37384. * @returns AnaglyphFreeCamera
  37385. */
  37386. getClassName(): string;
  37387. }
  37388. }
  37389. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37390. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37391. import { Scene } from "babylonjs/scene";
  37392. import { Vector3 } from "babylonjs/Maths/math";
  37393. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37394. /**
  37395. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37396. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37397. */
  37398. export class AnaglyphGamepadCamera extends GamepadCamera {
  37399. /**
  37400. * Creates a new AnaglyphGamepadCamera
  37401. * @param name defines camera name
  37402. * @param position defines initial position
  37403. * @param interaxialDistance defines distance between each color axis
  37404. * @param scene defines the hosting scene
  37405. */
  37406. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37407. /**
  37408. * Gets camera class name
  37409. * @returns AnaglyphGamepadCamera
  37410. */
  37411. getClassName(): string;
  37412. }
  37413. }
  37414. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37415. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37416. import { Scene } from "babylonjs/scene";
  37417. import { Vector3 } from "babylonjs/Maths/math";
  37418. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37419. /**
  37420. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37421. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37422. */
  37423. export class AnaglyphUniversalCamera extends UniversalCamera {
  37424. /**
  37425. * Creates a new AnaglyphUniversalCamera
  37426. * @param name defines camera name
  37427. * @param position defines initial position
  37428. * @param interaxialDistance defines distance between each color axis
  37429. * @param scene defines the hosting scene
  37430. */
  37431. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37432. /**
  37433. * Gets camera class name
  37434. * @returns AnaglyphUniversalCamera
  37435. */
  37436. getClassName(): string;
  37437. }
  37438. }
  37439. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37440. /** @hidden */
  37441. export var stereoscopicInterlacePixelShader: {
  37442. name: string;
  37443. shader: string;
  37444. };
  37445. }
  37446. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37447. import { Camera } from "babylonjs/Cameras/camera";
  37448. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37449. import { Engine } from "babylonjs/Engines/engine";
  37450. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37451. /**
  37452. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37453. */
  37454. export class StereoscopicInterlacePostProcess extends PostProcess {
  37455. private _stepSize;
  37456. private _passedProcess;
  37457. /**
  37458. * Initializes a StereoscopicInterlacePostProcess
  37459. * @param name The name of the effect.
  37460. * @param rigCameras The rig cameras to be appled to the post process
  37461. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37462. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37463. * @param engine The engine which the post process will be applied. (default: current engine)
  37464. * @param reusable If the post process can be reused on the same frame. (default: false)
  37465. */
  37466. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37467. }
  37468. }
  37469. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37470. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37471. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37472. import { Scene } from "babylonjs/scene";
  37473. import { Vector3 } from "babylonjs/Maths/math";
  37474. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37475. /**
  37476. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37477. * @see http://doc.babylonjs.com/features/cameras
  37478. */
  37479. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37480. /**
  37481. * Creates a new StereoscopicArcRotateCamera
  37482. * @param name defines camera name
  37483. * @param alpha defines alpha angle (in radians)
  37484. * @param beta defines beta angle (in radians)
  37485. * @param radius defines radius
  37486. * @param target defines camera target
  37487. * @param interaxialDistance defines distance between each color axis
  37488. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37489. * @param scene defines the hosting scene
  37490. */
  37491. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37492. /**
  37493. * Gets camera class name
  37494. * @returns StereoscopicArcRotateCamera
  37495. */
  37496. getClassName(): string;
  37497. }
  37498. }
  37499. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37500. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37501. import { Scene } from "babylonjs/scene";
  37502. import { Vector3 } from "babylonjs/Maths/math";
  37503. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37504. /**
  37505. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37506. * @see http://doc.babylonjs.com/features/cameras
  37507. */
  37508. export class StereoscopicFreeCamera extends FreeCamera {
  37509. /**
  37510. * Creates a new StereoscopicFreeCamera
  37511. * @param name defines camera name
  37512. * @param position defines initial position
  37513. * @param interaxialDistance defines distance between each color axis
  37514. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37515. * @param scene defines the hosting scene
  37516. */
  37517. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37518. /**
  37519. * Gets camera class name
  37520. * @returns StereoscopicFreeCamera
  37521. */
  37522. getClassName(): string;
  37523. }
  37524. }
  37525. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  37526. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37527. import { Scene } from "babylonjs/scene";
  37528. import { Vector3 } from "babylonjs/Maths/math";
  37529. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37530. /**
  37531. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37532. * @see http://doc.babylonjs.com/features/cameras
  37533. */
  37534. export class StereoscopicGamepadCamera extends GamepadCamera {
  37535. /**
  37536. * Creates a new StereoscopicGamepadCamera
  37537. * @param name defines camera name
  37538. * @param position defines initial position
  37539. * @param interaxialDistance defines distance between each color axis
  37540. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37541. * @param scene defines the hosting scene
  37542. */
  37543. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37544. /**
  37545. * Gets camera class name
  37546. * @returns StereoscopicGamepadCamera
  37547. */
  37548. getClassName(): string;
  37549. }
  37550. }
  37551. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  37552. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37553. import { Scene } from "babylonjs/scene";
  37554. import { Vector3 } from "babylonjs/Maths/math";
  37555. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37556. /**
  37557. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37558. * @see http://doc.babylonjs.com/features/cameras
  37559. */
  37560. export class StereoscopicUniversalCamera extends UniversalCamera {
  37561. /**
  37562. * Creates a new StereoscopicUniversalCamera
  37563. * @param name defines camera name
  37564. * @param position defines initial position
  37565. * @param interaxialDistance defines distance between each color axis
  37566. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37567. * @param scene defines the hosting scene
  37568. */
  37569. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37570. /**
  37571. * Gets camera class name
  37572. * @returns StereoscopicUniversalCamera
  37573. */
  37574. getClassName(): string;
  37575. }
  37576. }
  37577. declare module "babylonjs/Cameras/Stereoscopic/index" {
  37578. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  37579. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  37580. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  37581. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  37582. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  37583. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  37584. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  37585. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  37586. }
  37587. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  37588. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37589. import { Scene } from "babylonjs/scene";
  37590. import { Vector3 } from "babylonjs/Maths/math";
  37591. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37592. /**
  37593. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37594. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37595. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37596. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37597. */
  37598. export class VirtualJoysticksCamera extends FreeCamera {
  37599. /**
  37600. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37601. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37602. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37603. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37604. * @param name Define the name of the camera in the scene
  37605. * @param position Define the start position of the camera in the scene
  37606. * @param scene Define the scene the camera belongs to
  37607. */
  37608. constructor(name: string, position: Vector3, scene: Scene);
  37609. /**
  37610. * Gets the current object class name.
  37611. * @return the class name
  37612. */
  37613. getClassName(): string;
  37614. }
  37615. }
  37616. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  37617. import { Matrix } from "babylonjs/Maths/math";
  37618. /**
  37619. * This represents all the required metrics to create a VR camera.
  37620. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37621. */
  37622. export class VRCameraMetrics {
  37623. /**
  37624. * Define the horizontal resolution off the screen.
  37625. */
  37626. hResolution: number;
  37627. /**
  37628. * Define the vertical resolution off the screen.
  37629. */
  37630. vResolution: number;
  37631. /**
  37632. * Define the horizontal screen size.
  37633. */
  37634. hScreenSize: number;
  37635. /**
  37636. * Define the vertical screen size.
  37637. */
  37638. vScreenSize: number;
  37639. /**
  37640. * Define the vertical screen center position.
  37641. */
  37642. vScreenCenter: number;
  37643. /**
  37644. * Define the distance of the eyes to the screen.
  37645. */
  37646. eyeToScreenDistance: number;
  37647. /**
  37648. * Define the distance between both lenses
  37649. */
  37650. lensSeparationDistance: number;
  37651. /**
  37652. * Define the distance between both viewer's eyes.
  37653. */
  37654. interpupillaryDistance: number;
  37655. /**
  37656. * Define the distortion factor of the VR postprocess.
  37657. * Please, touch with care.
  37658. */
  37659. distortionK: number[];
  37660. /**
  37661. * Define the chromatic aberration correction factors for the VR post process.
  37662. */
  37663. chromaAbCorrection: number[];
  37664. /**
  37665. * Define the scale factor of the post process.
  37666. * The smaller the better but the slower.
  37667. */
  37668. postProcessScaleFactor: number;
  37669. /**
  37670. * Define an offset for the lens center.
  37671. */
  37672. lensCenterOffset: number;
  37673. /**
  37674. * Define if the current vr camera should compensate the distortion of the lense or not.
  37675. */
  37676. compensateDistortion: boolean;
  37677. /**
  37678. * Gets the rendering aspect ratio based on the provided resolutions.
  37679. */
  37680. readonly aspectRatio: number;
  37681. /**
  37682. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37683. */
  37684. readonly aspectRatioFov: number;
  37685. /**
  37686. * @hidden
  37687. */
  37688. readonly leftHMatrix: Matrix;
  37689. /**
  37690. * @hidden
  37691. */
  37692. readonly rightHMatrix: Matrix;
  37693. /**
  37694. * @hidden
  37695. */
  37696. readonly leftPreViewMatrix: Matrix;
  37697. /**
  37698. * @hidden
  37699. */
  37700. readonly rightPreViewMatrix: Matrix;
  37701. /**
  37702. * Get the default VRMetrics based on the most generic setup.
  37703. * @returns the default vr metrics
  37704. */
  37705. static GetDefault(): VRCameraMetrics;
  37706. }
  37707. }
  37708. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  37709. /** @hidden */
  37710. export var vrDistortionCorrectionPixelShader: {
  37711. name: string;
  37712. shader: string;
  37713. };
  37714. }
  37715. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  37716. import { Camera } from "babylonjs/Cameras/camera";
  37717. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37718. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37719. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  37720. /**
  37721. * VRDistortionCorrectionPostProcess used for mobile VR
  37722. */
  37723. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37724. private _isRightEye;
  37725. private _distortionFactors;
  37726. private _postProcessScaleFactor;
  37727. private _lensCenterOffset;
  37728. private _scaleIn;
  37729. private _scaleFactor;
  37730. private _lensCenter;
  37731. /**
  37732. * Initializes the VRDistortionCorrectionPostProcess
  37733. * @param name The name of the effect.
  37734. * @param camera The camera to apply the render pass to.
  37735. * @param isRightEye If this is for the right eye distortion
  37736. * @param vrMetrics All the required metrics for the VR camera
  37737. */
  37738. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37739. }
  37740. }
  37741. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  37742. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  37743. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37744. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37745. import { Scene } from "babylonjs/scene";
  37746. import { Vector3 } from "babylonjs/Maths/math";
  37747. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37748. import "babylonjs/Cameras/RigModes/vrRigMode";
  37749. /**
  37750. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37751. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37752. */
  37753. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37754. /**
  37755. * Creates a new VRDeviceOrientationArcRotateCamera
  37756. * @param name defines camera name
  37757. * @param alpha defines the camera rotation along the logitudinal axis
  37758. * @param beta defines the camera rotation along the latitudinal axis
  37759. * @param radius defines the camera distance from its target
  37760. * @param target defines the camera target
  37761. * @param scene defines the scene the camera belongs to
  37762. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37763. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37764. */
  37765. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37766. /**
  37767. * Gets camera class name
  37768. * @returns VRDeviceOrientationArcRotateCamera
  37769. */
  37770. getClassName(): string;
  37771. }
  37772. }
  37773. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  37774. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  37775. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37776. import { Scene } from "babylonjs/scene";
  37777. import { Vector3 } from "babylonjs/Maths/math";
  37778. import "babylonjs/Cameras/RigModes/vrRigMode";
  37779. /**
  37780. * Camera used to simulate VR rendering (based on FreeCamera)
  37781. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37782. */
  37783. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37784. /**
  37785. * Creates a new VRDeviceOrientationFreeCamera
  37786. * @param name defines camera name
  37787. * @param position defines the start position of the camera
  37788. * @param scene defines the scene the camera belongs to
  37789. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37790. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37791. */
  37792. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37793. /**
  37794. * Gets camera class name
  37795. * @returns VRDeviceOrientationFreeCamera
  37796. */
  37797. getClassName(): string;
  37798. }
  37799. }
  37800. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  37801. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  37802. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37803. import { Scene } from "babylonjs/scene";
  37804. import { Vector3 } from "babylonjs/Maths/math";
  37805. /**
  37806. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37807. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37808. */
  37809. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37810. /**
  37811. * Creates a new VRDeviceOrientationGamepadCamera
  37812. * @param name defines camera name
  37813. * @param position defines the start position of the camera
  37814. * @param scene defines the scene the camera belongs to
  37815. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37816. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37817. */
  37818. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37819. /**
  37820. * Gets camera class name
  37821. * @returns VRDeviceOrientationGamepadCamera
  37822. */
  37823. getClassName(): string;
  37824. }
  37825. }
  37826. declare module "babylonjs/Gamepads/xboxGamepad" {
  37827. import { Observable } from "babylonjs/Misc/observable";
  37828. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37829. /**
  37830. * Defines supported buttons for XBox360 compatible gamepads
  37831. */
  37832. export enum Xbox360Button {
  37833. /** A */
  37834. A = 0,
  37835. /** B */
  37836. B = 1,
  37837. /** X */
  37838. X = 2,
  37839. /** Y */
  37840. Y = 3,
  37841. /** Start */
  37842. Start = 4,
  37843. /** Back */
  37844. Back = 5,
  37845. /** Left button */
  37846. LB = 6,
  37847. /** Right button */
  37848. RB = 7,
  37849. /** Left stick */
  37850. LeftStick = 8,
  37851. /** Right stick */
  37852. RightStick = 9
  37853. }
  37854. /** Defines values for XBox360 DPad */
  37855. export enum Xbox360Dpad {
  37856. /** Up */
  37857. Up = 0,
  37858. /** Down */
  37859. Down = 1,
  37860. /** Left */
  37861. Left = 2,
  37862. /** Right */
  37863. Right = 3
  37864. }
  37865. /**
  37866. * Defines a XBox360 gamepad
  37867. */
  37868. export class Xbox360Pad extends Gamepad {
  37869. private _leftTrigger;
  37870. private _rightTrigger;
  37871. private _onlefttriggerchanged;
  37872. private _onrighttriggerchanged;
  37873. private _onbuttondown;
  37874. private _onbuttonup;
  37875. private _ondpaddown;
  37876. private _ondpadup;
  37877. /** Observable raised when a button is pressed */
  37878. onButtonDownObservable: Observable<Xbox360Button>;
  37879. /** Observable raised when a button is released */
  37880. onButtonUpObservable: Observable<Xbox360Button>;
  37881. /** Observable raised when a pad is pressed */
  37882. onPadDownObservable: Observable<Xbox360Dpad>;
  37883. /** Observable raised when a pad is released */
  37884. onPadUpObservable: Observable<Xbox360Dpad>;
  37885. private _buttonA;
  37886. private _buttonB;
  37887. private _buttonX;
  37888. private _buttonY;
  37889. private _buttonBack;
  37890. private _buttonStart;
  37891. private _buttonLB;
  37892. private _buttonRB;
  37893. private _buttonLeftStick;
  37894. private _buttonRightStick;
  37895. private _dPadUp;
  37896. private _dPadDown;
  37897. private _dPadLeft;
  37898. private _dPadRight;
  37899. private _isXboxOnePad;
  37900. /**
  37901. * Creates a new XBox360 gamepad object
  37902. * @param id defines the id of this gamepad
  37903. * @param index defines its index
  37904. * @param gamepad defines the internal HTML gamepad object
  37905. * @param xboxOne defines if it is a XBox One gamepad
  37906. */
  37907. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37908. /**
  37909. * Defines the callback to call when left trigger is pressed
  37910. * @param callback defines the callback to use
  37911. */
  37912. onlefttriggerchanged(callback: (value: number) => void): void;
  37913. /**
  37914. * Defines the callback to call when right trigger is pressed
  37915. * @param callback defines the callback to use
  37916. */
  37917. onrighttriggerchanged(callback: (value: number) => void): void;
  37918. /**
  37919. * Gets the left trigger value
  37920. */
  37921. /**
  37922. * Sets the left trigger value
  37923. */
  37924. leftTrigger: number;
  37925. /**
  37926. * Gets the right trigger value
  37927. */
  37928. /**
  37929. * Sets the right trigger value
  37930. */
  37931. rightTrigger: number;
  37932. /**
  37933. * Defines the callback to call when a button is pressed
  37934. * @param callback defines the callback to use
  37935. */
  37936. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37937. /**
  37938. * Defines the callback to call when a button is released
  37939. * @param callback defines the callback to use
  37940. */
  37941. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37942. /**
  37943. * Defines the callback to call when a pad is pressed
  37944. * @param callback defines the callback to use
  37945. */
  37946. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37947. /**
  37948. * Defines the callback to call when a pad is released
  37949. * @param callback defines the callback to use
  37950. */
  37951. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37952. private _setButtonValue;
  37953. private _setDPadValue;
  37954. /**
  37955. * Gets the value of the `A` button
  37956. */
  37957. /**
  37958. * Sets the value of the `A` button
  37959. */
  37960. buttonA: number;
  37961. /**
  37962. * Gets the value of the `B` button
  37963. */
  37964. /**
  37965. * Sets the value of the `B` button
  37966. */
  37967. buttonB: number;
  37968. /**
  37969. * Gets the value of the `X` button
  37970. */
  37971. /**
  37972. * Sets the value of the `X` button
  37973. */
  37974. buttonX: number;
  37975. /**
  37976. * Gets the value of the `Y` button
  37977. */
  37978. /**
  37979. * Sets the value of the `Y` button
  37980. */
  37981. buttonY: number;
  37982. /**
  37983. * Gets the value of the `Start` button
  37984. */
  37985. /**
  37986. * Sets the value of the `Start` button
  37987. */
  37988. buttonStart: number;
  37989. /**
  37990. * Gets the value of the `Back` button
  37991. */
  37992. /**
  37993. * Sets the value of the `Back` button
  37994. */
  37995. buttonBack: number;
  37996. /**
  37997. * Gets the value of the `Left` button
  37998. */
  37999. /**
  38000. * Sets the value of the `Left` button
  38001. */
  38002. buttonLB: number;
  38003. /**
  38004. * Gets the value of the `Right` button
  38005. */
  38006. /**
  38007. * Sets the value of the `Right` button
  38008. */
  38009. buttonRB: number;
  38010. /**
  38011. * Gets the value of the Left joystick
  38012. */
  38013. /**
  38014. * Sets the value of the Left joystick
  38015. */
  38016. buttonLeftStick: number;
  38017. /**
  38018. * Gets the value of the Right joystick
  38019. */
  38020. /**
  38021. * Sets the value of the Right joystick
  38022. */
  38023. buttonRightStick: number;
  38024. /**
  38025. * Gets the value of D-pad up
  38026. */
  38027. /**
  38028. * Sets the value of D-pad up
  38029. */
  38030. dPadUp: number;
  38031. /**
  38032. * Gets the value of D-pad down
  38033. */
  38034. /**
  38035. * Sets the value of D-pad down
  38036. */
  38037. dPadDown: number;
  38038. /**
  38039. * Gets the value of D-pad left
  38040. */
  38041. /**
  38042. * Sets the value of D-pad left
  38043. */
  38044. dPadLeft: number;
  38045. /**
  38046. * Gets the value of D-pad right
  38047. */
  38048. /**
  38049. * Sets the value of D-pad right
  38050. */
  38051. dPadRight: number;
  38052. /**
  38053. * Force the gamepad to synchronize with device values
  38054. */
  38055. update(): void;
  38056. /**
  38057. * Disposes the gamepad
  38058. */
  38059. dispose(): void;
  38060. }
  38061. }
  38062. declare module "babylonjs/Materials/pushMaterial" {
  38063. import { Nullable } from "babylonjs/types";
  38064. import { Scene } from "babylonjs/scene";
  38065. import { Matrix } from "babylonjs/Maths/math";
  38066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38067. import { Mesh } from "babylonjs/Meshes/mesh";
  38068. import { Material } from "babylonjs/Materials/material";
  38069. import { Effect } from "babylonjs/Materials/effect";
  38070. /**
  38071. * Base class of materials working in push mode in babylon JS
  38072. * @hidden
  38073. */
  38074. export class PushMaterial extends Material {
  38075. protected _activeEffect: Effect;
  38076. protected _normalMatrix: Matrix;
  38077. /**
  38078. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38079. * This means that the material can keep using a previous shader while a new one is being compiled.
  38080. * This is mostly used when shader parallel compilation is supported (true by default)
  38081. */
  38082. allowShaderHotSwapping: boolean;
  38083. constructor(name: string, scene: Scene);
  38084. getEffect(): Effect;
  38085. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38086. /**
  38087. * Binds the given world matrix to the active effect
  38088. *
  38089. * @param world the matrix to bind
  38090. */
  38091. bindOnlyWorldMatrix(world: Matrix): void;
  38092. /**
  38093. * Binds the given normal matrix to the active effect
  38094. *
  38095. * @param normalMatrix the matrix to bind
  38096. */
  38097. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38098. bind(world: Matrix, mesh?: Mesh): void;
  38099. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38100. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38101. }
  38102. }
  38103. declare module "babylonjs/Materials/materialFlags" {
  38104. /**
  38105. * This groups all the flags used to control the materials channel.
  38106. */
  38107. export class MaterialFlags {
  38108. private static _DiffuseTextureEnabled;
  38109. /**
  38110. * Are diffuse textures enabled in the application.
  38111. */
  38112. static DiffuseTextureEnabled: boolean;
  38113. private static _AmbientTextureEnabled;
  38114. /**
  38115. * Are ambient textures enabled in the application.
  38116. */
  38117. static AmbientTextureEnabled: boolean;
  38118. private static _OpacityTextureEnabled;
  38119. /**
  38120. * Are opacity textures enabled in the application.
  38121. */
  38122. static OpacityTextureEnabled: boolean;
  38123. private static _ReflectionTextureEnabled;
  38124. /**
  38125. * Are reflection textures enabled in the application.
  38126. */
  38127. static ReflectionTextureEnabled: boolean;
  38128. private static _EmissiveTextureEnabled;
  38129. /**
  38130. * Are emissive textures enabled in the application.
  38131. */
  38132. static EmissiveTextureEnabled: boolean;
  38133. private static _SpecularTextureEnabled;
  38134. /**
  38135. * Are specular textures enabled in the application.
  38136. */
  38137. static SpecularTextureEnabled: boolean;
  38138. private static _BumpTextureEnabled;
  38139. /**
  38140. * Are bump textures enabled in the application.
  38141. */
  38142. static BumpTextureEnabled: boolean;
  38143. private static _LightmapTextureEnabled;
  38144. /**
  38145. * Are lightmap textures enabled in the application.
  38146. */
  38147. static LightmapTextureEnabled: boolean;
  38148. private static _RefractionTextureEnabled;
  38149. /**
  38150. * Are refraction textures enabled in the application.
  38151. */
  38152. static RefractionTextureEnabled: boolean;
  38153. private static _ColorGradingTextureEnabled;
  38154. /**
  38155. * Are color grading textures enabled in the application.
  38156. */
  38157. static ColorGradingTextureEnabled: boolean;
  38158. private static _FresnelEnabled;
  38159. /**
  38160. * Are fresnels enabled in the application.
  38161. */
  38162. static FresnelEnabled: boolean;
  38163. }
  38164. }
  38165. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38166. /** @hidden */
  38167. export var defaultFragmentDeclaration: {
  38168. name: string;
  38169. shader: string;
  38170. };
  38171. }
  38172. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38173. /** @hidden */
  38174. export var defaultUboDeclaration: {
  38175. name: string;
  38176. shader: string;
  38177. };
  38178. }
  38179. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38180. /** @hidden */
  38181. export var lightFragmentDeclaration: {
  38182. name: string;
  38183. shader: string;
  38184. };
  38185. }
  38186. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38187. /** @hidden */
  38188. export var lightUboDeclaration: {
  38189. name: string;
  38190. shader: string;
  38191. };
  38192. }
  38193. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38194. /** @hidden */
  38195. export var lightsFragmentFunctions: {
  38196. name: string;
  38197. shader: string;
  38198. };
  38199. }
  38200. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38201. /** @hidden */
  38202. export var shadowsFragmentFunctions: {
  38203. name: string;
  38204. shader: string;
  38205. };
  38206. }
  38207. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38208. /** @hidden */
  38209. export var fresnelFunction: {
  38210. name: string;
  38211. shader: string;
  38212. };
  38213. }
  38214. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38215. /** @hidden */
  38216. export var reflectionFunction: {
  38217. name: string;
  38218. shader: string;
  38219. };
  38220. }
  38221. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38222. /** @hidden */
  38223. export var bumpFragmentFunctions: {
  38224. name: string;
  38225. shader: string;
  38226. };
  38227. }
  38228. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38229. /** @hidden */
  38230. export var logDepthDeclaration: {
  38231. name: string;
  38232. shader: string;
  38233. };
  38234. }
  38235. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38236. /** @hidden */
  38237. export var bumpFragment: {
  38238. name: string;
  38239. shader: string;
  38240. };
  38241. }
  38242. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38243. /** @hidden */
  38244. export var depthPrePass: {
  38245. name: string;
  38246. shader: string;
  38247. };
  38248. }
  38249. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38250. /** @hidden */
  38251. export var lightFragment: {
  38252. name: string;
  38253. shader: string;
  38254. };
  38255. }
  38256. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38257. /** @hidden */
  38258. export var logDepthFragment: {
  38259. name: string;
  38260. shader: string;
  38261. };
  38262. }
  38263. declare module "babylonjs/Shaders/default.fragment" {
  38264. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38265. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38266. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38267. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38268. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38269. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38270. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38271. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38272. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38273. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38274. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38275. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38276. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38277. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38278. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38279. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38280. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38281. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38282. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38283. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38284. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38285. /** @hidden */
  38286. export var defaultPixelShader: {
  38287. name: string;
  38288. shader: string;
  38289. };
  38290. }
  38291. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38292. /** @hidden */
  38293. export var defaultVertexDeclaration: {
  38294. name: string;
  38295. shader: string;
  38296. };
  38297. }
  38298. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38299. /** @hidden */
  38300. export var bumpVertexDeclaration: {
  38301. name: string;
  38302. shader: string;
  38303. };
  38304. }
  38305. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38306. /** @hidden */
  38307. export var bumpVertex: {
  38308. name: string;
  38309. shader: string;
  38310. };
  38311. }
  38312. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38313. /** @hidden */
  38314. export var fogVertex: {
  38315. name: string;
  38316. shader: string;
  38317. };
  38318. }
  38319. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38320. /** @hidden */
  38321. export var shadowsVertex: {
  38322. name: string;
  38323. shader: string;
  38324. };
  38325. }
  38326. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38327. /** @hidden */
  38328. export var pointCloudVertex: {
  38329. name: string;
  38330. shader: string;
  38331. };
  38332. }
  38333. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38334. /** @hidden */
  38335. export var logDepthVertex: {
  38336. name: string;
  38337. shader: string;
  38338. };
  38339. }
  38340. declare module "babylonjs/Shaders/default.vertex" {
  38341. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38342. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38343. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38344. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38345. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38346. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38347. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38348. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38349. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38350. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38351. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38352. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38353. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38354. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38355. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38356. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38357. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38358. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38359. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38360. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38361. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38362. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38363. /** @hidden */
  38364. export var defaultVertexShader: {
  38365. name: string;
  38366. shader: string;
  38367. };
  38368. }
  38369. declare module "babylonjs/Materials/standardMaterial" {
  38370. import { SmartArray } from "babylonjs/Misc/smartArray";
  38371. import { IAnimatable } from "babylonjs/Misc/tools";
  38372. import { Nullable } from "babylonjs/types";
  38373. import { Scene } from "babylonjs/scene";
  38374. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38375. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38377. import { Mesh } from "babylonjs/Meshes/mesh";
  38378. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38379. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38380. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38381. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38382. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38383. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38384. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38385. import "babylonjs/Shaders/default.fragment";
  38386. import "babylonjs/Shaders/default.vertex";
  38387. /** @hidden */
  38388. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38389. MAINUV1: boolean;
  38390. MAINUV2: boolean;
  38391. DIFFUSE: boolean;
  38392. DIFFUSEDIRECTUV: number;
  38393. AMBIENT: boolean;
  38394. AMBIENTDIRECTUV: number;
  38395. OPACITY: boolean;
  38396. OPACITYDIRECTUV: number;
  38397. OPACITYRGB: boolean;
  38398. REFLECTION: boolean;
  38399. EMISSIVE: boolean;
  38400. EMISSIVEDIRECTUV: number;
  38401. SPECULAR: boolean;
  38402. SPECULARDIRECTUV: number;
  38403. BUMP: boolean;
  38404. BUMPDIRECTUV: number;
  38405. PARALLAX: boolean;
  38406. PARALLAXOCCLUSION: boolean;
  38407. SPECULAROVERALPHA: boolean;
  38408. CLIPPLANE: boolean;
  38409. CLIPPLANE2: boolean;
  38410. CLIPPLANE3: boolean;
  38411. CLIPPLANE4: boolean;
  38412. ALPHATEST: boolean;
  38413. DEPTHPREPASS: boolean;
  38414. ALPHAFROMDIFFUSE: boolean;
  38415. POINTSIZE: boolean;
  38416. FOG: boolean;
  38417. SPECULARTERM: boolean;
  38418. DIFFUSEFRESNEL: boolean;
  38419. OPACITYFRESNEL: boolean;
  38420. REFLECTIONFRESNEL: boolean;
  38421. REFRACTIONFRESNEL: boolean;
  38422. EMISSIVEFRESNEL: boolean;
  38423. FRESNEL: boolean;
  38424. NORMAL: boolean;
  38425. UV1: boolean;
  38426. UV2: boolean;
  38427. VERTEXCOLOR: boolean;
  38428. VERTEXALPHA: boolean;
  38429. NUM_BONE_INFLUENCERS: number;
  38430. BonesPerMesh: number;
  38431. BONETEXTURE: boolean;
  38432. INSTANCES: boolean;
  38433. GLOSSINESS: boolean;
  38434. ROUGHNESS: boolean;
  38435. EMISSIVEASILLUMINATION: boolean;
  38436. LINKEMISSIVEWITHDIFFUSE: boolean;
  38437. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38438. LIGHTMAP: boolean;
  38439. LIGHTMAPDIRECTUV: number;
  38440. OBJECTSPACE_NORMALMAP: boolean;
  38441. USELIGHTMAPASSHADOWMAP: boolean;
  38442. REFLECTIONMAP_3D: boolean;
  38443. REFLECTIONMAP_SPHERICAL: boolean;
  38444. REFLECTIONMAP_PLANAR: boolean;
  38445. REFLECTIONMAP_CUBIC: boolean;
  38446. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38447. REFLECTIONMAP_PROJECTION: boolean;
  38448. REFLECTIONMAP_SKYBOX: boolean;
  38449. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38450. REFLECTIONMAP_EXPLICIT: boolean;
  38451. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38452. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38453. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38454. INVERTCUBICMAP: boolean;
  38455. LOGARITHMICDEPTH: boolean;
  38456. REFRACTION: boolean;
  38457. REFRACTIONMAP_3D: boolean;
  38458. REFLECTIONOVERALPHA: boolean;
  38459. TWOSIDEDLIGHTING: boolean;
  38460. SHADOWFLOAT: boolean;
  38461. MORPHTARGETS: boolean;
  38462. MORPHTARGETS_NORMAL: boolean;
  38463. MORPHTARGETS_TANGENT: boolean;
  38464. NUM_MORPH_INFLUENCERS: number;
  38465. NONUNIFORMSCALING: boolean;
  38466. PREMULTIPLYALPHA: boolean;
  38467. IMAGEPROCESSING: boolean;
  38468. VIGNETTE: boolean;
  38469. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38470. VIGNETTEBLENDMODEOPAQUE: boolean;
  38471. TONEMAPPING: boolean;
  38472. TONEMAPPING_ACES: boolean;
  38473. CONTRAST: boolean;
  38474. COLORCURVES: boolean;
  38475. COLORGRADING: boolean;
  38476. COLORGRADING3D: boolean;
  38477. SAMPLER3DGREENDEPTH: boolean;
  38478. SAMPLER3DBGRMAP: boolean;
  38479. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38480. /**
  38481. * If the reflection texture on this material is in linear color space
  38482. * @hidden
  38483. */
  38484. IS_REFLECTION_LINEAR: boolean;
  38485. /**
  38486. * If the refraction texture on this material is in linear color space
  38487. * @hidden
  38488. */
  38489. IS_REFRACTION_LINEAR: boolean;
  38490. EXPOSURE: boolean;
  38491. constructor();
  38492. setReflectionMode(modeToEnable: string): void;
  38493. }
  38494. /**
  38495. * This is the default material used in Babylon. It is the best trade off between quality
  38496. * and performances.
  38497. * @see http://doc.babylonjs.com/babylon101/materials
  38498. */
  38499. export class StandardMaterial extends PushMaterial {
  38500. private _diffuseTexture;
  38501. /**
  38502. * The basic texture of the material as viewed under a light.
  38503. */
  38504. diffuseTexture: Nullable<BaseTexture>;
  38505. private _ambientTexture;
  38506. /**
  38507. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38508. */
  38509. ambientTexture: Nullable<BaseTexture>;
  38510. private _opacityTexture;
  38511. /**
  38512. * Define the transparency of the material from a texture.
  38513. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38514. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38515. */
  38516. opacityTexture: Nullable<BaseTexture>;
  38517. private _reflectionTexture;
  38518. /**
  38519. * Define the texture used to display the reflection.
  38520. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38521. */
  38522. reflectionTexture: Nullable<BaseTexture>;
  38523. private _emissiveTexture;
  38524. /**
  38525. * Define texture of the material as if self lit.
  38526. * This will be mixed in the final result even in the absence of light.
  38527. */
  38528. emissiveTexture: Nullable<BaseTexture>;
  38529. private _specularTexture;
  38530. /**
  38531. * Define how the color and intensity of the highlight given by the light in the material.
  38532. */
  38533. specularTexture: Nullable<BaseTexture>;
  38534. private _bumpTexture;
  38535. /**
  38536. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38537. * 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.
  38538. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38539. */
  38540. bumpTexture: Nullable<BaseTexture>;
  38541. private _lightmapTexture;
  38542. /**
  38543. * Complex lighting can be computationally expensive to compute at runtime.
  38544. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38545. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38546. */
  38547. lightmapTexture: Nullable<BaseTexture>;
  38548. private _refractionTexture;
  38549. /**
  38550. * Define the texture used to display the refraction.
  38551. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38552. */
  38553. refractionTexture: Nullable<BaseTexture>;
  38554. /**
  38555. * The color of the material lit by the environmental background lighting.
  38556. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38557. */
  38558. ambientColor: Color3;
  38559. /**
  38560. * The basic color of the material as viewed under a light.
  38561. */
  38562. diffuseColor: Color3;
  38563. /**
  38564. * Define how the color and intensity of the highlight given by the light in the material.
  38565. */
  38566. specularColor: Color3;
  38567. /**
  38568. * Define the color of the material as if self lit.
  38569. * This will be mixed in the final result even in the absence of light.
  38570. */
  38571. emissiveColor: Color3;
  38572. /**
  38573. * Defines how sharp are the highlights in the material.
  38574. * The bigger the value the sharper giving a more glossy feeling to the result.
  38575. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38576. */
  38577. specularPower: number;
  38578. private _useAlphaFromDiffuseTexture;
  38579. /**
  38580. * Does the transparency come from the diffuse texture alpha channel.
  38581. */
  38582. useAlphaFromDiffuseTexture: boolean;
  38583. private _useEmissiveAsIllumination;
  38584. /**
  38585. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38586. */
  38587. useEmissiveAsIllumination: boolean;
  38588. private _linkEmissiveWithDiffuse;
  38589. /**
  38590. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38591. * the emissive level when the final color is close to one.
  38592. */
  38593. linkEmissiveWithDiffuse: boolean;
  38594. private _useSpecularOverAlpha;
  38595. /**
  38596. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38597. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38598. */
  38599. useSpecularOverAlpha: boolean;
  38600. private _useReflectionOverAlpha;
  38601. /**
  38602. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38603. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38604. */
  38605. useReflectionOverAlpha: boolean;
  38606. private _disableLighting;
  38607. /**
  38608. * Does lights from the scene impacts this material.
  38609. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38610. */
  38611. disableLighting: boolean;
  38612. private _useObjectSpaceNormalMap;
  38613. /**
  38614. * Allows using an object space normal map (instead of tangent space).
  38615. */
  38616. useObjectSpaceNormalMap: boolean;
  38617. private _useParallax;
  38618. /**
  38619. * Is parallax enabled or not.
  38620. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38621. */
  38622. useParallax: boolean;
  38623. private _useParallaxOcclusion;
  38624. /**
  38625. * Is parallax occlusion enabled or not.
  38626. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38627. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38628. */
  38629. useParallaxOcclusion: boolean;
  38630. /**
  38631. * 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.
  38632. */
  38633. parallaxScaleBias: number;
  38634. private _roughness;
  38635. /**
  38636. * Helps to define how blurry the reflections should appears in the material.
  38637. */
  38638. roughness: number;
  38639. /**
  38640. * In case of refraction, define the value of the indice of refraction.
  38641. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38642. */
  38643. indexOfRefraction: number;
  38644. /**
  38645. * Invert the refraction texture alongside the y axis.
  38646. * It can be useful with procedural textures or probe for instance.
  38647. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38648. */
  38649. invertRefractionY: boolean;
  38650. /**
  38651. * Defines the alpha limits in alpha test mode.
  38652. */
  38653. alphaCutOff: number;
  38654. private _useLightmapAsShadowmap;
  38655. /**
  38656. * In case of light mapping, define whether the map contains light or shadow informations.
  38657. */
  38658. useLightmapAsShadowmap: boolean;
  38659. private _diffuseFresnelParameters;
  38660. /**
  38661. * Define the diffuse fresnel parameters of the material.
  38662. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38663. */
  38664. diffuseFresnelParameters: FresnelParameters;
  38665. private _opacityFresnelParameters;
  38666. /**
  38667. * Define the opacity fresnel parameters of the material.
  38668. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38669. */
  38670. opacityFresnelParameters: FresnelParameters;
  38671. private _reflectionFresnelParameters;
  38672. /**
  38673. * Define the reflection fresnel parameters of the material.
  38674. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38675. */
  38676. reflectionFresnelParameters: FresnelParameters;
  38677. private _refractionFresnelParameters;
  38678. /**
  38679. * Define the refraction fresnel parameters of the material.
  38680. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38681. */
  38682. refractionFresnelParameters: FresnelParameters;
  38683. private _emissiveFresnelParameters;
  38684. /**
  38685. * Define the emissive fresnel parameters of the material.
  38686. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38687. */
  38688. emissiveFresnelParameters: FresnelParameters;
  38689. private _useReflectionFresnelFromSpecular;
  38690. /**
  38691. * If true automatically deducts the fresnels values from the material specularity.
  38692. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38693. */
  38694. useReflectionFresnelFromSpecular: boolean;
  38695. private _useGlossinessFromSpecularMapAlpha;
  38696. /**
  38697. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38698. */
  38699. useGlossinessFromSpecularMapAlpha: boolean;
  38700. private _maxSimultaneousLights;
  38701. /**
  38702. * Defines the maximum number of lights that can be used in the material
  38703. */
  38704. maxSimultaneousLights: number;
  38705. private _invertNormalMapX;
  38706. /**
  38707. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38708. */
  38709. invertNormalMapX: boolean;
  38710. private _invertNormalMapY;
  38711. /**
  38712. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38713. */
  38714. invertNormalMapY: boolean;
  38715. private _twoSidedLighting;
  38716. /**
  38717. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38718. */
  38719. twoSidedLighting: boolean;
  38720. /**
  38721. * Default configuration related to image processing available in the standard Material.
  38722. */
  38723. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38724. /**
  38725. * Gets the image processing configuration used either in this material.
  38726. */
  38727. /**
  38728. * Sets the Default image processing configuration used either in the this material.
  38729. *
  38730. * If sets to null, the scene one is in use.
  38731. */
  38732. imageProcessingConfiguration: ImageProcessingConfiguration;
  38733. /**
  38734. * Keep track of the image processing observer to allow dispose and replace.
  38735. */
  38736. private _imageProcessingObserver;
  38737. /**
  38738. * Attaches a new image processing configuration to the Standard Material.
  38739. * @param configuration
  38740. */
  38741. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38742. /**
  38743. * Gets wether the color curves effect is enabled.
  38744. */
  38745. /**
  38746. * Sets wether the color curves effect is enabled.
  38747. */
  38748. cameraColorCurvesEnabled: boolean;
  38749. /**
  38750. * Gets wether the color grading effect is enabled.
  38751. */
  38752. /**
  38753. * Gets wether the color grading effect is enabled.
  38754. */
  38755. cameraColorGradingEnabled: boolean;
  38756. /**
  38757. * Gets wether tonemapping is enabled or not.
  38758. */
  38759. /**
  38760. * Sets wether tonemapping is enabled or not
  38761. */
  38762. cameraToneMappingEnabled: boolean;
  38763. /**
  38764. * The camera exposure used on this material.
  38765. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38766. * This corresponds to a photographic exposure.
  38767. */
  38768. /**
  38769. * The camera exposure used on this material.
  38770. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38771. * This corresponds to a photographic exposure.
  38772. */
  38773. cameraExposure: number;
  38774. /**
  38775. * Gets The camera contrast used on this material.
  38776. */
  38777. /**
  38778. * Sets The camera contrast used on this material.
  38779. */
  38780. cameraContrast: number;
  38781. /**
  38782. * Gets the Color Grading 2D Lookup Texture.
  38783. */
  38784. /**
  38785. * Sets the Color Grading 2D Lookup Texture.
  38786. */
  38787. cameraColorGradingTexture: Nullable<BaseTexture>;
  38788. /**
  38789. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38790. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38791. * 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;
  38792. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38793. */
  38794. /**
  38795. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38796. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38797. * 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;
  38798. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38799. */
  38800. cameraColorCurves: Nullable<ColorCurves>;
  38801. /**
  38802. * Custom callback helping to override the default shader used in the material.
  38803. */
  38804. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38805. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38806. protected _worldViewProjectionMatrix: Matrix;
  38807. protected _globalAmbientColor: Color3;
  38808. protected _useLogarithmicDepth: boolean;
  38809. /**
  38810. * Instantiates a new standard material.
  38811. * This is the default material used in Babylon. It is the best trade off between quality
  38812. * and performances.
  38813. * @see http://doc.babylonjs.com/babylon101/materials
  38814. * @param name Define the name of the material in the scene
  38815. * @param scene Define the scene the material belong to
  38816. */
  38817. constructor(name: string, scene: Scene);
  38818. /**
  38819. * Gets a boolean indicating that current material needs to register RTT
  38820. */
  38821. readonly hasRenderTargetTextures: boolean;
  38822. /**
  38823. * Gets the current class name of the material e.g. "StandardMaterial"
  38824. * Mainly use in serialization.
  38825. * @returns the class name
  38826. */
  38827. getClassName(): string;
  38828. /**
  38829. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38830. * You can try switching to logarithmic depth.
  38831. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38832. */
  38833. useLogarithmicDepth: boolean;
  38834. /**
  38835. * Specifies if the material will require alpha blending
  38836. * @returns a boolean specifying if alpha blending is needed
  38837. */
  38838. needAlphaBlending(): boolean;
  38839. /**
  38840. * Specifies if this material should be rendered in alpha test mode
  38841. * @returns a boolean specifying if an alpha test is needed.
  38842. */
  38843. needAlphaTesting(): boolean;
  38844. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38845. /**
  38846. * Get the texture used for alpha test purpose.
  38847. * @returns the diffuse texture in case of the standard material.
  38848. */
  38849. getAlphaTestTexture(): Nullable<BaseTexture>;
  38850. /**
  38851. * Get if the submesh is ready to be used and all its information available.
  38852. * Child classes can use it to update shaders
  38853. * @param mesh defines the mesh to check
  38854. * @param subMesh defines which submesh to check
  38855. * @param useInstances specifies that instances should be used
  38856. * @returns a boolean indicating that the submesh is ready or not
  38857. */
  38858. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38859. /**
  38860. * Builds the material UBO layouts.
  38861. * Used internally during the effect preparation.
  38862. */
  38863. buildUniformLayout(): void;
  38864. /**
  38865. * Unbinds the material from the mesh
  38866. */
  38867. unbind(): void;
  38868. /**
  38869. * Binds the submesh to this material by preparing the effect and shader to draw
  38870. * @param world defines the world transformation matrix
  38871. * @param mesh defines the mesh containing the submesh
  38872. * @param subMesh defines the submesh to bind the material to
  38873. */
  38874. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38875. /**
  38876. * Get the list of animatables in the material.
  38877. * @returns the list of animatables object used in the material
  38878. */
  38879. getAnimatables(): IAnimatable[];
  38880. /**
  38881. * Gets the active textures from the material
  38882. * @returns an array of textures
  38883. */
  38884. getActiveTextures(): BaseTexture[];
  38885. /**
  38886. * Specifies if the material uses a texture
  38887. * @param texture defines the texture to check against the material
  38888. * @returns a boolean specifying if the material uses the texture
  38889. */
  38890. hasTexture(texture: BaseTexture): boolean;
  38891. /**
  38892. * Disposes the material
  38893. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38894. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38895. */
  38896. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38897. /**
  38898. * Makes a duplicate of the material, and gives it a new name
  38899. * @param name defines the new name for the duplicated material
  38900. * @returns the cloned material
  38901. */
  38902. clone(name: string): StandardMaterial;
  38903. /**
  38904. * Serializes this material in a JSON representation
  38905. * @returns the serialized material object
  38906. */
  38907. serialize(): any;
  38908. /**
  38909. * Creates a standard material from parsed material data
  38910. * @param source defines the JSON representation of the material
  38911. * @param scene defines the hosting scene
  38912. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38913. * @returns a new standard material
  38914. */
  38915. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38916. /**
  38917. * Are diffuse textures enabled in the application.
  38918. */
  38919. static DiffuseTextureEnabled: boolean;
  38920. /**
  38921. * Are ambient textures enabled in the application.
  38922. */
  38923. static AmbientTextureEnabled: boolean;
  38924. /**
  38925. * Are opacity textures enabled in the application.
  38926. */
  38927. static OpacityTextureEnabled: boolean;
  38928. /**
  38929. * Are reflection textures enabled in the application.
  38930. */
  38931. static ReflectionTextureEnabled: boolean;
  38932. /**
  38933. * Are emissive textures enabled in the application.
  38934. */
  38935. static EmissiveTextureEnabled: boolean;
  38936. /**
  38937. * Are specular textures enabled in the application.
  38938. */
  38939. static SpecularTextureEnabled: boolean;
  38940. /**
  38941. * Are bump textures enabled in the application.
  38942. */
  38943. static BumpTextureEnabled: boolean;
  38944. /**
  38945. * Are lightmap textures enabled in the application.
  38946. */
  38947. static LightmapTextureEnabled: boolean;
  38948. /**
  38949. * Are refraction textures enabled in the application.
  38950. */
  38951. static RefractionTextureEnabled: boolean;
  38952. /**
  38953. * Are color grading textures enabled in the application.
  38954. */
  38955. static ColorGradingTextureEnabled: boolean;
  38956. /**
  38957. * Are fresnels enabled in the application.
  38958. */
  38959. static FresnelEnabled: boolean;
  38960. }
  38961. }
  38962. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  38963. import { Scene } from "babylonjs/scene";
  38964. import { Texture } from "babylonjs/Materials/Textures/texture";
  38965. /**
  38966. * A class extending Texture allowing drawing on a texture
  38967. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38968. */
  38969. export class DynamicTexture extends Texture {
  38970. private _generateMipMaps;
  38971. private _canvas;
  38972. private _context;
  38973. private _engine;
  38974. /**
  38975. * Creates a DynamicTexture
  38976. * @param name defines the name of the texture
  38977. * @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
  38978. * @param scene defines the scene where you want the texture
  38979. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38980. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38981. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38982. */
  38983. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38984. /**
  38985. * Get the current class name of the texture useful for serialization or dynamic coding.
  38986. * @returns "DynamicTexture"
  38987. */
  38988. getClassName(): string;
  38989. /**
  38990. * Gets the current state of canRescale
  38991. */
  38992. readonly canRescale: boolean;
  38993. private _recreate;
  38994. /**
  38995. * Scales the texture
  38996. * @param ratio the scale factor to apply to both width and height
  38997. */
  38998. scale(ratio: number): void;
  38999. /**
  39000. * Resizes the texture
  39001. * @param width the new width
  39002. * @param height the new height
  39003. */
  39004. scaleTo(width: number, height: number): void;
  39005. /**
  39006. * Gets the context of the canvas used by the texture
  39007. * @returns the canvas context of the dynamic texture
  39008. */
  39009. getContext(): CanvasRenderingContext2D;
  39010. /**
  39011. * Clears the texture
  39012. */
  39013. clear(): void;
  39014. /**
  39015. * Updates the texture
  39016. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39017. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39018. */
  39019. update(invertY?: boolean, premulAlpha?: boolean): void;
  39020. /**
  39021. * Draws text onto the texture
  39022. * @param text defines the text to be drawn
  39023. * @param x defines the placement of the text from the left
  39024. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39025. * @param font defines the font to be used with font-style, font-size, font-name
  39026. * @param color defines the color used for the text
  39027. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39028. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39029. * @param update defines whether texture is immediately update (default is true)
  39030. */
  39031. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39032. /**
  39033. * Clones the texture
  39034. * @returns the clone of the texture.
  39035. */
  39036. clone(): DynamicTexture;
  39037. /**
  39038. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39039. * @returns a serialized dynamic texture object
  39040. */
  39041. serialize(): any;
  39042. /** @hidden */
  39043. _rebuild(): void;
  39044. }
  39045. }
  39046. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39047. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39048. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39049. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39050. /** @hidden */
  39051. export var imageProcessingPixelShader: {
  39052. name: string;
  39053. shader: string;
  39054. };
  39055. }
  39056. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39057. import { Nullable } from "babylonjs/types";
  39058. import { Color4 } from "babylonjs/Maths/math";
  39059. import { Camera } from "babylonjs/Cameras/camera";
  39060. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39061. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39062. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39063. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39064. import { Engine } from "babylonjs/Engines/engine";
  39065. import "babylonjs/Shaders/imageProcessing.fragment";
  39066. import "babylonjs/Shaders/postprocess.vertex";
  39067. /**
  39068. * ImageProcessingPostProcess
  39069. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39070. */
  39071. export class ImageProcessingPostProcess extends PostProcess {
  39072. /**
  39073. * Default configuration related to image processing available in the PBR Material.
  39074. */
  39075. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39076. /**
  39077. * Gets the image processing configuration used either in this material.
  39078. */
  39079. /**
  39080. * Sets the Default image processing configuration used either in the this material.
  39081. *
  39082. * If sets to null, the scene one is in use.
  39083. */
  39084. imageProcessingConfiguration: ImageProcessingConfiguration;
  39085. /**
  39086. * Keep track of the image processing observer to allow dispose and replace.
  39087. */
  39088. private _imageProcessingObserver;
  39089. /**
  39090. * Attaches a new image processing configuration to the PBR Material.
  39091. * @param configuration
  39092. */
  39093. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39094. /**
  39095. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39096. */
  39097. /**
  39098. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39099. */
  39100. colorCurves: Nullable<ColorCurves>;
  39101. /**
  39102. * Gets wether the color curves effect is enabled.
  39103. */
  39104. /**
  39105. * Sets wether the color curves effect is enabled.
  39106. */
  39107. colorCurvesEnabled: boolean;
  39108. /**
  39109. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39110. */
  39111. /**
  39112. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39113. */
  39114. colorGradingTexture: Nullable<BaseTexture>;
  39115. /**
  39116. * Gets wether the color grading effect is enabled.
  39117. */
  39118. /**
  39119. * Gets wether the color grading effect is enabled.
  39120. */
  39121. colorGradingEnabled: boolean;
  39122. /**
  39123. * Gets exposure used in the effect.
  39124. */
  39125. /**
  39126. * Sets exposure used in the effect.
  39127. */
  39128. exposure: number;
  39129. /**
  39130. * Gets wether tonemapping is enabled or not.
  39131. */
  39132. /**
  39133. * Sets wether tonemapping is enabled or not
  39134. */
  39135. toneMappingEnabled: boolean;
  39136. /**
  39137. * Gets contrast used in the effect.
  39138. */
  39139. /**
  39140. * Sets contrast used in the effect.
  39141. */
  39142. contrast: number;
  39143. /**
  39144. * Gets Vignette stretch size.
  39145. */
  39146. /**
  39147. * Sets Vignette stretch size.
  39148. */
  39149. vignetteStretch: number;
  39150. /**
  39151. * Gets Vignette centre X Offset.
  39152. */
  39153. /**
  39154. * Sets Vignette centre X Offset.
  39155. */
  39156. vignetteCentreX: number;
  39157. /**
  39158. * Gets Vignette centre Y Offset.
  39159. */
  39160. /**
  39161. * Sets Vignette centre Y Offset.
  39162. */
  39163. vignetteCentreY: number;
  39164. /**
  39165. * Gets Vignette weight or intensity of the vignette effect.
  39166. */
  39167. /**
  39168. * Sets Vignette weight or intensity of the vignette effect.
  39169. */
  39170. vignetteWeight: number;
  39171. /**
  39172. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39173. * if vignetteEnabled is set to true.
  39174. */
  39175. /**
  39176. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39177. * if vignetteEnabled is set to true.
  39178. */
  39179. vignetteColor: Color4;
  39180. /**
  39181. * Gets Camera field of view used by the Vignette effect.
  39182. */
  39183. /**
  39184. * Sets Camera field of view used by the Vignette effect.
  39185. */
  39186. vignetteCameraFov: number;
  39187. /**
  39188. * Gets the vignette blend mode allowing different kind of effect.
  39189. */
  39190. /**
  39191. * Sets the vignette blend mode allowing different kind of effect.
  39192. */
  39193. vignetteBlendMode: number;
  39194. /**
  39195. * Gets wether the vignette effect is enabled.
  39196. */
  39197. /**
  39198. * Sets wether the vignette effect is enabled.
  39199. */
  39200. vignetteEnabled: boolean;
  39201. private _fromLinearSpace;
  39202. /**
  39203. * Gets wether the input of the processing is in Gamma or Linear Space.
  39204. */
  39205. /**
  39206. * Sets wether the input of the processing is in Gamma or Linear Space.
  39207. */
  39208. fromLinearSpace: boolean;
  39209. /**
  39210. * Defines cache preventing GC.
  39211. */
  39212. private _defines;
  39213. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39214. /**
  39215. * "ImageProcessingPostProcess"
  39216. * @returns "ImageProcessingPostProcess"
  39217. */
  39218. getClassName(): string;
  39219. protected _updateParameters(): void;
  39220. dispose(camera?: Camera): void;
  39221. }
  39222. }
  39223. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39224. import { Scene } from "babylonjs/scene";
  39225. import { Color3 } from "babylonjs/Maths/math";
  39226. import { Mesh } from "babylonjs/Meshes/mesh";
  39227. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39228. /**
  39229. * Class containing static functions to help procedurally build meshes
  39230. */
  39231. export class GroundBuilder {
  39232. /**
  39233. * Creates a ground mesh
  39234. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39235. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39237. * @param name defines the name of the mesh
  39238. * @param options defines the options used to create the mesh
  39239. * @param scene defines the hosting scene
  39240. * @returns the ground mesh
  39241. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39242. */
  39243. static CreateGround(name: string, options: {
  39244. width?: number;
  39245. height?: number;
  39246. subdivisions?: number;
  39247. subdivisionsX?: number;
  39248. subdivisionsY?: number;
  39249. updatable?: boolean;
  39250. }, scene: any): Mesh;
  39251. /**
  39252. * Creates a tiled ground mesh
  39253. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39254. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39255. * * 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
  39256. * * 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
  39257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39258. * @param name defines the name of the mesh
  39259. * @param options defines the options used to create the mesh
  39260. * @param scene defines the hosting scene
  39261. * @returns the tiled ground mesh
  39262. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39263. */
  39264. static CreateTiledGround(name: string, options: {
  39265. xmin: number;
  39266. zmin: number;
  39267. xmax: number;
  39268. zmax: number;
  39269. subdivisions?: {
  39270. w: number;
  39271. h: number;
  39272. };
  39273. precision?: {
  39274. w: number;
  39275. h: number;
  39276. };
  39277. updatable?: boolean;
  39278. }, scene: Scene): Mesh;
  39279. /**
  39280. * Creates a ground mesh from a height map
  39281. * * The parameter `url` sets the URL of the height map image resource.
  39282. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39283. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39284. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39285. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39286. * * 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.
  39287. * * 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).
  39288. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39290. * @param name defines the name of the mesh
  39291. * @param url defines the url to the height map
  39292. * @param options defines the options used to create the mesh
  39293. * @param scene defines the hosting scene
  39294. * @returns the ground mesh
  39295. * @see https://doc.babylonjs.com/babylon101/height_map
  39296. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39297. */
  39298. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39299. width?: number;
  39300. height?: number;
  39301. subdivisions?: number;
  39302. minHeight?: number;
  39303. maxHeight?: number;
  39304. colorFilter?: Color3;
  39305. alphaFilter?: number;
  39306. updatable?: boolean;
  39307. onReady?: (mesh: GroundMesh) => void;
  39308. }, scene: Scene): GroundMesh;
  39309. }
  39310. }
  39311. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39312. import { Vector4 } from "babylonjs/Maths/math";
  39313. import { Mesh } from "babylonjs/Meshes/mesh";
  39314. /**
  39315. * Class containing static functions to help procedurally build meshes
  39316. */
  39317. export class TorusBuilder {
  39318. /**
  39319. * Creates a torus mesh
  39320. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39321. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39322. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39324. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39326. * @param name defines the name of the mesh
  39327. * @param options defines the options used to create the mesh
  39328. * @param scene defines the hosting scene
  39329. * @returns the torus mesh
  39330. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39331. */
  39332. static CreateTorus(name: string, options: {
  39333. diameter?: number;
  39334. thickness?: number;
  39335. tessellation?: number;
  39336. updatable?: boolean;
  39337. sideOrientation?: number;
  39338. frontUVs?: Vector4;
  39339. backUVs?: Vector4;
  39340. }, scene: any): Mesh;
  39341. }
  39342. }
  39343. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39344. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39345. import { Mesh } from "babylonjs/Meshes/mesh";
  39346. /**
  39347. * Class containing static functions to help procedurally build meshes
  39348. */
  39349. export class CylinderBuilder {
  39350. /**
  39351. * Creates a cylinder or a cone mesh
  39352. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39353. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39354. * * 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.
  39355. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39356. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39357. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39358. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39359. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39360. * * 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).
  39361. * * 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
  39362. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39363. * * 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
  39364. * * 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.
  39365. * * If `enclose` is false, a ring surface is one element.
  39366. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39367. * * 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
  39368. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39369. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39371. * @param name defines the name of the mesh
  39372. * @param options defines the options used to create the mesh
  39373. * @param scene defines the hosting scene
  39374. * @returns the cylinder mesh
  39375. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39376. */
  39377. static CreateCylinder(name: string, options: {
  39378. height?: number;
  39379. diameterTop?: number;
  39380. diameterBottom?: number;
  39381. diameter?: number;
  39382. tessellation?: number;
  39383. subdivisions?: number;
  39384. arc?: number;
  39385. faceColors?: Color4[];
  39386. faceUV?: Vector4[];
  39387. updatable?: boolean;
  39388. hasRings?: boolean;
  39389. enclose?: boolean;
  39390. sideOrientation?: number;
  39391. frontUVs?: Vector4;
  39392. backUVs?: Vector4;
  39393. }, scene: any): Mesh;
  39394. }
  39395. }
  39396. declare module "babylonjs/Gamepads/gamepadManager" {
  39397. import { Observable } from "babylonjs/Misc/observable";
  39398. import { Nullable } from "babylonjs/types";
  39399. import { Scene } from "babylonjs/scene";
  39400. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39401. /**
  39402. * Manager for handling gamepads
  39403. */
  39404. export class GamepadManager {
  39405. private _scene?;
  39406. private _babylonGamepads;
  39407. private _oneGamepadConnected;
  39408. /** @hidden */
  39409. _isMonitoring: boolean;
  39410. private _gamepadEventSupported;
  39411. private _gamepadSupport;
  39412. /**
  39413. * observable to be triggered when the gamepad controller has been connected
  39414. */
  39415. onGamepadConnectedObservable: Observable<Gamepad>;
  39416. /**
  39417. * observable to be triggered when the gamepad controller has been disconnected
  39418. */
  39419. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39420. private _onGamepadConnectedEvent;
  39421. private _onGamepadDisconnectedEvent;
  39422. /**
  39423. * Initializes the gamepad manager
  39424. * @param _scene BabylonJS scene
  39425. */
  39426. constructor(_scene?: Scene | undefined);
  39427. /**
  39428. * The gamepads in the game pad manager
  39429. */
  39430. readonly gamepads: Gamepad[];
  39431. /**
  39432. * Get the gamepad controllers based on type
  39433. * @param type The type of gamepad controller
  39434. * @returns Nullable gamepad
  39435. */
  39436. getGamepadByType(type?: number): Nullable<Gamepad>;
  39437. /**
  39438. * Disposes the gamepad manager
  39439. */
  39440. dispose(): void;
  39441. private _addNewGamepad;
  39442. private _startMonitoringGamepads;
  39443. private _stopMonitoringGamepads;
  39444. /** @hidden */
  39445. _checkGamepadsStatus(): void;
  39446. private _updateGamepadObjects;
  39447. }
  39448. }
  39449. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39450. import { Nullable } from "babylonjs/types";
  39451. import { Scene } from "babylonjs/scene";
  39452. import { ISceneComponent } from "babylonjs/sceneComponent";
  39453. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39454. module "babylonjs/scene" {
  39455. interface Scene {
  39456. /** @hidden */
  39457. _gamepadManager: Nullable<GamepadManager>;
  39458. /**
  39459. * Gets the gamepad manager associated with the scene
  39460. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39461. */
  39462. gamepadManager: GamepadManager;
  39463. }
  39464. }
  39465. module "babylonjs/Cameras/freeCameraInputsManager" {
  39466. /**
  39467. * Interface representing a free camera inputs manager
  39468. */
  39469. interface FreeCameraInputsManager {
  39470. /**
  39471. * Adds gamepad input support to the FreeCameraInputsManager.
  39472. * @returns the FreeCameraInputsManager
  39473. */
  39474. addGamepad(): FreeCameraInputsManager;
  39475. }
  39476. }
  39477. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39478. /**
  39479. * Interface representing an arc rotate camera inputs manager
  39480. */
  39481. interface ArcRotateCameraInputsManager {
  39482. /**
  39483. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39484. * @returns the camera inputs manager
  39485. */
  39486. addGamepad(): ArcRotateCameraInputsManager;
  39487. }
  39488. }
  39489. /**
  39490. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39491. */
  39492. export class GamepadSystemSceneComponent implements ISceneComponent {
  39493. /**
  39494. * The component name helpfull to identify the component in the list of scene components.
  39495. */
  39496. readonly name: string;
  39497. /**
  39498. * The scene the component belongs to.
  39499. */
  39500. scene: Scene;
  39501. /**
  39502. * Creates a new instance of the component for the given scene
  39503. * @param scene Defines the scene to register the component in
  39504. */
  39505. constructor(scene: Scene);
  39506. /**
  39507. * Registers the component in a given scene
  39508. */
  39509. register(): void;
  39510. /**
  39511. * Rebuilds the elements related to this component in case of
  39512. * context lost for instance.
  39513. */
  39514. rebuild(): void;
  39515. /**
  39516. * Disposes the component and the associated ressources
  39517. */
  39518. dispose(): void;
  39519. private _beforeCameraUpdate;
  39520. }
  39521. }
  39522. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  39523. import { Observable } from "babylonjs/Misc/observable";
  39524. import { Nullable } from "babylonjs/types";
  39525. import { Camera } from "babylonjs/Cameras/camera";
  39526. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39527. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39528. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  39529. import { Scene } from "babylonjs/scene";
  39530. import { Vector3, Color3 } from "babylonjs/Maths/math";
  39531. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  39532. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39533. import { Mesh } from "babylonjs/Meshes/mesh";
  39534. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39535. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39536. import "babylonjs/Meshes/Builders/groundBuilder";
  39537. import "babylonjs/Meshes/Builders/torusBuilder";
  39538. import "babylonjs/Meshes/Builders/cylinderBuilder";
  39539. import "babylonjs/Gamepads/gamepadSceneComponent";
  39540. import "babylonjs/Animations/animatable";
  39541. /**
  39542. * Options to modify the vr teleportation behavior.
  39543. */
  39544. export interface VRTeleportationOptions {
  39545. /**
  39546. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39547. */
  39548. floorMeshName?: string;
  39549. /**
  39550. * A list of meshes to be used as the teleportation floor. (default: empty)
  39551. */
  39552. floorMeshes?: Mesh[];
  39553. }
  39554. /**
  39555. * Options to modify the vr experience helper's behavior.
  39556. */
  39557. export interface VRExperienceHelperOptions extends WebVROptions {
  39558. /**
  39559. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39560. */
  39561. createDeviceOrientationCamera?: boolean;
  39562. /**
  39563. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39564. */
  39565. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39566. /**
  39567. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39568. */
  39569. laserToggle?: boolean;
  39570. /**
  39571. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39572. */
  39573. floorMeshes?: Mesh[];
  39574. /**
  39575. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39576. */
  39577. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39578. }
  39579. /**
  39580. * Helps to quickly add VR support to an existing scene.
  39581. * See http://doc.babylonjs.com/how_to/webvr_helper
  39582. */
  39583. export class VRExperienceHelper {
  39584. /** Options to modify the vr experience helper's behavior. */
  39585. webVROptions: VRExperienceHelperOptions;
  39586. private _scene;
  39587. private _position;
  39588. private _btnVR;
  39589. private _btnVRDisplayed;
  39590. private _webVRsupported;
  39591. private _webVRready;
  39592. private _webVRrequesting;
  39593. private _webVRpresenting;
  39594. private _hasEnteredVR;
  39595. private _fullscreenVRpresenting;
  39596. private _canvas;
  39597. private _webVRCamera;
  39598. private _vrDeviceOrientationCamera;
  39599. private _deviceOrientationCamera;
  39600. private _existingCamera;
  39601. private _onKeyDown;
  39602. private _onVrDisplayPresentChange;
  39603. private _onVRDisplayChanged;
  39604. private _onVRRequestPresentStart;
  39605. private _onVRRequestPresentComplete;
  39606. /**
  39607. * Observable raised when entering VR.
  39608. */
  39609. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39610. /**
  39611. * Observable raised when exiting VR.
  39612. */
  39613. onExitingVRObservable: Observable<VRExperienceHelper>;
  39614. /**
  39615. * Observable raised when controller mesh is loaded.
  39616. */
  39617. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39618. /** Return this.onEnteringVRObservable
  39619. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39620. */
  39621. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39622. /** Return this.onExitingVRObservable
  39623. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39624. */
  39625. readonly onExitingVR: Observable<VRExperienceHelper>;
  39626. /** Return this.onControllerMeshLoadedObservable
  39627. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39628. */
  39629. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39630. private _rayLength;
  39631. private _useCustomVRButton;
  39632. private _teleportationRequested;
  39633. private _teleportActive;
  39634. private _floorMeshName;
  39635. private _floorMeshesCollection;
  39636. private _rotationAllowed;
  39637. private _teleportBackwardsVector;
  39638. private _teleportationTarget;
  39639. private _isDefaultTeleportationTarget;
  39640. private _postProcessMove;
  39641. private _teleportationFillColor;
  39642. private _teleportationBorderColor;
  39643. private _rotationAngle;
  39644. private _haloCenter;
  39645. private _cameraGazer;
  39646. private _padSensibilityUp;
  39647. private _padSensibilityDown;
  39648. private _leftController;
  39649. private _rightController;
  39650. /**
  39651. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39652. */
  39653. onNewMeshSelected: Observable<AbstractMesh>;
  39654. /**
  39655. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39656. */
  39657. onNewMeshPicked: Observable<PickingInfo>;
  39658. private _circleEase;
  39659. /**
  39660. * Observable raised before camera teleportation
  39661. */
  39662. onBeforeCameraTeleport: Observable<Vector3>;
  39663. /**
  39664. * Observable raised after camera teleportation
  39665. */
  39666. onAfterCameraTeleport: Observable<Vector3>;
  39667. /**
  39668. * Observable raised when current selected mesh gets unselected
  39669. */
  39670. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39671. private _raySelectionPredicate;
  39672. /**
  39673. * To be optionaly changed by user to define custom ray selection
  39674. */
  39675. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39676. /**
  39677. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39678. */
  39679. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39680. /**
  39681. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39682. */
  39683. teleportationEnabled: boolean;
  39684. private _defaultHeight;
  39685. private _teleportationInitialized;
  39686. private _interactionsEnabled;
  39687. private _interactionsRequested;
  39688. private _displayGaze;
  39689. private _displayLaserPointer;
  39690. /**
  39691. * The mesh used to display where the user is going to teleport.
  39692. */
  39693. /**
  39694. * Sets the mesh to be used to display where the user is going to teleport.
  39695. */
  39696. teleportationTarget: Mesh;
  39697. /**
  39698. * 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
  39699. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39700. * See http://doc.babylonjs.com/resources/baking_transformations
  39701. */
  39702. gazeTrackerMesh: Mesh;
  39703. /**
  39704. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39705. */
  39706. updateGazeTrackerScale: boolean;
  39707. /**
  39708. * If the gaze trackers color should be updated when selecting meshes
  39709. */
  39710. updateGazeTrackerColor: boolean;
  39711. /**
  39712. * The gaze tracking mesh corresponding to the left controller
  39713. */
  39714. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39715. /**
  39716. * The gaze tracking mesh corresponding to the right controller
  39717. */
  39718. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39719. /**
  39720. * If the ray of the gaze should be displayed.
  39721. */
  39722. /**
  39723. * Sets if the ray of the gaze should be displayed.
  39724. */
  39725. displayGaze: boolean;
  39726. /**
  39727. * If the ray of the LaserPointer should be displayed.
  39728. */
  39729. /**
  39730. * Sets if the ray of the LaserPointer should be displayed.
  39731. */
  39732. displayLaserPointer: boolean;
  39733. /**
  39734. * The deviceOrientationCamera used as the camera when not in VR.
  39735. */
  39736. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39737. /**
  39738. * Based on the current WebVR support, returns the current VR camera used.
  39739. */
  39740. readonly currentVRCamera: Nullable<Camera>;
  39741. /**
  39742. * The webVRCamera which is used when in VR.
  39743. */
  39744. readonly webVRCamera: WebVRFreeCamera;
  39745. /**
  39746. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39747. */
  39748. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39749. private readonly _teleportationRequestInitiated;
  39750. /**
  39751. * Instantiates a VRExperienceHelper.
  39752. * Helps to quickly add VR support to an existing scene.
  39753. * @param scene The scene the VRExperienceHelper belongs to.
  39754. * @param webVROptions Options to modify the vr experience helper's behavior.
  39755. */
  39756. constructor(scene: Scene,
  39757. /** Options to modify the vr experience helper's behavior. */
  39758. webVROptions?: VRExperienceHelperOptions);
  39759. private _onDefaultMeshLoaded;
  39760. private _onResize;
  39761. private _onFullscreenChange;
  39762. /**
  39763. * Gets a value indicating if we are currently in VR mode.
  39764. */
  39765. readonly isInVRMode: boolean;
  39766. private onVrDisplayPresentChange;
  39767. private onVRDisplayChanged;
  39768. private moveButtonToBottomRight;
  39769. private displayVRButton;
  39770. private updateButtonVisibility;
  39771. private _cachedAngularSensibility;
  39772. /**
  39773. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39774. * Otherwise, will use the fullscreen API.
  39775. */
  39776. enterVR(): void;
  39777. /**
  39778. * Attempt to exit VR, or fullscreen.
  39779. */
  39780. exitVR(): void;
  39781. /**
  39782. * The position of the vr experience helper.
  39783. */
  39784. /**
  39785. * Sets the position of the vr experience helper.
  39786. */
  39787. position: Vector3;
  39788. /**
  39789. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39790. */
  39791. enableInteractions(): void;
  39792. private readonly _noControllerIsActive;
  39793. private beforeRender;
  39794. private _isTeleportationFloor;
  39795. /**
  39796. * Adds a floor mesh to be used for teleportation.
  39797. * @param floorMesh the mesh to be used for teleportation.
  39798. */
  39799. addFloorMesh(floorMesh: Mesh): void;
  39800. /**
  39801. * Removes a floor mesh from being used for teleportation.
  39802. * @param floorMesh the mesh to be removed.
  39803. */
  39804. removeFloorMesh(floorMesh: Mesh): void;
  39805. /**
  39806. * Enables interactions and teleportation using the VR controllers and gaze.
  39807. * @param vrTeleportationOptions options to modify teleportation behavior.
  39808. */
  39809. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39810. private _onNewGamepadConnected;
  39811. private _tryEnableInteractionOnController;
  39812. private _onNewGamepadDisconnected;
  39813. private _enableInteractionOnController;
  39814. private _checkTeleportWithRay;
  39815. private _checkRotate;
  39816. private _checkTeleportBackwards;
  39817. private _enableTeleportationOnController;
  39818. private _createTeleportationCircles;
  39819. private _displayTeleportationTarget;
  39820. private _hideTeleportationTarget;
  39821. private _rotateCamera;
  39822. private _moveTeleportationSelectorTo;
  39823. private _workingVector;
  39824. private _workingQuaternion;
  39825. private _workingMatrix;
  39826. /**
  39827. * Teleports the users feet to the desired location
  39828. * @param location The location where the user's feet should be placed
  39829. */
  39830. teleportCamera(location: Vector3): void;
  39831. private _convertNormalToDirectionOfRay;
  39832. private _castRayAndSelectObject;
  39833. private _notifySelectedMeshUnselected;
  39834. /**
  39835. * Sets the color of the laser ray from the vr controllers.
  39836. * @param color new color for the ray.
  39837. */
  39838. changeLaserColor(color: Color3): void;
  39839. /**
  39840. * Sets the color of the ray from the vr headsets gaze.
  39841. * @param color new color for the ray.
  39842. */
  39843. changeGazeColor(color: Color3): void;
  39844. /**
  39845. * Exits VR and disposes of the vr experience helper
  39846. */
  39847. dispose(): void;
  39848. /**
  39849. * Gets the name of the VRExperienceHelper class
  39850. * @returns "VRExperienceHelper"
  39851. */
  39852. getClassName(): string;
  39853. }
  39854. }
  39855. declare module "babylonjs/Cameras/VR/index" {
  39856. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  39857. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  39858. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39859. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  39860. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  39861. export * from "babylonjs/Cameras/VR/webVRCamera";
  39862. }
  39863. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  39864. import { Observable } from "babylonjs/Misc/observable";
  39865. import { Nullable } from "babylonjs/types";
  39866. import { IDisposable, Scene } from "babylonjs/scene";
  39867. import { Vector3 } from "babylonjs/Maths/math";
  39868. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39869. import { Ray } from "babylonjs/Culling/ray";
  39870. /**
  39871. * Manages an XRSession
  39872. * @see https://doc.babylonjs.com/how_to/webxr
  39873. */
  39874. export class WebXRSessionManager implements IDisposable {
  39875. private scene;
  39876. /**
  39877. * Fires every time a new xrFrame arrives which can be used to update the camera
  39878. */
  39879. onXRFrameObservable: Observable<any>;
  39880. /**
  39881. * Fires when the xr session is ended either by the device or manually done
  39882. */
  39883. onXRSessionEnded: Observable<any>;
  39884. /** @hidden */
  39885. _xrSession: XRSession;
  39886. /** @hidden */
  39887. _frameOfReference: XRFrameOfReference;
  39888. /** @hidden */
  39889. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39890. /** @hidden */
  39891. _currentXRFrame: Nullable<XRFrame>;
  39892. private _xrNavigator;
  39893. private _xrDevice;
  39894. private _tmpMatrix;
  39895. /**
  39896. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39897. * @param scene The scene which the session should be created for
  39898. */
  39899. constructor(scene: Scene);
  39900. /**
  39901. * Initializes the manager
  39902. * After initialization enterXR can be called to start an XR session
  39903. * @returns Promise which resolves after it is initialized
  39904. */
  39905. initializeAsync(): Promise<void>;
  39906. /**
  39907. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39908. * @param sessionCreationOptions xr options to create the session with
  39909. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39910. * @returns Promise which resolves after it enters XR
  39911. */
  39912. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39913. /**
  39914. * Stops the xrSession and restores the renderloop
  39915. * @returns Promise which resolves after it exits XR
  39916. */
  39917. exitXRAsync(): Promise<void>;
  39918. /**
  39919. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39920. * @param ray ray to cast into the environment
  39921. * @returns Promise which resolves with a collision point in the environment if it exists
  39922. */
  39923. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39924. /**
  39925. * Checks if a session would be supported for the creation options specified
  39926. * @param options creation options to check if they are supported
  39927. * @returns true if supported
  39928. */
  39929. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39930. /**
  39931. * @hidden
  39932. * Converts the render layer of xrSession to a render target
  39933. * @param session session to create render target for
  39934. * @param scene scene the new render target should be created for
  39935. */
  39936. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39937. /**
  39938. * Disposes of the session manager
  39939. */
  39940. dispose(): void;
  39941. }
  39942. }
  39943. declare module "babylonjs/Cameras/XR/webXRCamera" {
  39944. import { Scene } from "babylonjs/scene";
  39945. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39946. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  39947. /**
  39948. * WebXR Camera which holds the views for the xrSession
  39949. * @see https://doc.babylonjs.com/how_to/webxr
  39950. */
  39951. export class WebXRCamera extends FreeCamera {
  39952. private static _TmpMatrix;
  39953. /**
  39954. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39955. * @param name the name of the camera
  39956. * @param scene the scene to add the camera to
  39957. */
  39958. constructor(name: string, scene: Scene);
  39959. private _updateNumberOfRigCameras;
  39960. /** @hidden */
  39961. _updateForDualEyeDebugging(pupilDistance?: number): void;
  39962. /**
  39963. * Updates the cameras position from the current pose information of the XR session
  39964. * @param xrSessionManager the session containing pose information
  39965. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39966. */
  39967. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39968. }
  39969. }
  39970. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  39971. import { Nullable } from "babylonjs/types";
  39972. import { Observable } from "babylonjs/Misc/observable";
  39973. import { IDisposable, Scene } from "babylonjs/scene";
  39974. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  39975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39976. import { Ray } from "babylonjs/Culling/ray";
  39977. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  39978. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  39979. /**
  39980. * States of the webXR experience
  39981. */
  39982. export enum WebXRState {
  39983. /**
  39984. * Transitioning to being in XR mode
  39985. */
  39986. ENTERING_XR = 0,
  39987. /**
  39988. * Transitioning to non XR mode
  39989. */
  39990. EXITING_XR = 1,
  39991. /**
  39992. * In XR mode and presenting
  39993. */
  39994. IN_XR = 2,
  39995. /**
  39996. * Not entered XR mode
  39997. */
  39998. NOT_IN_XR = 3
  39999. }
  40000. /**
  40001. * Helper class used to enable XR
  40002. * @see https://doc.babylonjs.com/how_to/webxr
  40003. */
  40004. export class WebXRExperienceHelper implements IDisposable {
  40005. private scene;
  40006. /**
  40007. * 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
  40008. */
  40009. container: AbstractMesh;
  40010. /**
  40011. * Camera used to render xr content
  40012. */
  40013. camera: WebXRCamera;
  40014. /**
  40015. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40016. */
  40017. state: WebXRState;
  40018. private _setState;
  40019. private static _TmpVector;
  40020. /**
  40021. * Fires when the state of the experience helper has changed
  40022. */
  40023. onStateChangedObservable: Observable<WebXRState>;
  40024. /** @hidden */
  40025. _sessionManager: WebXRSessionManager;
  40026. private _nonVRCamera;
  40027. private _originalSceneAutoClear;
  40028. private _supported;
  40029. /**
  40030. * Creates the experience helper
  40031. * @param scene the scene to attach the experience helper to
  40032. * @returns a promise for the experience helper
  40033. */
  40034. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40035. /**
  40036. * Creates a WebXRExperienceHelper
  40037. * @param scene The scene the helper should be created in
  40038. */
  40039. private constructor();
  40040. /**
  40041. * Exits XR mode and returns the scene to its original state
  40042. * @returns promise that resolves after xr mode has exited
  40043. */
  40044. exitXRAsync(): Promise<void>;
  40045. /**
  40046. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40047. * @param sessionCreationOptions options for the XR session
  40048. * @param frameOfReference frame of reference of the XR session
  40049. * @returns promise that resolves after xr mode has entered
  40050. */
  40051. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40052. /**
  40053. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40054. * @param ray ray to cast into the environment
  40055. * @returns Promise which resolves with a collision point in the environment if it exists
  40056. */
  40057. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40058. /**
  40059. * Updates the global position of the camera by moving the camera's container
  40060. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40061. * @param position The desired global position of the camera
  40062. */
  40063. setPositionOfCameraUsingContainer(position: Vector3): void;
  40064. /**
  40065. * Rotates the xr camera by rotating the camera's container around the camera's position
  40066. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40067. * @param rotation the desired quaternion rotation to apply to the camera
  40068. */
  40069. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40070. /**
  40071. * Checks if the creation options are supported by the xr session
  40072. * @param options creation options
  40073. * @returns true if supported
  40074. */
  40075. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40076. /**
  40077. * Disposes of the experience helper
  40078. */
  40079. dispose(): void;
  40080. }
  40081. }
  40082. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40083. import { Nullable } from "babylonjs/types";
  40084. import { Observable } from "babylonjs/Misc/observable";
  40085. import { IDisposable, Scene } from "babylonjs/scene";
  40086. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40087. /**
  40088. * Button which can be used to enter a different mode of XR
  40089. */
  40090. export class WebXREnterExitUIButton {
  40091. /** button element */
  40092. element: HTMLElement;
  40093. /** XR initialization options for the button */
  40094. initializationOptions: XRSessionCreationOptions;
  40095. /**
  40096. * Creates a WebXREnterExitUIButton
  40097. * @param element button element
  40098. * @param initializationOptions XR initialization options for the button
  40099. */
  40100. constructor(
  40101. /** button element */
  40102. element: HTMLElement,
  40103. /** XR initialization options for the button */
  40104. initializationOptions: XRSessionCreationOptions);
  40105. /**
  40106. * Overwritable function which can be used to update the button's visuals when the state changes
  40107. * @param activeButton the current active button in the UI
  40108. */
  40109. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40110. }
  40111. /**
  40112. * Options to create the webXR UI
  40113. */
  40114. export class WebXREnterExitUIOptions {
  40115. /**
  40116. * Context to enter xr with
  40117. */
  40118. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40119. /**
  40120. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40121. */
  40122. customButtons?: Array<WebXREnterExitUIButton>;
  40123. }
  40124. /**
  40125. * UI to allow the user to enter/exit XR mode
  40126. */
  40127. export class WebXREnterExitUI implements IDisposable {
  40128. private scene;
  40129. private _overlay;
  40130. private _buttons;
  40131. private _activeButton;
  40132. /**
  40133. * Fired every time the active button is changed.
  40134. *
  40135. * When xr is entered via a button that launches xr that button will be the callback parameter
  40136. *
  40137. * When exiting xr the callback parameter will be null)
  40138. */
  40139. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40140. /**
  40141. * Creates UI to allow the user to enter/exit XR mode
  40142. * @param scene the scene to add the ui to
  40143. * @param helper the xr experience helper to enter/exit xr with
  40144. * @param options options to configure the UI
  40145. * @returns the created ui
  40146. */
  40147. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40148. private constructor();
  40149. private _updateButtons;
  40150. /**
  40151. * Disposes of the object
  40152. */
  40153. dispose(): void;
  40154. }
  40155. }
  40156. declare module "babylonjs/Cameras/XR/webXRInput" {
  40157. import { IDisposable, Scene } from "babylonjs/scene";
  40158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40159. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40160. /**
  40161. * Represents an XR input
  40162. */
  40163. export class WebXRController {
  40164. /**
  40165. * 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
  40166. */
  40167. grip?: AbstractMesh;
  40168. /**
  40169. * Pointer which can be used to select objects or attach a visible laser to
  40170. */
  40171. pointer: AbstractMesh;
  40172. /**
  40173. * Creates the controller
  40174. * @see https://doc.babylonjs.com/how_to/webxr
  40175. * @param scene the scene which the controller should be associated to
  40176. */
  40177. constructor(scene: Scene);
  40178. /**
  40179. * Disposes of the object
  40180. */
  40181. dispose(): void;
  40182. }
  40183. /**
  40184. * XR input used to track XR inputs such as controllers/rays
  40185. */
  40186. export class WebXRInput implements IDisposable {
  40187. private helper;
  40188. /**
  40189. * XR controllers being tracked
  40190. */
  40191. controllers: Array<WebXRController>;
  40192. private _tmpMatrix;
  40193. private _frameObserver;
  40194. /**
  40195. * Initializes the WebXRInput
  40196. * @param helper experience helper which the input should be created for
  40197. */
  40198. constructor(helper: WebXRExperienceHelper);
  40199. /**
  40200. * Disposes of the object
  40201. */
  40202. dispose(): void;
  40203. }
  40204. }
  40205. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40206. import { Nullable } from "babylonjs/types";
  40207. import { IDisposable } from "babylonjs/scene";
  40208. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40209. /**
  40210. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40211. */
  40212. export class WebXRManagedOutputCanvas implements IDisposable {
  40213. private _canvas;
  40214. /**
  40215. * xrpresent context of the canvas which can be used to display/mirror xr content
  40216. */
  40217. canvasContext: Nullable<WebGLRenderingContext>;
  40218. /**
  40219. * Initializes the canvas to be added/removed upon entering/exiting xr
  40220. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40221. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40222. */
  40223. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40224. /**
  40225. * Disposes of the object
  40226. */
  40227. dispose(): void;
  40228. private _setManagedOutputCanvas;
  40229. private _addCanvas;
  40230. private _removeCanvas;
  40231. }
  40232. }
  40233. declare module "babylonjs/Cameras/XR/index" {
  40234. export * from "babylonjs/Cameras/XR/webXRCamera";
  40235. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40236. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40237. export * from "babylonjs/Cameras/XR/webXRInput";
  40238. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40239. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40240. }
  40241. declare module "babylonjs/Cameras/RigModes/index" {
  40242. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40243. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40244. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40245. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40246. }
  40247. declare module "babylonjs/Cameras/index" {
  40248. export * from "babylonjs/Cameras/Inputs/index";
  40249. export * from "babylonjs/Cameras/cameraInputsManager";
  40250. export * from "babylonjs/Cameras/camera";
  40251. export * from "babylonjs/Cameras/targetCamera";
  40252. export * from "babylonjs/Cameras/freeCamera";
  40253. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40254. export * from "babylonjs/Cameras/touchCamera";
  40255. export * from "babylonjs/Cameras/arcRotateCamera";
  40256. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40257. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40258. export * from "babylonjs/Cameras/flyCamera";
  40259. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40260. export * from "babylonjs/Cameras/followCamera";
  40261. export * from "babylonjs/Cameras/gamepadCamera";
  40262. export * from "babylonjs/Cameras/Stereoscopic/index";
  40263. export * from "babylonjs/Cameras/universalCamera";
  40264. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40265. export * from "babylonjs/Cameras/VR/index";
  40266. export * from "babylonjs/Cameras/XR/index";
  40267. export * from "babylonjs/Cameras/RigModes/index";
  40268. }
  40269. declare module "babylonjs/Collisions/index" {
  40270. export * from "babylonjs/Collisions/collider";
  40271. export * from "babylonjs/Collisions/collisionCoordinator";
  40272. export * from "babylonjs/Collisions/pickingInfo";
  40273. export * from "babylonjs/Collisions/intersectionInfo";
  40274. }
  40275. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40276. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40277. import { Vector3, Plane } from "babylonjs/Maths/math";
  40278. import { Ray } from "babylonjs/Culling/ray";
  40279. /**
  40280. * Contains an array of blocks representing the octree
  40281. */
  40282. export interface IOctreeContainer<T> {
  40283. /**
  40284. * Blocks within the octree
  40285. */
  40286. blocks: Array<OctreeBlock<T>>;
  40287. }
  40288. /**
  40289. * Class used to store a cell in an octree
  40290. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40291. */
  40292. export class OctreeBlock<T> {
  40293. /**
  40294. * Gets the content of the current block
  40295. */
  40296. entries: T[];
  40297. /**
  40298. * Gets the list of block children
  40299. */
  40300. blocks: Array<OctreeBlock<T>>;
  40301. private _depth;
  40302. private _maxDepth;
  40303. private _capacity;
  40304. private _minPoint;
  40305. private _maxPoint;
  40306. private _boundingVectors;
  40307. private _creationFunc;
  40308. /**
  40309. * Creates a new block
  40310. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40311. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40312. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40313. * @param depth defines the current depth of this block in the octree
  40314. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40315. * @param creationFunc defines a callback to call when an element is added to the block
  40316. */
  40317. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40318. /**
  40319. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40320. */
  40321. readonly capacity: number;
  40322. /**
  40323. * Gets the minimum vector (in world space) of the block's bounding box
  40324. */
  40325. readonly minPoint: Vector3;
  40326. /**
  40327. * Gets the maximum vector (in world space) of the block's bounding box
  40328. */
  40329. readonly maxPoint: Vector3;
  40330. /**
  40331. * Add a new element to this block
  40332. * @param entry defines the element to add
  40333. */
  40334. addEntry(entry: T): void;
  40335. /**
  40336. * Remove an element from this block
  40337. * @param entry defines the element to remove
  40338. */
  40339. removeEntry(entry: T): void;
  40340. /**
  40341. * Add an array of elements to this block
  40342. * @param entries defines the array of elements to add
  40343. */
  40344. addEntries(entries: T[]): void;
  40345. /**
  40346. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40347. * @param frustumPlanes defines the frustum planes to test
  40348. * @param selection defines the array to store current content if selection is positive
  40349. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40350. */
  40351. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40352. /**
  40353. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40354. * @param sphereCenter defines the bounding sphere center
  40355. * @param sphereRadius defines the bounding sphere radius
  40356. * @param selection defines the array to store current content if selection is positive
  40357. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40358. */
  40359. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40360. /**
  40361. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40362. * @param ray defines the ray to test with
  40363. * @param selection defines the array to store current content if selection is positive
  40364. */
  40365. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40366. /**
  40367. * Subdivide the content into child blocks (this block will then be empty)
  40368. */
  40369. createInnerBlocks(): void;
  40370. /**
  40371. * @hidden
  40372. */
  40373. 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;
  40374. }
  40375. }
  40376. declare module "babylonjs/Culling/Octrees/octree" {
  40377. import { SmartArray } from "babylonjs/Misc/smartArray";
  40378. import { Vector3, Plane } from "babylonjs/Maths/math";
  40379. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40381. import { Ray } from "babylonjs/Culling/ray";
  40382. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40383. /**
  40384. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40385. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40386. */
  40387. export class Octree<T> {
  40388. /** 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.) */
  40389. maxDepth: number;
  40390. /**
  40391. * Blocks within the octree containing objects
  40392. */
  40393. blocks: Array<OctreeBlock<T>>;
  40394. /**
  40395. * Content stored in the octree
  40396. */
  40397. dynamicContent: T[];
  40398. private _maxBlockCapacity;
  40399. private _selectionContent;
  40400. private _creationFunc;
  40401. /**
  40402. * Creates a octree
  40403. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40404. * @param creationFunc function to be used to instatiate the octree
  40405. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40406. * @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.)
  40407. */
  40408. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40409. /** 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.) */
  40410. maxDepth?: number);
  40411. /**
  40412. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40413. * @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);
  40414. * @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);
  40415. * @param entries meshes to be added to the octree blocks
  40416. */
  40417. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40418. /**
  40419. * Adds a mesh to the octree
  40420. * @param entry Mesh to add to the octree
  40421. */
  40422. addMesh(entry: T): void;
  40423. /**
  40424. * Remove an element from the octree
  40425. * @param entry defines the element to remove
  40426. */
  40427. removeMesh(entry: T): void;
  40428. /**
  40429. * Selects an array of meshes within the frustum
  40430. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40431. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40432. * @returns array of meshes within the frustum
  40433. */
  40434. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40435. /**
  40436. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40437. * @param sphereCenter defines the bounding sphere center
  40438. * @param sphereRadius defines the bounding sphere radius
  40439. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40440. * @returns an array of objects that intersect the sphere
  40441. */
  40442. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40443. /**
  40444. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40445. * @param ray defines the ray to test with
  40446. * @returns array of intersected objects
  40447. */
  40448. intersectsRay(ray: Ray): SmartArray<T>;
  40449. /**
  40450. * Adds a mesh into the octree block if it intersects the block
  40451. */
  40452. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40453. /**
  40454. * Adds a submesh into the octree block if it intersects the block
  40455. */
  40456. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40457. }
  40458. }
  40459. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40460. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40461. import { Scene } from "babylonjs/scene";
  40462. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40464. import { Ray } from "babylonjs/Culling/ray";
  40465. import { Octree } from "babylonjs/Culling/Octrees/octree";
  40466. import { Collider } from "babylonjs/Collisions/collider";
  40467. module "babylonjs/scene" {
  40468. interface Scene {
  40469. /**
  40470. * @hidden
  40471. * Backing Filed
  40472. */
  40473. _selectionOctree: Octree<AbstractMesh>;
  40474. /**
  40475. * Gets the octree used to boost mesh selection (picking)
  40476. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40477. */
  40478. selectionOctree: Octree<AbstractMesh>;
  40479. /**
  40480. * Creates or updates the octree used to boost selection (picking)
  40481. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40482. * @param maxCapacity defines the maximum capacity per leaf
  40483. * @param maxDepth defines the maximum depth of the octree
  40484. * @returns an octree of AbstractMesh
  40485. */
  40486. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40487. }
  40488. }
  40489. module "babylonjs/Meshes/abstractMesh" {
  40490. interface AbstractMesh {
  40491. /**
  40492. * @hidden
  40493. * Backing Field
  40494. */
  40495. _submeshesOctree: Octree<SubMesh>;
  40496. /**
  40497. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40498. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40499. * @param maxCapacity defines the maximum size of each block (64 by default)
  40500. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40501. * @returns the new octree
  40502. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40503. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40504. */
  40505. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40506. }
  40507. }
  40508. /**
  40509. * Defines the octree scene component responsible to manage any octrees
  40510. * in a given scene.
  40511. */
  40512. export class OctreeSceneComponent {
  40513. /**
  40514. * The component name helpfull to identify the component in the list of scene components.
  40515. */
  40516. readonly name: string;
  40517. /**
  40518. * The scene the component belongs to.
  40519. */
  40520. scene: Scene;
  40521. /**
  40522. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40523. */
  40524. readonly checksIsEnabled: boolean;
  40525. /**
  40526. * Creates a new instance of the component for the given scene
  40527. * @param scene Defines the scene to register the component in
  40528. */
  40529. constructor(scene: Scene);
  40530. /**
  40531. * Registers the component in a given scene
  40532. */
  40533. register(): void;
  40534. /**
  40535. * Return the list of active meshes
  40536. * @returns the list of active meshes
  40537. */
  40538. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40539. /**
  40540. * Return the list of active sub meshes
  40541. * @param mesh The mesh to get the candidates sub meshes from
  40542. * @returns the list of active sub meshes
  40543. */
  40544. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40545. private _tempRay;
  40546. /**
  40547. * Return the list of sub meshes intersecting with a given local ray
  40548. * @param mesh defines the mesh to find the submesh for
  40549. * @param localRay defines the ray in local space
  40550. * @returns the list of intersecting sub meshes
  40551. */
  40552. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40553. /**
  40554. * Return the list of sub meshes colliding with a collider
  40555. * @param mesh defines the mesh to find the submesh for
  40556. * @param collider defines the collider to evaluate the collision against
  40557. * @returns the list of colliding sub meshes
  40558. */
  40559. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40560. /**
  40561. * Rebuilds the elements related to this component in case of
  40562. * context lost for instance.
  40563. */
  40564. rebuild(): void;
  40565. /**
  40566. * Disposes the component and the associated ressources.
  40567. */
  40568. dispose(): void;
  40569. }
  40570. }
  40571. declare module "babylonjs/Culling/Octrees/index" {
  40572. export * from "babylonjs/Culling/Octrees/octree";
  40573. export * from "babylonjs/Culling/Octrees/octreeBlock";
  40574. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  40575. }
  40576. declare module "babylonjs/Culling/index" {
  40577. export * from "babylonjs/Culling/boundingBox";
  40578. export * from "babylonjs/Culling/boundingInfo";
  40579. export * from "babylonjs/Culling/boundingSphere";
  40580. export * from "babylonjs/Culling/Octrees/index";
  40581. export * from "babylonjs/Culling/ray";
  40582. }
  40583. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  40584. import { Vector3, Color4 } from "babylonjs/Maths/math";
  40585. import { Nullable } from "babylonjs/types";
  40586. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  40587. import { Scene } from "babylonjs/scene";
  40588. /**
  40589. * Class containing static functions to help procedurally build meshes
  40590. */
  40591. export class LinesBuilder {
  40592. /**
  40593. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40594. * * 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
  40595. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40596. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40597. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40598. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40599. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40600. * * 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
  40601. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40603. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40604. * @param name defines the name of the new line system
  40605. * @param options defines the options used to create the line system
  40606. * @param scene defines the hosting scene
  40607. * @returns a new line system mesh
  40608. */
  40609. static CreateLineSystem(name: string, options: {
  40610. lines: Vector3[][];
  40611. updatable?: boolean;
  40612. instance?: Nullable<LinesMesh>;
  40613. colors?: Nullable<Color4[][]>;
  40614. useVertexAlpha?: boolean;
  40615. }, scene: Nullable<Scene>): LinesMesh;
  40616. /**
  40617. * Creates a line mesh
  40618. * 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
  40619. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40620. * * The parameter `points` is an array successive Vector3
  40621. * * 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
  40622. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40623. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40624. * * When updating an instance, remember that only point positions can change, not the number of points
  40625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40626. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40627. * @param name defines the name of the new line system
  40628. * @param options defines the options used to create the line system
  40629. * @param scene defines the hosting scene
  40630. * @returns a new line mesh
  40631. */
  40632. static CreateLines(name: string, options: {
  40633. points: Vector3[];
  40634. updatable?: boolean;
  40635. instance?: Nullable<LinesMesh>;
  40636. colors?: Color4[];
  40637. useVertexAlpha?: boolean;
  40638. }, scene?: Nullable<Scene>): LinesMesh;
  40639. /**
  40640. * Creates a dashed line mesh
  40641. * * 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
  40642. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40643. * * The parameter `points` is an array successive Vector3
  40644. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40645. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40646. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40647. * * 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
  40648. * * When updating an instance, remember that only point positions can change, not the number of points
  40649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40650. * @param name defines the name of the mesh
  40651. * @param options defines the options used to create the mesh
  40652. * @param scene defines the hosting scene
  40653. * @returns the dashed line mesh
  40654. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40655. */
  40656. static CreateDashedLines(name: string, options: {
  40657. points: Vector3[];
  40658. dashSize?: number;
  40659. gapSize?: number;
  40660. dashNb?: number;
  40661. updatable?: boolean;
  40662. instance?: LinesMesh;
  40663. }, scene?: Nullable<Scene>): LinesMesh;
  40664. }
  40665. }
  40666. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  40667. import { IDisposable, Scene } from "babylonjs/scene";
  40668. import { Nullable } from "babylonjs/types";
  40669. import { Observable } from "babylonjs/Misc/observable";
  40670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40671. /**
  40672. * Renders a layer on top of an existing scene
  40673. */
  40674. export class UtilityLayerRenderer implements IDisposable {
  40675. /** the original scene that will be rendered on top of */
  40676. originalScene: Scene;
  40677. private _pointerCaptures;
  40678. private _lastPointerEvents;
  40679. private static _DefaultUtilityLayer;
  40680. private static _DefaultKeepDepthUtilityLayer;
  40681. /**
  40682. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40683. */
  40684. pickUtilitySceneFirst: boolean;
  40685. /**
  40686. * 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)
  40687. */
  40688. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40689. /**
  40690. * 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)
  40691. */
  40692. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40693. /**
  40694. * The scene that is rendered on top of the original scene
  40695. */
  40696. utilityLayerScene: Scene;
  40697. /**
  40698. * If the utility layer should automatically be rendered on top of existing scene
  40699. */
  40700. shouldRender: boolean;
  40701. /**
  40702. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40703. */
  40704. onlyCheckPointerDownEvents: boolean;
  40705. /**
  40706. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40707. */
  40708. processAllEvents: boolean;
  40709. /**
  40710. * Observable raised when the pointer move from the utility layer scene to the main scene
  40711. */
  40712. onPointerOutObservable: Observable<number>;
  40713. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40714. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40715. private _afterRenderObserver;
  40716. private _sceneDisposeObserver;
  40717. private _originalPointerObserver;
  40718. /**
  40719. * Instantiates a UtilityLayerRenderer
  40720. * @param originalScene the original scene that will be rendered on top of
  40721. * @param handleEvents boolean indicating if the utility layer should handle events
  40722. */
  40723. constructor(
  40724. /** the original scene that will be rendered on top of */
  40725. originalScene: Scene, handleEvents?: boolean);
  40726. private _notifyObservers;
  40727. /**
  40728. * Renders the utility layers scene on top of the original scene
  40729. */
  40730. render(): void;
  40731. /**
  40732. * Disposes of the renderer
  40733. */
  40734. dispose(): void;
  40735. private _updateCamera;
  40736. }
  40737. }
  40738. declare module "babylonjs/Gizmos/gizmo" {
  40739. import { Nullable } from "babylonjs/types";
  40740. import { IDisposable } from "babylonjs/scene";
  40741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40742. import { Mesh } from "babylonjs/Meshes/mesh";
  40743. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  40744. /**
  40745. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40746. */
  40747. export class Gizmo implements IDisposable {
  40748. /** The utility layer the gizmo will be added to */
  40749. gizmoLayer: UtilityLayerRenderer;
  40750. /**
  40751. * The root mesh of the gizmo
  40752. */
  40753. protected _rootMesh: Mesh;
  40754. private _attachedMesh;
  40755. /**
  40756. * Ratio for the scale of the gizmo (Default: 1)
  40757. */
  40758. scaleRatio: number;
  40759. private _tmpMatrix;
  40760. /**
  40761. * If a custom mesh has been set (Default: false)
  40762. */
  40763. protected _customMeshSet: boolean;
  40764. /**
  40765. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40766. * * When set, interactions will be enabled
  40767. */
  40768. attachedMesh: Nullable<AbstractMesh>;
  40769. /**
  40770. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40771. * @param mesh The mesh to replace the default mesh of the gizmo
  40772. */
  40773. setCustomMesh(mesh: Mesh): void;
  40774. /**
  40775. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40776. */
  40777. updateGizmoRotationToMatchAttachedMesh: boolean;
  40778. /**
  40779. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40780. */
  40781. updateGizmoPositionToMatchAttachedMesh: boolean;
  40782. /**
  40783. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40784. */
  40785. protected _updateScale: boolean;
  40786. protected _interactionsEnabled: boolean;
  40787. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40788. private _beforeRenderObserver;
  40789. /**
  40790. * Creates a gizmo
  40791. * @param gizmoLayer The utility layer the gizmo will be added to
  40792. */
  40793. constructor(
  40794. /** The utility layer the gizmo will be added to */
  40795. gizmoLayer?: UtilityLayerRenderer);
  40796. private _tempVector;
  40797. /**
  40798. * @hidden
  40799. * Updates the gizmo to match the attached mesh's position/rotation
  40800. */
  40801. protected _update(): void;
  40802. /**
  40803. * Disposes of the gizmo
  40804. */
  40805. dispose(): void;
  40806. }
  40807. }
  40808. declare module "babylonjs/Gizmos/axisDragGizmo" {
  40809. import { Observable } from "babylonjs/Misc/observable";
  40810. import { Nullable } from "babylonjs/types";
  40811. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40812. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40814. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40815. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  40816. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  40817. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  40818. import { Scene } from "babylonjs/scene";
  40819. /**
  40820. * Single axis drag gizmo
  40821. */
  40822. export class AxisDragGizmo extends Gizmo {
  40823. /**
  40824. * Drag behavior responsible for the gizmos dragging interactions
  40825. */
  40826. dragBehavior: PointerDragBehavior;
  40827. private _pointerObserver;
  40828. /**
  40829. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40830. */
  40831. snapDistance: number;
  40832. /**
  40833. * Event that fires each time the gizmo snaps to a new location.
  40834. * * snapDistance is the the change in distance
  40835. */
  40836. onSnapObservable: Observable<{
  40837. snapDistance: number;
  40838. }>;
  40839. /** @hidden */
  40840. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40841. /** @hidden */
  40842. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40843. /**
  40844. * Creates an AxisDragGizmo
  40845. * @param gizmoLayer The utility layer the gizmo will be added to
  40846. * @param dragAxis The axis which the gizmo will be able to drag on
  40847. * @param color The color of the gizmo
  40848. */
  40849. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40850. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40851. /**
  40852. * Disposes of the gizmo
  40853. */
  40854. dispose(): void;
  40855. }
  40856. }
  40857. declare module "babylonjs/Debug/axesViewer" {
  40858. import { Vector3 } from "babylonjs/Maths/math";
  40859. import { Nullable } from "babylonjs/types";
  40860. import { Scene } from "babylonjs/scene";
  40861. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40862. /**
  40863. * The Axes viewer will show 3 axes in a specific point in space
  40864. */
  40865. export class AxesViewer {
  40866. private _xAxis;
  40867. private _yAxis;
  40868. private _zAxis;
  40869. private _scaleLinesFactor;
  40870. private _instanced;
  40871. /**
  40872. * Gets the hosting scene
  40873. */
  40874. scene: Scene;
  40875. /**
  40876. * Gets or sets a number used to scale line length
  40877. */
  40878. scaleLines: number;
  40879. /** Gets the node hierarchy used to render x-axis */
  40880. readonly xAxis: TransformNode;
  40881. /** Gets the node hierarchy used to render y-axis */
  40882. readonly yAxis: TransformNode;
  40883. /** Gets the node hierarchy used to render z-axis */
  40884. readonly zAxis: TransformNode;
  40885. /**
  40886. * Creates a new AxesViewer
  40887. * @param scene defines the hosting scene
  40888. * @param scaleLines defines a number used to scale line length (1 by default)
  40889. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40890. * @param xAxis defines the node hierarchy used to render the x-axis
  40891. * @param yAxis defines the node hierarchy used to render the y-axis
  40892. * @param zAxis defines the node hierarchy used to render the z-axis
  40893. */
  40894. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40895. /**
  40896. * Force the viewer to update
  40897. * @param position defines the position of the viewer
  40898. * @param xaxis defines the x axis of the viewer
  40899. * @param yaxis defines the y axis of the viewer
  40900. * @param zaxis defines the z axis of the viewer
  40901. */
  40902. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40903. /**
  40904. * Creates an instance of this axes viewer.
  40905. * @returns a new axes viewer with instanced meshes
  40906. */
  40907. createInstance(): AxesViewer;
  40908. /** Releases resources */
  40909. dispose(): void;
  40910. private static _SetRenderingGroupId;
  40911. }
  40912. }
  40913. declare module "babylonjs/Debug/boneAxesViewer" {
  40914. import { Nullable } from "babylonjs/types";
  40915. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  40916. import { Vector3 } from "babylonjs/Maths/math";
  40917. import { Mesh } from "babylonjs/Meshes/mesh";
  40918. import { Bone } from "babylonjs/Bones/bone";
  40919. import { Scene } from "babylonjs/scene";
  40920. /**
  40921. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40922. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40923. */
  40924. export class BoneAxesViewer extends AxesViewer {
  40925. /**
  40926. * Gets or sets the target mesh where to display the axes viewer
  40927. */
  40928. mesh: Nullable<Mesh>;
  40929. /**
  40930. * Gets or sets the target bone where to display the axes viewer
  40931. */
  40932. bone: Nullable<Bone>;
  40933. /** Gets current position */
  40934. pos: Vector3;
  40935. /** Gets direction of X axis */
  40936. xaxis: Vector3;
  40937. /** Gets direction of Y axis */
  40938. yaxis: Vector3;
  40939. /** Gets direction of Z axis */
  40940. zaxis: Vector3;
  40941. /**
  40942. * Creates a new BoneAxesViewer
  40943. * @param scene defines the hosting scene
  40944. * @param bone defines the target bone
  40945. * @param mesh defines the target mesh
  40946. * @param scaleLines defines a scaling factor for line length (1 by default)
  40947. */
  40948. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40949. /**
  40950. * Force the viewer to update
  40951. */
  40952. update(): void;
  40953. /** Releases resources */
  40954. dispose(): void;
  40955. }
  40956. }
  40957. declare module "babylonjs/Debug/debugLayer" {
  40958. import { Observable } from "babylonjs/Misc/observable";
  40959. import { Scene } from "babylonjs/scene";
  40960. /**
  40961. * Interface used to define scene explorer extensibility option
  40962. */
  40963. export interface IExplorerExtensibilityOption {
  40964. /**
  40965. * Define the option label
  40966. */
  40967. label: string;
  40968. /**
  40969. * Defines the action to execute on click
  40970. */
  40971. action: (entity: any) => void;
  40972. }
  40973. /**
  40974. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40975. */
  40976. export interface IExplorerExtensibilityGroup {
  40977. /**
  40978. * Defines a predicate to test if a given type mut be extended
  40979. */
  40980. predicate: (entity: any) => boolean;
  40981. /**
  40982. * Gets the list of options added to a type
  40983. */
  40984. entries: IExplorerExtensibilityOption[];
  40985. }
  40986. /**
  40987. * Interface used to define the options to use to create the Inspector
  40988. */
  40989. export interface IInspectorOptions {
  40990. /**
  40991. * Display in overlay mode (default: false)
  40992. */
  40993. overlay?: boolean;
  40994. /**
  40995. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40996. */
  40997. globalRoot?: HTMLElement;
  40998. /**
  40999. * Display the Scene explorer
  41000. */
  41001. showExplorer?: boolean;
  41002. /**
  41003. * Display the property inspector
  41004. */
  41005. showInspector?: boolean;
  41006. /**
  41007. * Display in embed mode (both panes on the right)
  41008. */
  41009. embedMode?: boolean;
  41010. /**
  41011. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41012. */
  41013. handleResize?: boolean;
  41014. /**
  41015. * Allow the panes to popup (default: true)
  41016. */
  41017. enablePopup?: boolean;
  41018. /**
  41019. * Allow the panes to be closed by users (default: true)
  41020. */
  41021. enableClose?: boolean;
  41022. /**
  41023. * Optional list of extensibility entries
  41024. */
  41025. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41026. }
  41027. module "babylonjs/scene" {
  41028. interface Scene {
  41029. /**
  41030. * @hidden
  41031. * Backing field
  41032. */
  41033. _debugLayer: DebugLayer;
  41034. /**
  41035. * Gets the debug layer (aka Inspector) associated with the scene
  41036. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41037. */
  41038. debugLayer: DebugLayer;
  41039. }
  41040. }
  41041. /**
  41042. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41043. * what is happening in your scene
  41044. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41045. */
  41046. export class DebugLayer {
  41047. /**
  41048. * Define the url to get the inspector script from.
  41049. * By default it uses the babylonjs CDN.
  41050. * @ignoreNaming
  41051. */
  41052. static InspectorURL: string;
  41053. private _scene;
  41054. private BJSINSPECTOR;
  41055. /**
  41056. * Observable triggered when a property is changed through the inspector.
  41057. */
  41058. onPropertyChangedObservable: Observable<{
  41059. object: any;
  41060. property: string;
  41061. value: any;
  41062. initialValue: any;
  41063. }>;
  41064. /**
  41065. * Instantiates a new debug layer.
  41066. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41067. * what is happening in your scene
  41068. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41069. * @param scene Defines the scene to inspect
  41070. */
  41071. constructor(scene: Scene);
  41072. /** Creates the inspector window. */
  41073. private _createInspector;
  41074. /** Get the inspector from bundle or global */
  41075. private _getGlobalInspector;
  41076. /**
  41077. * Get if the inspector is visible or not.
  41078. * @returns true if visible otherwise, false
  41079. */
  41080. isVisible(): boolean;
  41081. /**
  41082. * Hide the inspector and close its window.
  41083. */
  41084. hide(): void;
  41085. /**
  41086. * Launch the debugLayer.
  41087. * @param config Define the configuration of the inspector
  41088. */
  41089. show(config?: IInspectorOptions): void;
  41090. }
  41091. }
  41092. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41093. import { Nullable } from "babylonjs/types";
  41094. import { Scene } from "babylonjs/scene";
  41095. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41096. import { Mesh } from "babylonjs/Meshes/mesh";
  41097. /**
  41098. * Class containing static functions to help procedurally build meshes
  41099. */
  41100. export class BoxBuilder {
  41101. /**
  41102. * Creates a box mesh
  41103. * * The parameter `size` sets the size (float) of each box side (default 1)
  41104. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41105. * * 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)
  41106. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41108. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41110. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41111. * @param name defines the name of the mesh
  41112. * @param options defines the options used to create the mesh
  41113. * @param scene defines the hosting scene
  41114. * @returns the box mesh
  41115. */
  41116. static CreateBox(name: string, options: {
  41117. size?: number;
  41118. width?: number;
  41119. height?: number;
  41120. depth?: number;
  41121. faceUV?: Vector4[];
  41122. faceColors?: Color4[];
  41123. sideOrientation?: number;
  41124. frontUVs?: Vector4;
  41125. backUVs?: Vector4;
  41126. updatable?: boolean;
  41127. }, scene?: Nullable<Scene>): Mesh;
  41128. }
  41129. }
  41130. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41131. import { Vector4 } from "babylonjs/Maths/math";
  41132. import { Mesh } from "babylonjs/Meshes/mesh";
  41133. /**
  41134. * Class containing static functions to help procedurally build meshes
  41135. */
  41136. export class SphereBuilder {
  41137. /**
  41138. * Creates a sphere mesh
  41139. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41140. * * 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`)
  41141. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41142. * * 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
  41143. * * 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)
  41144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41145. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41147. * @param name defines the name of the mesh
  41148. * @param options defines the options used to create the mesh
  41149. * @param scene defines the hosting scene
  41150. * @returns the sphere mesh
  41151. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41152. */
  41153. static CreateSphere(name: string, options: {
  41154. segments?: number;
  41155. diameter?: number;
  41156. diameterX?: number;
  41157. diameterY?: number;
  41158. diameterZ?: number;
  41159. arc?: number;
  41160. slice?: number;
  41161. sideOrientation?: number;
  41162. frontUVs?: Vector4;
  41163. backUVs?: Vector4;
  41164. updatable?: boolean;
  41165. }, scene: any): Mesh;
  41166. }
  41167. }
  41168. declare module "babylonjs/Debug/physicsViewer" {
  41169. import { Nullable } from "babylonjs/types";
  41170. import { Scene } from "babylonjs/scene";
  41171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41172. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41173. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41174. /**
  41175. * Used to show the physics impostor around the specific mesh
  41176. */
  41177. export class PhysicsViewer {
  41178. /** @hidden */
  41179. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41180. /** @hidden */
  41181. protected _meshes: Array<Nullable<AbstractMesh>>;
  41182. /** @hidden */
  41183. protected _scene: Nullable<Scene>;
  41184. /** @hidden */
  41185. protected _numMeshes: number;
  41186. /** @hidden */
  41187. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41188. private _renderFunction;
  41189. private _utilityLayer;
  41190. private _debugBoxMesh;
  41191. private _debugSphereMesh;
  41192. private _debugMaterial;
  41193. /**
  41194. * Creates a new PhysicsViewer
  41195. * @param scene defines the hosting scene
  41196. */
  41197. constructor(scene: Scene);
  41198. /** @hidden */
  41199. protected _updateDebugMeshes(): void;
  41200. /**
  41201. * Renders a specified physic impostor
  41202. * @param impostor defines the impostor to render
  41203. * @returns the new debug mesh used to render the impostor
  41204. */
  41205. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41206. /**
  41207. * Hides a specified physic impostor
  41208. * @param impostor defines the impostor to hide
  41209. */
  41210. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41211. private _getDebugMaterial;
  41212. private _getDebugBoxMesh;
  41213. private _getDebugSphereMesh;
  41214. private _getDebugMesh;
  41215. /** Releases all resources */
  41216. dispose(): void;
  41217. }
  41218. }
  41219. declare module "babylonjs/Debug/rayHelper" {
  41220. import { Nullable } from "babylonjs/types";
  41221. import { Ray } from "babylonjs/Culling/ray";
  41222. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41223. import { Scene } from "babylonjs/scene";
  41224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41225. import "babylonjs/Meshes/Builders/linesBuilder";
  41226. /**
  41227. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41228. * in order to better appreciate the issue one might have.
  41229. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41230. */
  41231. export class RayHelper {
  41232. /**
  41233. * Defines the ray we are currently tryin to visualize.
  41234. */
  41235. ray: Nullable<Ray>;
  41236. private _renderPoints;
  41237. private _renderLine;
  41238. private _renderFunction;
  41239. private _scene;
  41240. private _updateToMeshFunction;
  41241. private _attachedToMesh;
  41242. private _meshSpaceDirection;
  41243. private _meshSpaceOrigin;
  41244. /**
  41245. * Helper function to create a colored helper in a scene in one line.
  41246. * @param ray Defines the ray we are currently tryin to visualize
  41247. * @param scene Defines the scene the ray is used in
  41248. * @param color Defines the color we want to see the ray in
  41249. * @returns The newly created ray helper.
  41250. */
  41251. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41252. /**
  41253. * Instantiate a new ray helper.
  41254. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41255. * in order to better appreciate the issue one might have.
  41256. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41257. * @param ray Defines the ray we are currently tryin to visualize
  41258. */
  41259. constructor(ray: Ray);
  41260. /**
  41261. * Shows the ray we are willing to debug.
  41262. * @param scene Defines the scene the ray needs to be rendered in
  41263. * @param color Defines the color the ray needs to be rendered in
  41264. */
  41265. show(scene: Scene, color?: Color3): void;
  41266. /**
  41267. * Hides the ray we are debugging.
  41268. */
  41269. hide(): void;
  41270. private _render;
  41271. /**
  41272. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41273. * @param mesh Defines the mesh we want the helper attached to
  41274. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41275. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41276. * @param length Defines the length of the ray
  41277. */
  41278. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41279. /**
  41280. * Detach the ray helper from the mesh it has previously been attached to.
  41281. */
  41282. detachFromMesh(): void;
  41283. private _updateToMesh;
  41284. /**
  41285. * Dispose the helper and release its associated resources.
  41286. */
  41287. dispose(): void;
  41288. }
  41289. }
  41290. declare module "babylonjs/Debug/skeletonViewer" {
  41291. import { Color3 } from "babylonjs/Maths/math";
  41292. import { Scene } from "babylonjs/scene";
  41293. import { Nullable } from "babylonjs/types";
  41294. import { Skeleton } from "babylonjs/Bones/skeleton";
  41295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41296. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41297. /**
  41298. * Class used to render a debug view of a given skeleton
  41299. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41300. */
  41301. export class SkeletonViewer {
  41302. /** defines the skeleton to render */
  41303. skeleton: Skeleton;
  41304. /** defines the mesh attached to the skeleton */
  41305. mesh: AbstractMesh;
  41306. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41307. autoUpdateBonesMatrices: boolean;
  41308. /** defines the rendering group id to use with the viewer */
  41309. renderingGroupId: number;
  41310. /** Gets or sets the color used to render the skeleton */
  41311. color: Color3;
  41312. private _scene;
  41313. private _debugLines;
  41314. private _debugMesh;
  41315. private _isEnabled;
  41316. private _renderFunction;
  41317. private _utilityLayer;
  41318. /**
  41319. * Returns the mesh used to render the bones
  41320. */
  41321. readonly debugMesh: Nullable<LinesMesh>;
  41322. /**
  41323. * Creates a new SkeletonViewer
  41324. * @param skeleton defines the skeleton to render
  41325. * @param mesh defines the mesh attached to the skeleton
  41326. * @param scene defines the hosting scene
  41327. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41328. * @param renderingGroupId defines the rendering group id to use with the viewer
  41329. */
  41330. constructor(
  41331. /** defines the skeleton to render */
  41332. skeleton: Skeleton,
  41333. /** defines the mesh attached to the skeleton */
  41334. mesh: AbstractMesh, scene: Scene,
  41335. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41336. autoUpdateBonesMatrices?: boolean,
  41337. /** defines the rendering group id to use with the viewer */
  41338. renderingGroupId?: number);
  41339. /** Gets or sets a boolean indicating if the viewer is enabled */
  41340. isEnabled: boolean;
  41341. private _getBonePosition;
  41342. private _getLinesForBonesWithLength;
  41343. private _getLinesForBonesNoLength;
  41344. /** Update the viewer to sync with current skeleton state */
  41345. update(): void;
  41346. /** Release associated resources */
  41347. dispose(): void;
  41348. }
  41349. }
  41350. declare module "babylonjs/Debug/index" {
  41351. export * from "babylonjs/Debug/axesViewer";
  41352. export * from "babylonjs/Debug/boneAxesViewer";
  41353. export * from "babylonjs/Debug/debugLayer";
  41354. export * from "babylonjs/Debug/physicsViewer";
  41355. export * from "babylonjs/Debug/rayHelper";
  41356. export * from "babylonjs/Debug/skeletonViewer";
  41357. }
  41358. declare module "babylonjs/Engines/nullEngine" {
  41359. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41360. import { Scene } from "babylonjs/scene";
  41361. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41362. import { Engine } from "babylonjs/Engines/engine";
  41363. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41364. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41365. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41366. import { Effect } from "babylonjs/Materials/effect";
  41367. /**
  41368. * Options to create the null engine
  41369. */
  41370. export class NullEngineOptions {
  41371. /**
  41372. * Render width (Default: 512)
  41373. */
  41374. renderWidth: number;
  41375. /**
  41376. * Render height (Default: 256)
  41377. */
  41378. renderHeight: number;
  41379. /**
  41380. * Texture size (Default: 512)
  41381. */
  41382. textureSize: number;
  41383. /**
  41384. * If delta time between frames should be constant
  41385. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41386. */
  41387. deterministicLockstep: boolean;
  41388. /**
  41389. * Maximum about of steps between frames (Default: 4)
  41390. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41391. */
  41392. lockstepMaxSteps: number;
  41393. }
  41394. /**
  41395. * The null engine class provides support for headless version of babylon.js.
  41396. * This can be used in server side scenario or for testing purposes
  41397. */
  41398. export class NullEngine extends Engine {
  41399. private _options;
  41400. /**
  41401. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41402. */
  41403. isDeterministicLockStep(): boolean;
  41404. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41405. getLockstepMaxSteps(): number;
  41406. /**
  41407. * Sets hardware scaling, used to save performance if needed
  41408. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41409. */
  41410. getHardwareScalingLevel(): number;
  41411. constructor(options?: NullEngineOptions);
  41412. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41413. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41414. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41415. getRenderWidth(useScreen?: boolean): number;
  41416. getRenderHeight(useScreen?: boolean): number;
  41417. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41418. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41419. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41420. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41421. bindSamplers(effect: Effect): void;
  41422. enableEffect(effect: Effect): void;
  41423. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41424. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41425. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41426. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41427. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41428. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41429. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41430. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41431. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41432. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41433. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41434. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41435. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41436. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41437. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41438. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41439. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41440. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41441. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41442. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41443. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41444. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41445. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41446. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41447. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41448. bindBuffers(vertexBuffers: {
  41449. [key: string]: VertexBuffer;
  41450. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41451. wipeCaches(bruteForce?: boolean): void;
  41452. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41453. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41454. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41455. /** @hidden */
  41456. _createTexture(): WebGLTexture;
  41457. /** @hidden */
  41458. _releaseTexture(texture: InternalTexture): void;
  41459. 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;
  41460. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41461. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41462. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41463. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41464. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41465. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41466. areAllEffectsReady(): boolean;
  41467. /**
  41468. * @hidden
  41469. * Get the current error code of the webGL context
  41470. * @returns the error code
  41471. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41472. */
  41473. getError(): number;
  41474. /** @hidden */
  41475. _getUnpackAlignement(): number;
  41476. /** @hidden */
  41477. _unpackFlipY(value: boolean): void;
  41478. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41479. /**
  41480. * Updates a dynamic vertex buffer.
  41481. * @param vertexBuffer the vertex buffer to update
  41482. * @param data the data used to update the vertex buffer
  41483. * @param byteOffset the byte offset of the data (optional)
  41484. * @param byteLength the byte length of the data (optional)
  41485. */
  41486. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41487. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41488. /** @hidden */
  41489. _bindTexture(channel: number, texture: InternalTexture): void;
  41490. /** @hidden */
  41491. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41492. releaseEffects(): void;
  41493. displayLoadingUI(): void;
  41494. hideLoadingUI(): void;
  41495. /** @hidden */
  41496. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41497. /** @hidden */
  41498. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41499. /** @hidden */
  41500. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41501. /** @hidden */
  41502. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41503. }
  41504. }
  41505. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  41506. import { Nullable, int } from "babylonjs/types";
  41507. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  41508. /** @hidden */
  41509. export class _OcclusionDataStorage {
  41510. /** @hidden */
  41511. occlusionInternalRetryCounter: number;
  41512. /** @hidden */
  41513. isOcclusionQueryInProgress: boolean;
  41514. /** @hidden */
  41515. isOccluded: boolean;
  41516. /** @hidden */
  41517. occlusionRetryCount: number;
  41518. /** @hidden */
  41519. occlusionType: number;
  41520. /** @hidden */
  41521. occlusionQueryAlgorithmType: number;
  41522. }
  41523. module "babylonjs/Engines/engine" {
  41524. interface Engine {
  41525. /**
  41526. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41527. * @return the new query
  41528. */
  41529. createQuery(): WebGLQuery;
  41530. /**
  41531. * Delete and release a webGL query
  41532. * @param query defines the query to delete
  41533. * @return the current engine
  41534. */
  41535. deleteQuery(query: WebGLQuery): Engine;
  41536. /**
  41537. * Check if a given query has resolved and got its value
  41538. * @param query defines the query to check
  41539. * @returns true if the query got its value
  41540. */
  41541. isQueryResultAvailable(query: WebGLQuery): boolean;
  41542. /**
  41543. * Gets the value of a given query
  41544. * @param query defines the query to check
  41545. * @returns the value of the query
  41546. */
  41547. getQueryResult(query: WebGLQuery): number;
  41548. /**
  41549. * Initiates an occlusion query
  41550. * @param algorithmType defines the algorithm to use
  41551. * @param query defines the query to use
  41552. * @returns the current engine
  41553. * @see http://doc.babylonjs.com/features/occlusionquery
  41554. */
  41555. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41556. /**
  41557. * Ends an occlusion query
  41558. * @see http://doc.babylonjs.com/features/occlusionquery
  41559. * @param algorithmType defines the algorithm to use
  41560. * @returns the current engine
  41561. */
  41562. endOcclusionQuery(algorithmType: number): Engine;
  41563. /**
  41564. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41565. * Please note that only one query can be issued at a time
  41566. * @returns a time token used to track the time span
  41567. */
  41568. startTimeQuery(): Nullable<_TimeToken>;
  41569. /**
  41570. * Ends a time query
  41571. * @param token defines the token used to measure the time span
  41572. * @returns the time spent (in ns)
  41573. */
  41574. endTimeQuery(token: _TimeToken): int;
  41575. /** @hidden */
  41576. _currentNonTimestampToken: Nullable<_TimeToken>;
  41577. /** @hidden */
  41578. _createTimeQuery(): WebGLQuery;
  41579. /** @hidden */
  41580. _deleteTimeQuery(query: WebGLQuery): void;
  41581. /** @hidden */
  41582. _getGlAlgorithmType(algorithmType: number): number;
  41583. /** @hidden */
  41584. _getTimeQueryResult(query: WebGLQuery): any;
  41585. /** @hidden */
  41586. _getTimeQueryAvailability(query: WebGLQuery): any;
  41587. }
  41588. }
  41589. module "babylonjs/Meshes/abstractMesh" {
  41590. interface AbstractMesh {
  41591. /**
  41592. * Backing filed
  41593. * @hidden
  41594. */
  41595. __occlusionDataStorage: _OcclusionDataStorage;
  41596. /**
  41597. * Access property
  41598. * @hidden
  41599. */
  41600. _occlusionDataStorage: _OcclusionDataStorage;
  41601. /**
  41602. * 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.
  41603. * The default value is -1 which means don't break the query and wait till the result
  41604. * @see http://doc.babylonjs.com/features/occlusionquery
  41605. */
  41606. occlusionRetryCount: number;
  41607. /**
  41608. * 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:
  41609. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41610. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41611. * * 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.
  41612. * @see http://doc.babylonjs.com/features/occlusionquery
  41613. */
  41614. occlusionType: number;
  41615. /**
  41616. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41617. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41618. * * 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.
  41619. * @see http://doc.babylonjs.com/features/occlusionquery
  41620. */
  41621. occlusionQueryAlgorithmType: number;
  41622. /**
  41623. * 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
  41624. * @see http://doc.babylonjs.com/features/occlusionquery
  41625. */
  41626. isOccluded: boolean;
  41627. /**
  41628. * Flag to check the progress status of the query
  41629. * @see http://doc.babylonjs.com/features/occlusionquery
  41630. */
  41631. isOcclusionQueryInProgress: boolean;
  41632. }
  41633. }
  41634. }
  41635. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  41636. import { Nullable } from "babylonjs/types";
  41637. /** @hidden */
  41638. export var _forceTransformFeedbackToBundle: boolean;
  41639. module "babylonjs/Engines/engine" {
  41640. interface Engine {
  41641. /**
  41642. * Creates a webGL transform feedback object
  41643. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41644. * @returns the webGL transform feedback object
  41645. */
  41646. createTransformFeedback(): WebGLTransformFeedback;
  41647. /**
  41648. * Delete a webGL transform feedback object
  41649. * @param value defines the webGL transform feedback object to delete
  41650. */
  41651. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41652. /**
  41653. * Bind a webGL transform feedback object to the webgl context
  41654. * @param value defines the webGL transform feedback object to bind
  41655. */
  41656. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41657. /**
  41658. * Begins a transform feedback operation
  41659. * @param usePoints defines if points or triangles must be used
  41660. */
  41661. beginTransformFeedback(usePoints: boolean): void;
  41662. /**
  41663. * Ends a transform feedback operation
  41664. */
  41665. endTransformFeedback(): void;
  41666. /**
  41667. * Specify the varyings to use with transform feedback
  41668. * @param program defines the associated webGL program
  41669. * @param value defines the list of strings representing the varying names
  41670. */
  41671. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41672. /**
  41673. * Bind a webGL buffer for a transform feedback operation
  41674. * @param value defines the webGL buffer to bind
  41675. */
  41676. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  41677. }
  41678. }
  41679. }
  41680. declare module "babylonjs/Engines/Extensions/index" {
  41681. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  41682. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  41683. }
  41684. declare module "babylonjs/Engines/index" {
  41685. export * from "babylonjs/Engines/constants";
  41686. export * from "babylonjs/Engines/engine";
  41687. export * from "babylonjs/Engines/engineStore";
  41688. export * from "babylonjs/Engines/nullEngine";
  41689. export * from "babylonjs/Engines/Extensions/index";
  41690. }
  41691. declare module "babylonjs/Events/clipboardEvents" {
  41692. /**
  41693. * Gather the list of clipboard event types as constants.
  41694. */
  41695. export class ClipboardEventTypes {
  41696. /**
  41697. * The clipboard event is fired when a copy command is active (pressed).
  41698. */
  41699. static readonly COPY: number;
  41700. /**
  41701. * The clipboard event is fired when a cut command is active (pressed).
  41702. */
  41703. static readonly CUT: number;
  41704. /**
  41705. * The clipboard event is fired when a paste command is active (pressed).
  41706. */
  41707. static readonly PASTE: number;
  41708. }
  41709. /**
  41710. * This class is used to store clipboard related info for the onClipboardObservable event.
  41711. */
  41712. export class ClipboardInfo {
  41713. /**
  41714. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41715. */
  41716. type: number;
  41717. /**
  41718. * Defines the related dom event
  41719. */
  41720. event: ClipboardEvent;
  41721. /**
  41722. *Creates an instance of ClipboardInfo.
  41723. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41724. * @param event Defines the related dom event
  41725. */
  41726. constructor(
  41727. /**
  41728. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41729. */
  41730. type: number,
  41731. /**
  41732. * Defines the related dom event
  41733. */
  41734. event: ClipboardEvent);
  41735. /**
  41736. * Get the clipboard event's type from the keycode.
  41737. * @param keyCode Defines the keyCode for the current keyboard event.
  41738. * @return {number}
  41739. */
  41740. static GetTypeFromCharacter(keyCode: number): number;
  41741. }
  41742. }
  41743. declare module "babylonjs/Events/index" {
  41744. export * from "babylonjs/Events/keyboardEvents";
  41745. export * from "babylonjs/Events/pointerEvents";
  41746. export * from "babylonjs/Events/clipboardEvents";
  41747. }
  41748. declare module "babylonjs/Loading/sceneLoader" {
  41749. import { Observable } from "babylonjs/Misc/observable";
  41750. import { Nullable } from "babylonjs/types";
  41751. import { Scene } from "babylonjs/scene";
  41752. import { Engine } from "babylonjs/Engines/engine";
  41753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41754. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41755. import { AssetContainer } from "babylonjs/assetContainer";
  41756. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41757. import { Skeleton } from "babylonjs/Bones/skeleton";
  41758. /**
  41759. * Class used to represent data loading progression
  41760. */
  41761. export class SceneLoaderProgressEvent {
  41762. /** defines if data length to load can be evaluated */
  41763. readonly lengthComputable: boolean;
  41764. /** defines the loaded data length */
  41765. readonly loaded: number;
  41766. /** defines the data length to load */
  41767. readonly total: number;
  41768. /**
  41769. * Create a new progress event
  41770. * @param lengthComputable defines if data length to load can be evaluated
  41771. * @param loaded defines the loaded data length
  41772. * @param total defines the data length to load
  41773. */
  41774. constructor(
  41775. /** defines if data length to load can be evaluated */
  41776. lengthComputable: boolean,
  41777. /** defines the loaded data length */
  41778. loaded: number,
  41779. /** defines the data length to load */
  41780. total: number);
  41781. /**
  41782. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41783. * @param event defines the source event
  41784. * @returns a new SceneLoaderProgressEvent
  41785. */
  41786. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41787. }
  41788. /**
  41789. * Interface used by SceneLoader plugins to define supported file extensions
  41790. */
  41791. export interface ISceneLoaderPluginExtensions {
  41792. /**
  41793. * Defines the list of supported extensions
  41794. */
  41795. [extension: string]: {
  41796. isBinary: boolean;
  41797. };
  41798. }
  41799. /**
  41800. * Interface used by SceneLoader plugin factory
  41801. */
  41802. export interface ISceneLoaderPluginFactory {
  41803. /**
  41804. * Defines the name of the factory
  41805. */
  41806. name: string;
  41807. /**
  41808. * Function called to create a new plugin
  41809. * @return the new plugin
  41810. */
  41811. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41812. /**
  41813. * Boolean indicating if the plugin can direct load specific data
  41814. */
  41815. canDirectLoad?: (data: string) => boolean;
  41816. }
  41817. /**
  41818. * Interface used to define a SceneLoader plugin
  41819. */
  41820. export interface ISceneLoaderPlugin {
  41821. /**
  41822. * The friendly name of this plugin.
  41823. */
  41824. name: string;
  41825. /**
  41826. * The file extensions supported by this plugin.
  41827. */
  41828. extensions: string | ISceneLoaderPluginExtensions;
  41829. /**
  41830. * Import meshes into a scene.
  41831. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41832. * @param scene The scene to import into
  41833. * @param data The data to import
  41834. * @param rootUrl The root url for scene and resources
  41835. * @param meshes The meshes array to import into
  41836. * @param particleSystems The particle systems array to import into
  41837. * @param skeletons The skeletons array to import into
  41838. * @param onError The callback when import fails
  41839. * @returns True if successful or false otherwise
  41840. */
  41841. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41842. /**
  41843. * Load into a scene.
  41844. * @param scene The scene to load into
  41845. * @param data The data to import
  41846. * @param rootUrl The root url for scene and resources
  41847. * @param onError The callback when import fails
  41848. * @returns true if successful or false otherwise
  41849. */
  41850. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41851. /**
  41852. * The callback that returns true if the data can be directly loaded.
  41853. */
  41854. canDirectLoad?: (data: string) => boolean;
  41855. /**
  41856. * The callback that allows custom handling of the root url based on the response url.
  41857. */
  41858. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41859. /**
  41860. * Load into an asset container.
  41861. * @param scene The scene to load into
  41862. * @param data The data to import
  41863. * @param rootUrl The root url for scene and resources
  41864. * @param onError The callback when import fails
  41865. * @returns The loaded asset container
  41866. */
  41867. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41868. }
  41869. /**
  41870. * Interface used to define an async SceneLoader plugin
  41871. */
  41872. export interface ISceneLoaderPluginAsync {
  41873. /**
  41874. * The friendly name of this plugin.
  41875. */
  41876. name: string;
  41877. /**
  41878. * The file extensions supported by this plugin.
  41879. */
  41880. extensions: string | ISceneLoaderPluginExtensions;
  41881. /**
  41882. * Import meshes into a scene.
  41883. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41884. * @param scene The scene to import into
  41885. * @param data The data to import
  41886. * @param rootUrl The root url for scene and resources
  41887. * @param onProgress The callback when the load progresses
  41888. * @param fileName Defines the name of the file to load
  41889. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41890. */
  41891. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41892. meshes: AbstractMesh[];
  41893. particleSystems: IParticleSystem[];
  41894. skeletons: Skeleton[];
  41895. animationGroups: AnimationGroup[];
  41896. }>;
  41897. /**
  41898. * Load into a scene.
  41899. * @param scene The scene to load into
  41900. * @param data The data to import
  41901. * @param rootUrl The root url for scene and resources
  41902. * @param onProgress The callback when the load progresses
  41903. * @param fileName Defines the name of the file to load
  41904. * @returns Nothing
  41905. */
  41906. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41907. /**
  41908. * The callback that returns true if the data can be directly loaded.
  41909. */
  41910. canDirectLoad?: (data: string) => boolean;
  41911. /**
  41912. * The callback that allows custom handling of the root url based on the response url.
  41913. */
  41914. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41915. /**
  41916. * Load into an asset container.
  41917. * @param scene The scene to load into
  41918. * @param data The data to import
  41919. * @param rootUrl The root url for scene and resources
  41920. * @param onProgress The callback when the load progresses
  41921. * @param fileName Defines the name of the file to load
  41922. * @returns The loaded asset container
  41923. */
  41924. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41925. }
  41926. /**
  41927. * Class used to load scene from various file formats using registered plugins
  41928. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41929. */
  41930. export class SceneLoader {
  41931. /**
  41932. * No logging while loading
  41933. */
  41934. static readonly NO_LOGGING: number;
  41935. /**
  41936. * Minimal logging while loading
  41937. */
  41938. static readonly MINIMAL_LOGGING: number;
  41939. /**
  41940. * Summary logging while loading
  41941. */
  41942. static readonly SUMMARY_LOGGING: number;
  41943. /**
  41944. * Detailled logging while loading
  41945. */
  41946. static readonly DETAILED_LOGGING: number;
  41947. /**
  41948. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41949. */
  41950. static ForceFullSceneLoadingForIncremental: boolean;
  41951. /**
  41952. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41953. */
  41954. static ShowLoadingScreen: boolean;
  41955. /**
  41956. * Defines the current logging level (while loading the scene)
  41957. * @ignorenaming
  41958. */
  41959. static loggingLevel: number;
  41960. /**
  41961. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41962. */
  41963. static CleanBoneMatrixWeights: boolean;
  41964. /**
  41965. * Event raised when a plugin is used to load a scene
  41966. */
  41967. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41968. private static _registeredPlugins;
  41969. private static _getDefaultPlugin;
  41970. private static _getPluginForExtension;
  41971. private static _getPluginForDirectLoad;
  41972. private static _getPluginForFilename;
  41973. private static _getDirectLoad;
  41974. private static _loadData;
  41975. private static _getFileInfo;
  41976. /**
  41977. * Gets a plugin that can load the given extension
  41978. * @param extension defines the extension to load
  41979. * @returns a plugin or null if none works
  41980. */
  41981. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41982. /**
  41983. * Gets a boolean indicating that the given extension can be loaded
  41984. * @param extension defines the extension to load
  41985. * @returns true if the extension is supported
  41986. */
  41987. static IsPluginForExtensionAvailable(extension: string): boolean;
  41988. /**
  41989. * Adds a new plugin to the list of registered plugins
  41990. * @param plugin defines the plugin to add
  41991. */
  41992. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41993. /**
  41994. * Import meshes into a scene
  41995. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41996. * @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)
  41997. * @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)
  41998. * @param scene the instance of BABYLON.Scene to append to
  41999. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42000. * @param onProgress a callback with a progress event for each file being loaded
  42001. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42002. * @param pluginExtension the extension used to determine the plugin
  42003. * @returns The loaded plugin
  42004. */
  42005. 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>;
  42006. /**
  42007. * Import meshes into a scene
  42008. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42009. * @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)
  42010. * @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)
  42011. * @param scene the instance of BABYLON.Scene to append to
  42012. * @param onProgress a callback with a progress event for each file being loaded
  42013. * @param pluginExtension the extension used to determine the plugin
  42014. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42015. */
  42016. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42017. meshes: AbstractMesh[];
  42018. particleSystems: IParticleSystem[];
  42019. skeletons: Skeleton[];
  42020. animationGroups: AnimationGroup[];
  42021. }>;
  42022. /**
  42023. * Load a scene
  42024. * @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)
  42025. * @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)
  42026. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42027. * @param onSuccess a callback with the scene when import succeeds
  42028. * @param onProgress a callback with a progress event for each file being loaded
  42029. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42030. * @param pluginExtension the extension used to determine the plugin
  42031. * @returns The loaded plugin
  42032. */
  42033. 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>;
  42034. /**
  42035. * Load a scene
  42036. * @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)
  42037. * @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)
  42038. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42039. * @param onProgress a callback with a progress event for each file being loaded
  42040. * @param pluginExtension the extension used to determine the plugin
  42041. * @returns The loaded scene
  42042. */
  42043. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42044. /**
  42045. * Append a scene
  42046. * @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)
  42047. * @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)
  42048. * @param scene is the instance of BABYLON.Scene to append to
  42049. * @param onSuccess a callback with the scene when import succeeds
  42050. * @param onProgress a callback with a progress event for each file being loaded
  42051. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42052. * @param pluginExtension the extension used to determine the plugin
  42053. * @returns The loaded plugin
  42054. */
  42055. 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>;
  42056. /**
  42057. * Append a scene
  42058. * @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)
  42059. * @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)
  42060. * @param scene is the instance of BABYLON.Scene to append to
  42061. * @param onProgress a callback with a progress event for each file being loaded
  42062. * @param pluginExtension the extension used to determine the plugin
  42063. * @returns The given scene
  42064. */
  42065. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42066. /**
  42067. * Load a scene into an asset container
  42068. * @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)
  42069. * @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)
  42070. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42071. * @param onSuccess a callback with the scene when import succeeds
  42072. * @param onProgress a callback with a progress event for each file being loaded
  42073. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42074. * @param pluginExtension the extension used to determine the plugin
  42075. * @returns The loaded plugin
  42076. */
  42077. 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>;
  42078. /**
  42079. * Load a scene into an asset container
  42080. * @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)
  42081. * @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)
  42082. * @param scene is the instance of Scene to append to
  42083. * @param onProgress a callback with a progress event for each file being loaded
  42084. * @param pluginExtension the extension used to determine the plugin
  42085. * @returns The loaded asset container
  42086. */
  42087. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42088. }
  42089. }
  42090. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42091. import { Scene } from "babylonjs/scene";
  42092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42093. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42094. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42095. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42096. /**
  42097. * Google Daydream controller
  42098. */
  42099. export class DaydreamController extends WebVRController {
  42100. /**
  42101. * Base Url for the controller model.
  42102. */
  42103. static MODEL_BASE_URL: string;
  42104. /**
  42105. * File name for the controller model.
  42106. */
  42107. static MODEL_FILENAME: string;
  42108. /**
  42109. * Gamepad Id prefix used to identify Daydream Controller.
  42110. */
  42111. static readonly GAMEPAD_ID_PREFIX: string;
  42112. /**
  42113. * Creates a new DaydreamController from a gamepad
  42114. * @param vrGamepad the gamepad that the controller should be created from
  42115. */
  42116. constructor(vrGamepad: any);
  42117. /**
  42118. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42119. * @param scene scene in which to add meshes
  42120. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42121. */
  42122. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42123. /**
  42124. * Called once for each button that changed state since the last frame
  42125. * @param buttonIdx Which button index changed
  42126. * @param state New state of the button
  42127. * @param changes Which properties on the state changed since last frame
  42128. */
  42129. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42130. }
  42131. }
  42132. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42133. import { Scene } from "babylonjs/scene";
  42134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42135. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42136. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42137. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42138. /**
  42139. * Gear VR Controller
  42140. */
  42141. export class GearVRController extends WebVRController {
  42142. /**
  42143. * Base Url for the controller model.
  42144. */
  42145. static MODEL_BASE_URL: string;
  42146. /**
  42147. * File name for the controller model.
  42148. */
  42149. static MODEL_FILENAME: string;
  42150. /**
  42151. * Gamepad Id prefix used to identify this controller.
  42152. */
  42153. static readonly GAMEPAD_ID_PREFIX: string;
  42154. private readonly _buttonIndexToObservableNameMap;
  42155. /**
  42156. * Creates a new GearVRController from a gamepad
  42157. * @param vrGamepad the gamepad that the controller should be created from
  42158. */
  42159. constructor(vrGamepad: any);
  42160. /**
  42161. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42162. * @param scene scene in which to add meshes
  42163. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42164. */
  42165. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42166. /**
  42167. * Called once for each button that changed state since the last frame
  42168. * @param buttonIdx Which button index changed
  42169. * @param state New state of the button
  42170. * @param changes Which properties on the state changed since last frame
  42171. */
  42172. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42173. }
  42174. }
  42175. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42176. import { Scene } from "babylonjs/scene";
  42177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42178. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42179. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42180. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42181. /**
  42182. * Generic Controller
  42183. */
  42184. export class GenericController extends WebVRController {
  42185. /**
  42186. * Base Url for the controller model.
  42187. */
  42188. static readonly MODEL_BASE_URL: string;
  42189. /**
  42190. * File name for the controller model.
  42191. */
  42192. static readonly MODEL_FILENAME: string;
  42193. /**
  42194. * Creates a new GenericController from a gamepad
  42195. * @param vrGamepad the gamepad that the controller should be created from
  42196. */
  42197. constructor(vrGamepad: any);
  42198. /**
  42199. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42200. * @param scene scene in which to add meshes
  42201. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42202. */
  42203. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42204. /**
  42205. * Called once for each button that changed state since the last frame
  42206. * @param buttonIdx Which button index changed
  42207. * @param state New state of the button
  42208. * @param changes Which properties on the state changed since last frame
  42209. */
  42210. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42211. }
  42212. }
  42213. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42214. import { Observable } from "babylonjs/Misc/observable";
  42215. import { Scene } from "babylonjs/scene";
  42216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42217. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42218. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42219. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42220. /**
  42221. * Oculus Touch Controller
  42222. */
  42223. export class OculusTouchController extends WebVRController {
  42224. /**
  42225. * Base Url for the controller model.
  42226. */
  42227. static MODEL_BASE_URL: string;
  42228. /**
  42229. * File name for the left controller model.
  42230. */
  42231. static MODEL_LEFT_FILENAME: string;
  42232. /**
  42233. * File name for the right controller model.
  42234. */
  42235. static MODEL_RIGHT_FILENAME: string;
  42236. /**
  42237. * Fired when the secondary trigger on this controller is modified
  42238. */
  42239. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42240. /**
  42241. * Fired when the thumb rest on this controller is modified
  42242. */
  42243. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42244. /**
  42245. * Creates a new OculusTouchController from a gamepad
  42246. * @param vrGamepad the gamepad that the controller should be created from
  42247. */
  42248. constructor(vrGamepad: any);
  42249. /**
  42250. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42251. * @param scene scene in which to add meshes
  42252. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42253. */
  42254. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42255. /**
  42256. * Fired when the A button on this controller is modified
  42257. */
  42258. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42259. /**
  42260. * Fired when the B button on this controller is modified
  42261. */
  42262. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42263. /**
  42264. * Fired when the X button on this controller is modified
  42265. */
  42266. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42267. /**
  42268. * Fired when the Y button on this controller is modified
  42269. */
  42270. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42271. /**
  42272. * Called once for each button that changed state since the last frame
  42273. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42274. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42275. * 2) secondary trigger (same)
  42276. * 3) A (right) X (left), touch, pressed = value
  42277. * 4) B / Y
  42278. * 5) thumb rest
  42279. * @param buttonIdx Which button index changed
  42280. * @param state New state of the button
  42281. * @param changes Which properties on the state changed since last frame
  42282. */
  42283. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42284. }
  42285. }
  42286. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42287. import { Scene } from "babylonjs/scene";
  42288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42289. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42290. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42291. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42292. import { Observable } from "babylonjs/Misc/observable";
  42293. /**
  42294. * Vive Controller
  42295. */
  42296. export class ViveController extends WebVRController {
  42297. /**
  42298. * Base Url for the controller model.
  42299. */
  42300. static MODEL_BASE_URL: string;
  42301. /**
  42302. * File name for the controller model.
  42303. */
  42304. static MODEL_FILENAME: string;
  42305. /**
  42306. * Creates a new ViveController from a gamepad
  42307. * @param vrGamepad the gamepad that the controller should be created from
  42308. */
  42309. constructor(vrGamepad: any);
  42310. /**
  42311. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42312. * @param scene scene in which to add meshes
  42313. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42314. */
  42315. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42316. /**
  42317. * Fired when the left button on this controller is modified
  42318. */
  42319. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42320. /**
  42321. * Fired when the right button on this controller is modified
  42322. */
  42323. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42324. /**
  42325. * Fired when the menu button on this controller is modified
  42326. */
  42327. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42328. /**
  42329. * Called once for each button that changed state since the last frame
  42330. * Vive mapping:
  42331. * 0: touchpad
  42332. * 1: trigger
  42333. * 2: left AND right buttons
  42334. * 3: menu button
  42335. * @param buttonIdx Which button index changed
  42336. * @param state New state of the button
  42337. * @param changes Which properties on the state changed since last frame
  42338. */
  42339. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42340. }
  42341. }
  42342. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42343. import { Observable } from "babylonjs/Misc/observable";
  42344. import { Scene } from "babylonjs/scene";
  42345. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42346. import { Ray } from "babylonjs/Culling/ray";
  42347. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42348. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42349. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42350. /**
  42351. * Defines the WindowsMotionController object that the state of the windows motion controller
  42352. */
  42353. export class WindowsMotionController extends WebVRController {
  42354. /**
  42355. * The base url used to load the left and right controller models
  42356. */
  42357. static MODEL_BASE_URL: string;
  42358. /**
  42359. * The name of the left controller model file
  42360. */
  42361. static MODEL_LEFT_FILENAME: string;
  42362. /**
  42363. * The name of the right controller model file
  42364. */
  42365. static MODEL_RIGHT_FILENAME: string;
  42366. /**
  42367. * The controller name prefix for this controller type
  42368. */
  42369. static readonly GAMEPAD_ID_PREFIX: string;
  42370. /**
  42371. * The controller id pattern for this controller type
  42372. */
  42373. private static readonly GAMEPAD_ID_PATTERN;
  42374. private _loadedMeshInfo;
  42375. private readonly _mapping;
  42376. /**
  42377. * Fired when the trackpad on this controller is clicked
  42378. */
  42379. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42380. /**
  42381. * Fired when the trackpad on this controller is modified
  42382. */
  42383. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42384. /**
  42385. * The current x and y values of this controller's trackpad
  42386. */
  42387. trackpad: StickValues;
  42388. /**
  42389. * Creates a new WindowsMotionController from a gamepad
  42390. * @param vrGamepad the gamepad that the controller should be created from
  42391. */
  42392. constructor(vrGamepad: any);
  42393. /**
  42394. * Fired when the trigger on this controller is modified
  42395. */
  42396. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42397. /**
  42398. * Fired when the menu button on this controller is modified
  42399. */
  42400. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42401. /**
  42402. * Fired when the grip button on this controller is modified
  42403. */
  42404. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42405. /**
  42406. * Fired when the thumbstick button on this controller is modified
  42407. */
  42408. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42409. /**
  42410. * Fired when the touchpad button on this controller is modified
  42411. */
  42412. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42413. /**
  42414. * Fired when the touchpad values on this controller are modified
  42415. */
  42416. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42417. private _updateTrackpad;
  42418. /**
  42419. * Called once per frame by the engine.
  42420. */
  42421. update(): void;
  42422. /**
  42423. * Called once for each button that changed state since the last frame
  42424. * @param buttonIdx Which button index changed
  42425. * @param state New state of the button
  42426. * @param changes Which properties on the state changed since last frame
  42427. */
  42428. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42429. /**
  42430. * Moves the buttons on the controller mesh based on their current state
  42431. * @param buttonName the name of the button to move
  42432. * @param buttonValue the value of the button which determines the buttons new position
  42433. */
  42434. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42435. /**
  42436. * Moves the axis on the controller mesh based on its current state
  42437. * @param axis the index of the axis
  42438. * @param axisValue the value of the axis which determines the meshes new position
  42439. * @hidden
  42440. */
  42441. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42442. /**
  42443. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42444. * @param scene scene in which to add meshes
  42445. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42446. */
  42447. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42448. /**
  42449. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42450. * can be transformed by button presses and axes values, based on this._mapping.
  42451. *
  42452. * @param scene scene in which the meshes exist
  42453. * @param meshes list of meshes that make up the controller model to process
  42454. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42455. */
  42456. private processModel;
  42457. private createMeshInfo;
  42458. /**
  42459. * Gets the ray of the controller in the direction the controller is pointing
  42460. * @param length the length the resulting ray should be
  42461. * @returns a ray in the direction the controller is pointing
  42462. */
  42463. getForwardRay(length?: number): Ray;
  42464. /**
  42465. * Disposes of the controller
  42466. */
  42467. dispose(): void;
  42468. }
  42469. }
  42470. declare module "babylonjs/Gamepads/Controllers/index" {
  42471. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  42472. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  42473. export * from "babylonjs/Gamepads/Controllers/genericController";
  42474. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  42475. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42476. export * from "babylonjs/Gamepads/Controllers/viveController";
  42477. export * from "babylonjs/Gamepads/Controllers/webVRController";
  42478. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  42479. }
  42480. declare module "babylonjs/Gamepads/index" {
  42481. export * from "babylonjs/Gamepads/Controllers/index";
  42482. export * from "babylonjs/Gamepads/gamepad";
  42483. export * from "babylonjs/Gamepads/gamepadManager";
  42484. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  42485. export * from "babylonjs/Gamepads/xboxGamepad";
  42486. }
  42487. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  42488. import { Observable } from "babylonjs/Misc/observable";
  42489. import { Nullable } from "babylonjs/types";
  42490. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42492. import { Mesh } from "babylonjs/Meshes/mesh";
  42493. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42494. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42495. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42496. /**
  42497. * Single axis scale gizmo
  42498. */
  42499. export class AxisScaleGizmo extends Gizmo {
  42500. private _coloredMaterial;
  42501. /**
  42502. * Drag behavior responsible for the gizmos dragging interactions
  42503. */
  42504. dragBehavior: PointerDragBehavior;
  42505. private _pointerObserver;
  42506. /**
  42507. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42508. */
  42509. snapDistance: number;
  42510. /**
  42511. * Event that fires each time the gizmo snaps to a new location.
  42512. * * snapDistance is the the change in distance
  42513. */
  42514. onSnapObservable: Observable<{
  42515. snapDistance: number;
  42516. }>;
  42517. /**
  42518. * If the scaling operation should be done on all axis (default: false)
  42519. */
  42520. uniformScaling: boolean;
  42521. /**
  42522. * Creates an AxisScaleGizmo
  42523. * @param gizmoLayer The utility layer the gizmo will be added to
  42524. * @param dragAxis The axis which the gizmo will be able to scale on
  42525. * @param color The color of the gizmo
  42526. */
  42527. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42528. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42529. /**
  42530. * Disposes of the gizmo
  42531. */
  42532. dispose(): void;
  42533. /**
  42534. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42535. * @param mesh The mesh to replace the default mesh of the gizmo
  42536. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42537. */
  42538. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42539. }
  42540. }
  42541. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  42542. import { Observable } from "babylonjs/Misc/observable";
  42543. import { Nullable } from "babylonjs/types";
  42544. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42545. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42546. import { Mesh } from "babylonjs/Meshes/mesh";
  42547. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42548. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42549. import "babylonjs/Meshes/Builders/boxBuilder";
  42550. /**
  42551. * Bounding box gizmo
  42552. */
  42553. export class BoundingBoxGizmo extends Gizmo {
  42554. private _lineBoundingBox;
  42555. private _rotateSpheresParent;
  42556. private _scaleBoxesParent;
  42557. private _boundingDimensions;
  42558. private _renderObserver;
  42559. private _pointerObserver;
  42560. private _scaleDragSpeed;
  42561. private _tmpQuaternion;
  42562. private _tmpVector;
  42563. private _tmpRotationMatrix;
  42564. /**
  42565. * 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)
  42566. */
  42567. ignoreChildren: boolean;
  42568. /**
  42569. * 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)
  42570. */
  42571. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42572. /**
  42573. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42574. */
  42575. rotationSphereSize: number;
  42576. /**
  42577. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42578. */
  42579. scaleBoxSize: number;
  42580. /**
  42581. * 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)
  42582. */
  42583. fixedDragMeshScreenSize: boolean;
  42584. /**
  42585. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42586. */
  42587. fixedDragMeshScreenSizeDistanceFactor: number;
  42588. /**
  42589. * Fired when a rotation sphere or scale box is dragged
  42590. */
  42591. onDragStartObservable: Observable<{}>;
  42592. /**
  42593. * Fired when a scale box is dragged
  42594. */
  42595. onScaleBoxDragObservable: Observable<{}>;
  42596. /**
  42597. * Fired when a scale box drag is ended
  42598. */
  42599. onScaleBoxDragEndObservable: Observable<{}>;
  42600. /**
  42601. * Fired when a rotation sphere is dragged
  42602. */
  42603. onRotationSphereDragObservable: Observable<{}>;
  42604. /**
  42605. * Fired when a rotation sphere drag is ended
  42606. */
  42607. onRotationSphereDragEndObservable: Observable<{}>;
  42608. /**
  42609. * 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)
  42610. */
  42611. scalePivot: Nullable<Vector3>;
  42612. private _anchorMesh;
  42613. private _existingMeshScale;
  42614. private _dragMesh;
  42615. private pointerDragBehavior;
  42616. /**
  42617. * Creates an BoundingBoxGizmo
  42618. * @param gizmoLayer The utility layer the gizmo will be added to
  42619. * @param color The color of the gizmo
  42620. */
  42621. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42622. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42623. private _selectNode;
  42624. /**
  42625. * Updates the bounding box information for the Gizmo
  42626. */
  42627. updateBoundingBox(): void;
  42628. private _updateRotationSpheres;
  42629. private _updateScaleBoxes;
  42630. /**
  42631. * Enables rotation on the specified axis and disables rotation on the others
  42632. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42633. */
  42634. setEnabledRotationAxis(axis: string): void;
  42635. /**
  42636. * Enables/disables scaling
  42637. * @param enable if scaling should be enabled
  42638. */
  42639. setEnabledScaling(enable: boolean): void;
  42640. private _updateDummy;
  42641. /**
  42642. * Enables a pointer drag behavior on the bounding box of the gizmo
  42643. */
  42644. enableDragBehavior(): void;
  42645. /**
  42646. * Disposes of the gizmo
  42647. */
  42648. dispose(): void;
  42649. /**
  42650. * 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)
  42651. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42652. * @returns the bounding box mesh with the passed in mesh as a child
  42653. */
  42654. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42655. /**
  42656. * CustomMeshes are not supported by this gizmo
  42657. * @param mesh The mesh to replace the default mesh of the gizmo
  42658. */
  42659. setCustomMesh(mesh: Mesh): void;
  42660. }
  42661. }
  42662. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  42663. import { Observable } from "babylonjs/Misc/observable";
  42664. import { Nullable } from "babylonjs/types";
  42665. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42667. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42668. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42669. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42670. import "babylonjs/Meshes/Builders/linesBuilder";
  42671. /**
  42672. * Single plane rotation gizmo
  42673. */
  42674. export class PlaneRotationGizmo extends Gizmo {
  42675. /**
  42676. * Drag behavior responsible for the gizmos dragging interactions
  42677. */
  42678. dragBehavior: PointerDragBehavior;
  42679. private _pointerObserver;
  42680. /**
  42681. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42682. */
  42683. snapDistance: number;
  42684. /**
  42685. * Event that fires each time the gizmo snaps to a new location.
  42686. * * snapDistance is the the change in distance
  42687. */
  42688. onSnapObservable: Observable<{
  42689. snapDistance: number;
  42690. }>;
  42691. /**
  42692. * Creates a PlaneRotationGizmo
  42693. * @param gizmoLayer The utility layer the gizmo will be added to
  42694. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42695. * @param color The color of the gizmo
  42696. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42697. */
  42698. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42699. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42700. /**
  42701. * Disposes of the gizmo
  42702. */
  42703. dispose(): void;
  42704. }
  42705. }
  42706. declare module "babylonjs/Gizmos/rotationGizmo" {
  42707. import { Observable } from "babylonjs/Misc/observable";
  42708. import { Nullable } from "babylonjs/types";
  42709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42710. import { Mesh } from "babylonjs/Meshes/mesh";
  42711. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42712. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  42713. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42714. /**
  42715. * Gizmo that enables rotating a mesh along 3 axis
  42716. */
  42717. export class RotationGizmo extends Gizmo {
  42718. /**
  42719. * Internal gizmo used for interactions on the x axis
  42720. */
  42721. xGizmo: PlaneRotationGizmo;
  42722. /**
  42723. * Internal gizmo used for interactions on the y axis
  42724. */
  42725. yGizmo: PlaneRotationGizmo;
  42726. /**
  42727. * Internal gizmo used for interactions on the z axis
  42728. */
  42729. zGizmo: PlaneRotationGizmo;
  42730. /** Fires an event when any of it's sub gizmos are dragged */
  42731. onDragStartObservable: Observable<{}>;
  42732. /** Fires an event when any of it's sub gizmos are released from dragging */
  42733. onDragEndObservable: Observable<{}>;
  42734. attachedMesh: Nullable<AbstractMesh>;
  42735. /**
  42736. * Creates a RotationGizmo
  42737. * @param gizmoLayer The utility layer the gizmo will be added to
  42738. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42739. */
  42740. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42741. updateGizmoRotationToMatchAttachedMesh: boolean;
  42742. /**
  42743. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42744. */
  42745. snapDistance: number;
  42746. /**
  42747. * Ratio for the scale of the gizmo (Default: 1)
  42748. */
  42749. scaleRatio: number;
  42750. /**
  42751. * Disposes of the gizmo
  42752. */
  42753. dispose(): void;
  42754. /**
  42755. * CustomMeshes are not supported by this gizmo
  42756. * @param mesh The mesh to replace the default mesh of the gizmo
  42757. */
  42758. setCustomMesh(mesh: Mesh): void;
  42759. }
  42760. }
  42761. declare module "babylonjs/Gizmos/positionGizmo" {
  42762. import { Observable } from "babylonjs/Misc/observable";
  42763. import { Nullable } from "babylonjs/types";
  42764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42765. import { Mesh } from "babylonjs/Meshes/mesh";
  42766. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42767. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42768. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42769. /**
  42770. * Gizmo that enables dragging a mesh along 3 axis
  42771. */
  42772. export class PositionGizmo extends Gizmo {
  42773. /**
  42774. * Internal gizmo used for interactions on the x axis
  42775. */
  42776. xGizmo: AxisDragGizmo;
  42777. /**
  42778. * Internal gizmo used for interactions on the y axis
  42779. */
  42780. yGizmo: AxisDragGizmo;
  42781. /**
  42782. * Internal gizmo used for interactions on the z axis
  42783. */
  42784. zGizmo: AxisDragGizmo;
  42785. /** Fires an event when any of it's sub gizmos are dragged */
  42786. onDragStartObservable: Observable<{}>;
  42787. /** Fires an event when any of it's sub gizmos are released from dragging */
  42788. onDragEndObservable: Observable<{}>;
  42789. attachedMesh: Nullable<AbstractMesh>;
  42790. /**
  42791. * Creates a PositionGizmo
  42792. * @param gizmoLayer The utility layer the gizmo will be added to
  42793. */
  42794. constructor(gizmoLayer?: UtilityLayerRenderer);
  42795. updateGizmoRotationToMatchAttachedMesh: boolean;
  42796. /**
  42797. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42798. */
  42799. snapDistance: number;
  42800. /**
  42801. * Ratio for the scale of the gizmo (Default: 1)
  42802. */
  42803. scaleRatio: number;
  42804. /**
  42805. * Disposes of the gizmo
  42806. */
  42807. dispose(): void;
  42808. /**
  42809. * CustomMeshes are not supported by this gizmo
  42810. * @param mesh The mesh to replace the default mesh of the gizmo
  42811. */
  42812. setCustomMesh(mesh: Mesh): void;
  42813. }
  42814. }
  42815. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  42816. import { Scene } from "babylonjs/scene";
  42817. import { Color4, Vector4 } from "babylonjs/Maths/math";
  42818. import { Mesh } from "babylonjs/Meshes/mesh";
  42819. /**
  42820. * Class containing static functions to help procedurally build meshes
  42821. */
  42822. export class PolyhedronBuilder {
  42823. /**
  42824. * Creates a polyhedron mesh
  42825. * * 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
  42826. * * The parameter `size` (positive float, default 1) sets the polygon size
  42827. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42828. * * 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`
  42829. * * 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
  42830. * * 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)`)
  42831. * * 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
  42832. * * 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
  42833. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42834. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42836. * @param name defines the name of the mesh
  42837. * @param options defines the options used to create the mesh
  42838. * @param scene defines the hosting scene
  42839. * @returns the polyhedron mesh
  42840. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42841. */
  42842. static CreatePolyhedron(name: string, options: {
  42843. type?: number;
  42844. size?: number;
  42845. sizeX?: number;
  42846. sizeY?: number;
  42847. sizeZ?: number;
  42848. custom?: any;
  42849. faceUV?: Vector4[];
  42850. faceColors?: Color4[];
  42851. flat?: boolean;
  42852. updatable?: boolean;
  42853. sideOrientation?: number;
  42854. frontUVs?: Vector4;
  42855. backUVs?: Vector4;
  42856. }, scene: Scene): Mesh;
  42857. }
  42858. }
  42859. declare module "babylonjs/Gizmos/scaleGizmo" {
  42860. import { Observable } from "babylonjs/Misc/observable";
  42861. import { Nullable } from "babylonjs/types";
  42862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42863. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42864. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  42865. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42866. /**
  42867. * Gizmo that enables scaling a mesh along 3 axis
  42868. */
  42869. export class ScaleGizmo extends Gizmo {
  42870. /**
  42871. * Internal gizmo used for interactions on the x axis
  42872. */
  42873. xGizmo: AxisScaleGizmo;
  42874. /**
  42875. * Internal gizmo used for interactions on the y axis
  42876. */
  42877. yGizmo: AxisScaleGizmo;
  42878. /**
  42879. * Internal gizmo used for interactions on the z axis
  42880. */
  42881. zGizmo: AxisScaleGizmo;
  42882. /**
  42883. * Internal gizmo used to scale all axis equally
  42884. */
  42885. uniformScaleGizmo: AxisScaleGizmo;
  42886. /** Fires an event when any of it's sub gizmos are dragged */
  42887. onDragStartObservable: Observable<{}>;
  42888. /** Fires an event when any of it's sub gizmos are released from dragging */
  42889. onDragEndObservable: Observable<{}>;
  42890. attachedMesh: Nullable<AbstractMesh>;
  42891. /**
  42892. * Creates a ScaleGizmo
  42893. * @param gizmoLayer The utility layer the gizmo will be added to
  42894. */
  42895. constructor(gizmoLayer?: UtilityLayerRenderer);
  42896. updateGizmoRotationToMatchAttachedMesh: boolean;
  42897. /**
  42898. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42899. */
  42900. snapDistance: number;
  42901. /**
  42902. * Ratio for the scale of the gizmo (Default: 1)
  42903. */
  42904. scaleRatio: number;
  42905. /**
  42906. * Disposes of the gizmo
  42907. */
  42908. dispose(): void;
  42909. }
  42910. }
  42911. declare module "babylonjs/Gizmos/gizmoManager" {
  42912. import { Observable } from "babylonjs/Misc/observable";
  42913. import { Nullable } from "babylonjs/types";
  42914. import { Scene, IDisposable } from "babylonjs/scene";
  42915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42916. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  42917. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  42918. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42919. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  42920. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  42921. /**
  42922. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42923. */
  42924. export class GizmoManager implements IDisposable {
  42925. private scene;
  42926. /**
  42927. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42928. */
  42929. gizmos: {
  42930. positionGizmo: Nullable<PositionGizmo>;
  42931. rotationGizmo: Nullable<RotationGizmo>;
  42932. scaleGizmo: Nullable<ScaleGizmo>;
  42933. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42934. };
  42935. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42936. clearGizmoOnEmptyPointerEvent: boolean;
  42937. /** Fires an event when the manager is attached to a mesh */
  42938. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42939. private _gizmosEnabled;
  42940. private _pointerObserver;
  42941. private _attachedMesh;
  42942. private _boundingBoxColor;
  42943. private _defaultUtilityLayer;
  42944. private _defaultKeepDepthUtilityLayer;
  42945. /**
  42946. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42947. */
  42948. boundingBoxDragBehavior: SixDofDragBehavior;
  42949. /**
  42950. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42951. */
  42952. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42953. /**
  42954. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42955. */
  42956. usePointerToAttachGizmos: boolean;
  42957. /**
  42958. * Instatiates a gizmo manager
  42959. * @param scene the scene to overlay the gizmos on top of
  42960. */
  42961. constructor(scene: Scene);
  42962. /**
  42963. * Attaches a set of gizmos to the specified mesh
  42964. * @param mesh The mesh the gizmo's should be attached to
  42965. */
  42966. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42967. /**
  42968. * If the position gizmo is enabled
  42969. */
  42970. positionGizmoEnabled: boolean;
  42971. /**
  42972. * If the rotation gizmo is enabled
  42973. */
  42974. rotationGizmoEnabled: boolean;
  42975. /**
  42976. * If the scale gizmo is enabled
  42977. */
  42978. scaleGizmoEnabled: boolean;
  42979. /**
  42980. * If the boundingBox gizmo is enabled
  42981. */
  42982. boundingBoxGizmoEnabled: boolean;
  42983. /**
  42984. * Disposes of the gizmo manager
  42985. */
  42986. dispose(): void;
  42987. }
  42988. }
  42989. declare module "babylonjs/Gizmos/index" {
  42990. export * from "babylonjs/Gizmos/axisDragGizmo";
  42991. export * from "babylonjs/Gizmos/axisScaleGizmo";
  42992. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  42993. export * from "babylonjs/Gizmos/gizmo";
  42994. export * from "babylonjs/Gizmos/gizmoManager";
  42995. export * from "babylonjs/Gizmos/planeRotationGizmo";
  42996. export * from "babylonjs/Gizmos/positionGizmo";
  42997. export * from "babylonjs/Gizmos/rotationGizmo";
  42998. export * from "babylonjs/Gizmos/scaleGizmo";
  42999. }
  43000. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43001. /** @hidden */
  43002. export var backgroundFragmentDeclaration: {
  43003. name: string;
  43004. shader: string;
  43005. };
  43006. }
  43007. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43008. /** @hidden */
  43009. export var backgroundUboDeclaration: {
  43010. name: string;
  43011. shader: string;
  43012. };
  43013. }
  43014. declare module "babylonjs/Shaders/background.fragment" {
  43015. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43016. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43017. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43018. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43019. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43020. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43021. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43022. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43023. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43024. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43025. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43026. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43027. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43028. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43029. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43030. /** @hidden */
  43031. export var backgroundPixelShader: {
  43032. name: string;
  43033. shader: string;
  43034. };
  43035. }
  43036. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43037. /** @hidden */
  43038. export var backgroundVertexDeclaration: {
  43039. name: string;
  43040. shader: string;
  43041. };
  43042. }
  43043. declare module "babylonjs/Shaders/background.vertex" {
  43044. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43045. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43046. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43047. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43048. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43049. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43050. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43051. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43052. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43053. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43054. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43055. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43056. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43057. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43058. /** @hidden */
  43059. export var backgroundVertexShader: {
  43060. name: string;
  43061. shader: string;
  43062. };
  43063. }
  43064. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43065. import { Nullable, int, float } from "babylonjs/types";
  43066. import { Scene } from "babylonjs/scene";
  43067. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43068. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43070. import { Mesh } from "babylonjs/Meshes/mesh";
  43071. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43072. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43073. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43074. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43075. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43076. import "babylonjs/Shaders/background.fragment";
  43077. import "babylonjs/Shaders/background.vertex";
  43078. /**
  43079. * Background material used to create an efficient environement around your scene.
  43080. */
  43081. export class BackgroundMaterial extends PushMaterial {
  43082. /**
  43083. * Standard reflectance value at parallel view angle.
  43084. */
  43085. static StandardReflectance0: number;
  43086. /**
  43087. * Standard reflectance value at grazing angle.
  43088. */
  43089. static StandardReflectance90: number;
  43090. protected _primaryColor: Color3;
  43091. /**
  43092. * Key light Color (multiply against the environement texture)
  43093. */
  43094. primaryColor: Color3;
  43095. protected __perceptualColor: Nullable<Color3>;
  43096. /**
  43097. * Experimental Internal Use Only.
  43098. *
  43099. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43100. * This acts as a helper to set the primary color to a more "human friendly" value.
  43101. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43102. * output color as close as possible from the chosen value.
  43103. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43104. * part of lighting setup.)
  43105. */
  43106. _perceptualColor: Nullable<Color3>;
  43107. protected _primaryColorShadowLevel: float;
  43108. /**
  43109. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43110. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43111. */
  43112. primaryColorShadowLevel: float;
  43113. protected _primaryColorHighlightLevel: float;
  43114. /**
  43115. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43116. * The primary color is used at the level chosen to define what the white area would look.
  43117. */
  43118. primaryColorHighlightLevel: float;
  43119. protected _reflectionTexture: Nullable<BaseTexture>;
  43120. /**
  43121. * Reflection Texture used in the material.
  43122. * Should be author in a specific way for the best result (refer to the documentation).
  43123. */
  43124. reflectionTexture: Nullable<BaseTexture>;
  43125. protected _reflectionBlur: float;
  43126. /**
  43127. * Reflection Texture level of blur.
  43128. *
  43129. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43130. * texture twice.
  43131. */
  43132. reflectionBlur: float;
  43133. protected _diffuseTexture: Nullable<BaseTexture>;
  43134. /**
  43135. * Diffuse Texture used in the material.
  43136. * Should be author in a specific way for the best result (refer to the documentation).
  43137. */
  43138. diffuseTexture: Nullable<BaseTexture>;
  43139. protected _shadowLights: Nullable<IShadowLight[]>;
  43140. /**
  43141. * Specify the list of lights casting shadow on the material.
  43142. * All scene shadow lights will be included if null.
  43143. */
  43144. shadowLights: Nullable<IShadowLight[]>;
  43145. protected _shadowLevel: float;
  43146. /**
  43147. * Helps adjusting the shadow to a softer level if required.
  43148. * 0 means black shadows and 1 means no shadows.
  43149. */
  43150. shadowLevel: float;
  43151. protected _sceneCenter: Vector3;
  43152. /**
  43153. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43154. * It is usually zero but might be interesting to modify according to your setup.
  43155. */
  43156. sceneCenter: Vector3;
  43157. protected _opacityFresnel: boolean;
  43158. /**
  43159. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43160. * This helps ensuring a nice transition when the camera goes under the ground.
  43161. */
  43162. opacityFresnel: boolean;
  43163. protected _reflectionFresnel: boolean;
  43164. /**
  43165. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43166. * This helps adding a mirror texture on the ground.
  43167. */
  43168. reflectionFresnel: boolean;
  43169. protected _reflectionFalloffDistance: number;
  43170. /**
  43171. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43172. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43173. */
  43174. reflectionFalloffDistance: number;
  43175. protected _reflectionAmount: number;
  43176. /**
  43177. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43178. */
  43179. reflectionAmount: number;
  43180. protected _reflectionReflectance0: number;
  43181. /**
  43182. * This specifies the weight of the reflection at grazing angle.
  43183. */
  43184. reflectionReflectance0: number;
  43185. protected _reflectionReflectance90: number;
  43186. /**
  43187. * This specifies the weight of the reflection at a perpendicular point of view.
  43188. */
  43189. reflectionReflectance90: number;
  43190. /**
  43191. * Sets the reflection reflectance fresnel values according to the default standard
  43192. * empirically know to work well :-)
  43193. */
  43194. reflectionStandardFresnelWeight: number;
  43195. protected _useRGBColor: boolean;
  43196. /**
  43197. * Helps to directly use the maps channels instead of their level.
  43198. */
  43199. useRGBColor: boolean;
  43200. protected _enableNoise: boolean;
  43201. /**
  43202. * This helps reducing the banding effect that could occur on the background.
  43203. */
  43204. enableNoise: boolean;
  43205. /**
  43206. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43207. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43208. * Recommended to be keep at 1.0 except for special cases.
  43209. */
  43210. fovMultiplier: number;
  43211. private _fovMultiplier;
  43212. /**
  43213. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43214. */
  43215. useEquirectangularFOV: boolean;
  43216. private _maxSimultaneousLights;
  43217. /**
  43218. * Number of Simultaneous lights allowed on the material.
  43219. */
  43220. maxSimultaneousLights: int;
  43221. /**
  43222. * Default configuration related to image processing available in the Background Material.
  43223. */
  43224. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43225. /**
  43226. * Keep track of the image processing observer to allow dispose and replace.
  43227. */
  43228. private _imageProcessingObserver;
  43229. /**
  43230. * Attaches a new image processing configuration to the PBR Material.
  43231. * @param configuration (if null the scene configuration will be use)
  43232. */
  43233. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43234. /**
  43235. * Gets the image processing configuration used either in this material.
  43236. */
  43237. /**
  43238. * Sets the Default image processing configuration used either in the this material.
  43239. *
  43240. * If sets to null, the scene one is in use.
  43241. */
  43242. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43243. /**
  43244. * Gets wether the color curves effect is enabled.
  43245. */
  43246. /**
  43247. * Sets wether the color curves effect is enabled.
  43248. */
  43249. cameraColorCurvesEnabled: boolean;
  43250. /**
  43251. * Gets wether the color grading effect is enabled.
  43252. */
  43253. /**
  43254. * Gets wether the color grading effect is enabled.
  43255. */
  43256. cameraColorGradingEnabled: boolean;
  43257. /**
  43258. * Gets wether tonemapping is enabled or not.
  43259. */
  43260. /**
  43261. * Sets wether tonemapping is enabled or not
  43262. */
  43263. cameraToneMappingEnabled: boolean;
  43264. /**
  43265. * The camera exposure used on this material.
  43266. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43267. * This corresponds to a photographic exposure.
  43268. */
  43269. /**
  43270. * The camera exposure used on this material.
  43271. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43272. * This corresponds to a photographic exposure.
  43273. */
  43274. cameraExposure: float;
  43275. /**
  43276. * Gets The camera contrast used on this material.
  43277. */
  43278. /**
  43279. * Sets The camera contrast used on this material.
  43280. */
  43281. cameraContrast: float;
  43282. /**
  43283. * Gets the Color Grading 2D Lookup Texture.
  43284. */
  43285. /**
  43286. * Sets the Color Grading 2D Lookup Texture.
  43287. */
  43288. cameraColorGradingTexture: Nullable<BaseTexture>;
  43289. /**
  43290. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43291. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43292. * 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;
  43293. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43294. */
  43295. /**
  43296. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43297. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43298. * 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;
  43299. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43300. */
  43301. cameraColorCurves: Nullable<ColorCurves>;
  43302. /**
  43303. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43304. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43305. */
  43306. switchToBGR: boolean;
  43307. private _renderTargets;
  43308. private _reflectionControls;
  43309. private _white;
  43310. private _primaryShadowColor;
  43311. private _primaryHighlightColor;
  43312. /**
  43313. * Instantiates a Background Material in the given scene
  43314. * @param name The friendly name of the material
  43315. * @param scene The scene to add the material to
  43316. */
  43317. constructor(name: string, scene: Scene);
  43318. /**
  43319. * Gets a boolean indicating that current material needs to register RTT
  43320. */
  43321. readonly hasRenderTargetTextures: boolean;
  43322. /**
  43323. * The entire material has been created in order to prevent overdraw.
  43324. * @returns false
  43325. */
  43326. needAlphaTesting(): boolean;
  43327. /**
  43328. * The entire material has been created in order to prevent overdraw.
  43329. * @returns true if blending is enable
  43330. */
  43331. needAlphaBlending(): boolean;
  43332. /**
  43333. * Checks wether the material is ready to be rendered for a given mesh.
  43334. * @param mesh The mesh to render
  43335. * @param subMesh The submesh to check against
  43336. * @param useInstances Specify wether or not the material is used with instances
  43337. * @returns true if all the dependencies are ready (Textures, Effects...)
  43338. */
  43339. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43340. /**
  43341. * Compute the primary color according to the chosen perceptual color.
  43342. */
  43343. private _computePrimaryColorFromPerceptualColor;
  43344. /**
  43345. * Compute the highlights and shadow colors according to their chosen levels.
  43346. */
  43347. private _computePrimaryColors;
  43348. /**
  43349. * Build the uniform buffer used in the material.
  43350. */
  43351. buildUniformLayout(): void;
  43352. /**
  43353. * Unbind the material.
  43354. */
  43355. unbind(): void;
  43356. /**
  43357. * Bind only the world matrix to the material.
  43358. * @param world The world matrix to bind.
  43359. */
  43360. bindOnlyWorldMatrix(world: Matrix): void;
  43361. /**
  43362. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43363. * @param world The world matrix to bind.
  43364. * @param subMesh The submesh to bind for.
  43365. */
  43366. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43367. /**
  43368. * Dispose the material.
  43369. * @param forceDisposeEffect Force disposal of the associated effect.
  43370. * @param forceDisposeTextures Force disposal of the associated textures.
  43371. */
  43372. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43373. /**
  43374. * Clones the material.
  43375. * @param name The cloned name.
  43376. * @returns The cloned material.
  43377. */
  43378. clone(name: string): BackgroundMaterial;
  43379. /**
  43380. * Serializes the current material to its JSON representation.
  43381. * @returns The JSON representation.
  43382. */
  43383. serialize(): any;
  43384. /**
  43385. * Gets the class name of the material
  43386. * @returns "BackgroundMaterial"
  43387. */
  43388. getClassName(): string;
  43389. /**
  43390. * Parse a JSON input to create back a background material.
  43391. * @param source The JSON data to parse
  43392. * @param scene The scene to create the parsed material in
  43393. * @param rootUrl The root url of the assets the material depends upon
  43394. * @returns the instantiated BackgroundMaterial.
  43395. */
  43396. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43397. }
  43398. }
  43399. declare module "babylonjs/Helpers/environmentHelper" {
  43400. import { Observable } from "babylonjs/Misc/observable";
  43401. import { Nullable } from "babylonjs/types";
  43402. import { Scene } from "babylonjs/scene";
  43403. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43404. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43405. import { Mesh } from "babylonjs/Meshes/mesh";
  43406. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43407. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43408. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43409. import "babylonjs/Meshes/Builders/planeBuilder";
  43410. import "babylonjs/Meshes/Builders/boxBuilder";
  43411. /**
  43412. * Represents the different options available during the creation of
  43413. * a Environment helper.
  43414. *
  43415. * This can control the default ground, skybox and image processing setup of your scene.
  43416. */
  43417. export interface IEnvironmentHelperOptions {
  43418. /**
  43419. * Specifies wether or not to create a ground.
  43420. * True by default.
  43421. */
  43422. createGround: boolean;
  43423. /**
  43424. * Specifies the ground size.
  43425. * 15 by default.
  43426. */
  43427. groundSize: number;
  43428. /**
  43429. * The texture used on the ground for the main color.
  43430. * Comes from the BabylonJS CDN by default.
  43431. *
  43432. * Remarks: Can be either a texture or a url.
  43433. */
  43434. groundTexture: string | BaseTexture;
  43435. /**
  43436. * The color mixed in the ground texture by default.
  43437. * BabylonJS clearColor by default.
  43438. */
  43439. groundColor: Color3;
  43440. /**
  43441. * Specifies the ground opacity.
  43442. * 1 by default.
  43443. */
  43444. groundOpacity: number;
  43445. /**
  43446. * Enables the ground to receive shadows.
  43447. * True by default.
  43448. */
  43449. enableGroundShadow: boolean;
  43450. /**
  43451. * Helps preventing the shadow to be fully black on the ground.
  43452. * 0.5 by default.
  43453. */
  43454. groundShadowLevel: number;
  43455. /**
  43456. * Creates a mirror texture attach to the ground.
  43457. * false by default.
  43458. */
  43459. enableGroundMirror: boolean;
  43460. /**
  43461. * Specifies the ground mirror size ratio.
  43462. * 0.3 by default as the default kernel is 64.
  43463. */
  43464. groundMirrorSizeRatio: number;
  43465. /**
  43466. * Specifies the ground mirror blur kernel size.
  43467. * 64 by default.
  43468. */
  43469. groundMirrorBlurKernel: number;
  43470. /**
  43471. * Specifies the ground mirror visibility amount.
  43472. * 1 by default
  43473. */
  43474. groundMirrorAmount: number;
  43475. /**
  43476. * Specifies the ground mirror reflectance weight.
  43477. * This uses the standard weight of the background material to setup the fresnel effect
  43478. * of the mirror.
  43479. * 1 by default.
  43480. */
  43481. groundMirrorFresnelWeight: number;
  43482. /**
  43483. * Specifies the ground mirror Falloff distance.
  43484. * This can helps reducing the size of the reflection.
  43485. * 0 by Default.
  43486. */
  43487. groundMirrorFallOffDistance: number;
  43488. /**
  43489. * Specifies the ground mirror texture type.
  43490. * Unsigned Int by Default.
  43491. */
  43492. groundMirrorTextureType: number;
  43493. /**
  43494. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43495. * the shown objects.
  43496. */
  43497. groundYBias: number;
  43498. /**
  43499. * Specifies wether or not to create a skybox.
  43500. * True by default.
  43501. */
  43502. createSkybox: boolean;
  43503. /**
  43504. * Specifies the skybox size.
  43505. * 20 by default.
  43506. */
  43507. skyboxSize: number;
  43508. /**
  43509. * The texture used on the skybox for the main color.
  43510. * Comes from the BabylonJS CDN by default.
  43511. *
  43512. * Remarks: Can be either a texture or a url.
  43513. */
  43514. skyboxTexture: string | BaseTexture;
  43515. /**
  43516. * The color mixed in the skybox texture by default.
  43517. * BabylonJS clearColor by default.
  43518. */
  43519. skyboxColor: Color3;
  43520. /**
  43521. * The background rotation around the Y axis of the scene.
  43522. * This helps aligning the key lights of your scene with the background.
  43523. * 0 by default.
  43524. */
  43525. backgroundYRotation: number;
  43526. /**
  43527. * Compute automatically the size of the elements to best fit with the scene.
  43528. */
  43529. sizeAuto: boolean;
  43530. /**
  43531. * Default position of the rootMesh if autoSize is not true.
  43532. */
  43533. rootPosition: Vector3;
  43534. /**
  43535. * Sets up the image processing in the scene.
  43536. * true by default.
  43537. */
  43538. setupImageProcessing: boolean;
  43539. /**
  43540. * The texture used as your environment texture in the scene.
  43541. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43542. *
  43543. * Remarks: Can be either a texture or a url.
  43544. */
  43545. environmentTexture: string | BaseTexture;
  43546. /**
  43547. * The value of the exposure to apply to the scene.
  43548. * 0.6 by default if setupImageProcessing is true.
  43549. */
  43550. cameraExposure: number;
  43551. /**
  43552. * The value of the contrast to apply to the scene.
  43553. * 1.6 by default if setupImageProcessing is true.
  43554. */
  43555. cameraContrast: number;
  43556. /**
  43557. * Specifies wether or not tonemapping should be enabled in the scene.
  43558. * true by default if setupImageProcessing is true.
  43559. */
  43560. toneMappingEnabled: boolean;
  43561. }
  43562. /**
  43563. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43564. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43565. * It also helps with the default setup of your imageProcessing configuration.
  43566. */
  43567. export class EnvironmentHelper {
  43568. /**
  43569. * Default ground texture URL.
  43570. */
  43571. private static _groundTextureCDNUrl;
  43572. /**
  43573. * Default skybox texture URL.
  43574. */
  43575. private static _skyboxTextureCDNUrl;
  43576. /**
  43577. * Default environment texture URL.
  43578. */
  43579. private static _environmentTextureCDNUrl;
  43580. /**
  43581. * Creates the default options for the helper.
  43582. */
  43583. private static _getDefaultOptions;
  43584. private _rootMesh;
  43585. /**
  43586. * Gets the root mesh created by the helper.
  43587. */
  43588. readonly rootMesh: Mesh;
  43589. private _skybox;
  43590. /**
  43591. * Gets the skybox created by the helper.
  43592. */
  43593. readonly skybox: Nullable<Mesh>;
  43594. private _skyboxTexture;
  43595. /**
  43596. * Gets the skybox texture created by the helper.
  43597. */
  43598. readonly skyboxTexture: Nullable<BaseTexture>;
  43599. private _skyboxMaterial;
  43600. /**
  43601. * Gets the skybox material created by the helper.
  43602. */
  43603. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43604. private _ground;
  43605. /**
  43606. * Gets the ground mesh created by the helper.
  43607. */
  43608. readonly ground: Nullable<Mesh>;
  43609. private _groundTexture;
  43610. /**
  43611. * Gets the ground texture created by the helper.
  43612. */
  43613. readonly groundTexture: Nullable<BaseTexture>;
  43614. private _groundMirror;
  43615. /**
  43616. * Gets the ground mirror created by the helper.
  43617. */
  43618. readonly groundMirror: Nullable<MirrorTexture>;
  43619. /**
  43620. * Gets the ground mirror render list to helps pushing the meshes
  43621. * you wish in the ground reflection.
  43622. */
  43623. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43624. private _groundMaterial;
  43625. /**
  43626. * Gets the ground material created by the helper.
  43627. */
  43628. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43629. /**
  43630. * Stores the creation options.
  43631. */
  43632. private readonly _scene;
  43633. private _options;
  43634. /**
  43635. * This observable will be notified with any error during the creation of the environment,
  43636. * mainly texture creation errors.
  43637. */
  43638. onErrorObservable: Observable<{
  43639. message?: string;
  43640. exception?: any;
  43641. }>;
  43642. /**
  43643. * constructor
  43644. * @param options Defines the options we want to customize the helper
  43645. * @param scene The scene to add the material to
  43646. */
  43647. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43648. /**
  43649. * Updates the background according to the new options
  43650. * @param options
  43651. */
  43652. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43653. /**
  43654. * Sets the primary color of all the available elements.
  43655. * @param color the main color to affect to the ground and the background
  43656. */
  43657. setMainColor(color: Color3): void;
  43658. /**
  43659. * Setup the image processing according to the specified options.
  43660. */
  43661. private _setupImageProcessing;
  43662. /**
  43663. * Setup the environment texture according to the specified options.
  43664. */
  43665. private _setupEnvironmentTexture;
  43666. /**
  43667. * Setup the background according to the specified options.
  43668. */
  43669. private _setupBackground;
  43670. /**
  43671. * Get the scene sizes according to the setup.
  43672. */
  43673. private _getSceneSize;
  43674. /**
  43675. * Setup the ground according to the specified options.
  43676. */
  43677. private _setupGround;
  43678. /**
  43679. * Setup the ground material according to the specified options.
  43680. */
  43681. private _setupGroundMaterial;
  43682. /**
  43683. * Setup the ground diffuse texture according to the specified options.
  43684. */
  43685. private _setupGroundDiffuseTexture;
  43686. /**
  43687. * Setup the ground mirror texture according to the specified options.
  43688. */
  43689. private _setupGroundMirrorTexture;
  43690. /**
  43691. * Setup the ground to receive the mirror texture.
  43692. */
  43693. private _setupMirrorInGroundMaterial;
  43694. /**
  43695. * Setup the skybox according to the specified options.
  43696. */
  43697. private _setupSkybox;
  43698. /**
  43699. * Setup the skybox material according to the specified options.
  43700. */
  43701. private _setupSkyboxMaterial;
  43702. /**
  43703. * Setup the skybox reflection texture according to the specified options.
  43704. */
  43705. private _setupSkyboxReflectionTexture;
  43706. private _errorHandler;
  43707. /**
  43708. * Dispose all the elements created by the Helper.
  43709. */
  43710. dispose(): void;
  43711. }
  43712. }
  43713. declare module "babylonjs/Helpers/photoDome" {
  43714. import { Observable } from "babylonjs/Misc/observable";
  43715. import { Nullable } from "babylonjs/types";
  43716. import { Scene } from "babylonjs/scene";
  43717. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43718. import { Mesh } from "babylonjs/Meshes/mesh";
  43719. import { Texture } from "babylonjs/Materials/Textures/texture";
  43720. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43721. import "babylonjs/Meshes/Builders/sphereBuilder";
  43722. /**
  43723. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43724. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43725. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43726. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43727. */
  43728. export class PhotoDome extends TransformNode {
  43729. private _useDirectMapping;
  43730. /**
  43731. * The texture being displayed on the sphere
  43732. */
  43733. protected _photoTexture: Texture;
  43734. /**
  43735. * Gets or sets the texture being displayed on the sphere
  43736. */
  43737. photoTexture: Texture;
  43738. /**
  43739. * Observable raised when an error occured while loading the 360 image
  43740. */
  43741. onLoadErrorObservable: Observable<string>;
  43742. /**
  43743. * The skybox material
  43744. */
  43745. protected _material: BackgroundMaterial;
  43746. /**
  43747. * The surface used for the skybox
  43748. */
  43749. protected _mesh: Mesh;
  43750. /**
  43751. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43752. * Also see the options.resolution property.
  43753. */
  43754. fovMultiplier: number;
  43755. /**
  43756. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43757. * @param name Element's name, child elements will append suffixes for their own names.
  43758. * @param urlsOfPhoto defines the url of the photo to display
  43759. * @param options defines an object containing optional or exposed sub element properties
  43760. * @param onError defines a callback called when an error occured while loading the texture
  43761. */
  43762. constructor(name: string, urlOfPhoto: string, options: {
  43763. resolution?: number;
  43764. size?: number;
  43765. useDirectMapping?: boolean;
  43766. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43767. /**
  43768. * Releases resources associated with this node.
  43769. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43770. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43771. */
  43772. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43773. }
  43774. }
  43775. declare module "babylonjs/Misc/textureTools" {
  43776. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43777. import { Texture } from "babylonjs/Materials/Textures/texture";
  43778. import { Scene } from "babylonjs/scene";
  43779. /**
  43780. * Class used to host texture specific utilities
  43781. */
  43782. export class TextureTools {
  43783. /**
  43784. * Uses the GPU to create a copy texture rescaled at a given size
  43785. * @param texture Texture to copy from
  43786. * @param width defines the desired width
  43787. * @param height defines the desired height
  43788. * @param useBilinearMode defines if bilinear mode has to be used
  43789. * @return the generated texture
  43790. */
  43791. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  43792. /**
  43793. * Gets an environment BRDF texture for a given scene
  43794. * @param scene defines the hosting scene
  43795. * @returns the environment BRDF texture
  43796. */
  43797. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43798. private static _environmentBRDFBase64Texture;
  43799. }
  43800. }
  43801. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  43802. /** @hidden */
  43803. export var pbrFragmentDeclaration: {
  43804. name: string;
  43805. shader: string;
  43806. };
  43807. }
  43808. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  43809. /** @hidden */
  43810. export var pbrUboDeclaration: {
  43811. name: string;
  43812. shader: string;
  43813. };
  43814. }
  43815. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  43816. /** @hidden */
  43817. export var pbrFunctions: {
  43818. name: string;
  43819. shader: string;
  43820. };
  43821. }
  43822. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  43823. /** @hidden */
  43824. export var harmonicsFunctions: {
  43825. name: string;
  43826. shader: string;
  43827. };
  43828. }
  43829. declare module "babylonjs/Shaders/ShadersInclude/pbrLightFunctions" {
  43830. /** @hidden */
  43831. export var pbrLightFunctions: {
  43832. name: string;
  43833. shader: string;
  43834. };
  43835. }
  43836. declare module "babylonjs/Shaders/pbr.fragment" {
  43837. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  43838. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  43839. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43840. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43841. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43842. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43843. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43844. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43845. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43846. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  43847. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  43848. import "babylonjs/Shaders/ShadersInclude/pbrLightFunctions";
  43849. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  43850. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43851. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  43852. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43853. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43854. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  43855. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  43856. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43857. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  43858. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43859. /** @hidden */
  43860. export var pbrPixelShader: {
  43861. name: string;
  43862. shader: string;
  43863. };
  43864. }
  43865. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  43866. /** @hidden */
  43867. export var pbrVertexDeclaration: {
  43868. name: string;
  43869. shader: string;
  43870. };
  43871. }
  43872. declare module "babylonjs/Shaders/pbr.vertex" {
  43873. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  43874. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  43875. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43876. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43877. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43878. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  43879. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  43880. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43881. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43882. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43883. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43884. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  43885. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  43886. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  43887. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  43888. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43889. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43890. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  43891. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43892. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43893. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43894. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  43895. /** @hidden */
  43896. export var pbrVertexShader: {
  43897. name: string;
  43898. shader: string;
  43899. };
  43900. }
  43901. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  43902. import { IAnimatable } from "babylonjs/Misc/tools";
  43903. import { Nullable } from "babylonjs/types";
  43904. import { Scene } from "babylonjs/scene";
  43905. import { Matrix, Color3 } from "babylonjs/Maths/math";
  43906. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43907. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43908. import { Mesh } from "babylonjs/Meshes/mesh";
  43909. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43910. import { Material } from "babylonjs/Materials/material";
  43911. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43912. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43913. import "babylonjs/Shaders/pbr.fragment";
  43914. import "babylonjs/Shaders/pbr.vertex";
  43915. /**
  43916. * The Physically based material base class of BJS.
  43917. *
  43918. * This offers the main features of a standard PBR material.
  43919. * For more information, please refer to the documentation :
  43920. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  43921. */
  43922. export abstract class PBRBaseMaterial extends PushMaterial {
  43923. /**
  43924. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  43925. */
  43926. static readonly PBRMATERIAL_OPAQUE: number;
  43927. /**
  43928. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  43929. */
  43930. static readonly PBRMATERIAL_ALPHATEST: number;
  43931. /**
  43932. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43933. */
  43934. static readonly PBRMATERIAL_ALPHABLEND: number;
  43935. /**
  43936. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43937. * They are also discarded below the alpha cutoff threshold to improve performances.
  43938. */
  43939. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  43940. /**
  43941. * Defines the default value of how much AO map is occluding the analytical lights
  43942. * (point spot...).
  43943. */
  43944. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  43945. /**
  43946. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  43947. */
  43948. static readonly LIGHTFALLOFF_PHYSICAL: number;
  43949. /**
  43950. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  43951. * to enhance interoperability with other engines.
  43952. */
  43953. static readonly LIGHTFALLOFF_GLTF: number;
  43954. /**
  43955. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  43956. * to enhance interoperability with other materials.
  43957. */
  43958. static readonly LIGHTFALLOFF_STANDARD: number;
  43959. /**
  43960. * Intensity of the direct lights e.g. the four lights available in your scene.
  43961. * This impacts both the direct diffuse and specular highlights.
  43962. */
  43963. protected _directIntensity: number;
  43964. /**
  43965. * Intensity of the emissive part of the material.
  43966. * This helps controlling the emissive effect without modifying the emissive color.
  43967. */
  43968. protected _emissiveIntensity: number;
  43969. /**
  43970. * Intensity of the environment e.g. how much the environment will light the object
  43971. * either through harmonics for rough material or through the refelction for shiny ones.
  43972. */
  43973. protected _environmentIntensity: number;
  43974. /**
  43975. * This is a special control allowing the reduction of the specular highlights coming from the
  43976. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  43977. */
  43978. protected _specularIntensity: number;
  43979. /**
  43980. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  43981. */
  43982. private _lightingInfos;
  43983. /**
  43984. * Debug Control allowing disabling the bump map on this material.
  43985. */
  43986. protected _disableBumpMap: boolean;
  43987. /**
  43988. * AKA Diffuse Texture in standard nomenclature.
  43989. */
  43990. protected _albedoTexture: BaseTexture;
  43991. /**
  43992. * AKA Occlusion Texture in other nomenclature.
  43993. */
  43994. protected _ambientTexture: BaseTexture;
  43995. /**
  43996. * AKA Occlusion Texture Intensity in other nomenclature.
  43997. */
  43998. protected _ambientTextureStrength: number;
  43999. /**
  44000. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44001. * 1 means it completely occludes it
  44002. * 0 mean it has no impact
  44003. */
  44004. protected _ambientTextureImpactOnAnalyticalLights: number;
  44005. /**
  44006. * Stores the alpha values in a texture.
  44007. */
  44008. protected _opacityTexture: BaseTexture;
  44009. /**
  44010. * Stores the reflection values in a texture.
  44011. */
  44012. protected _reflectionTexture: BaseTexture;
  44013. /**
  44014. * Stores the refraction values in a texture.
  44015. */
  44016. protected _refractionTexture: BaseTexture;
  44017. /**
  44018. * Stores the emissive values in a texture.
  44019. */
  44020. protected _emissiveTexture: BaseTexture;
  44021. /**
  44022. * AKA Specular texture in other nomenclature.
  44023. */
  44024. protected _reflectivityTexture: BaseTexture;
  44025. /**
  44026. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44027. */
  44028. protected _metallicTexture: BaseTexture;
  44029. /**
  44030. * Specifies the metallic scalar of the metallic/roughness workflow.
  44031. * Can also be used to scale the metalness values of the metallic texture.
  44032. */
  44033. protected _metallic: Nullable<number>;
  44034. /**
  44035. * Specifies the roughness scalar of the metallic/roughness workflow.
  44036. * Can also be used to scale the roughness values of the metallic texture.
  44037. */
  44038. protected _roughness: Nullable<number>;
  44039. /**
  44040. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44041. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44042. */
  44043. protected _microSurfaceTexture: BaseTexture;
  44044. /**
  44045. * Stores surface normal data used to displace a mesh in a texture.
  44046. */
  44047. protected _bumpTexture: BaseTexture;
  44048. /**
  44049. * Stores the pre-calculated light information of a mesh in a texture.
  44050. */
  44051. protected _lightmapTexture: BaseTexture;
  44052. /**
  44053. * The color of a material in ambient lighting.
  44054. */
  44055. protected _ambientColor: Color3;
  44056. /**
  44057. * AKA Diffuse Color in other nomenclature.
  44058. */
  44059. protected _albedoColor: Color3;
  44060. /**
  44061. * AKA Specular Color in other nomenclature.
  44062. */
  44063. protected _reflectivityColor: Color3;
  44064. /**
  44065. * The color applied when light is reflected from a material.
  44066. */
  44067. protected _reflectionColor: Color3;
  44068. /**
  44069. * The color applied when light is emitted from a material.
  44070. */
  44071. protected _emissiveColor: Color3;
  44072. /**
  44073. * AKA Glossiness in other nomenclature.
  44074. */
  44075. protected _microSurface: number;
  44076. /**
  44077. * source material index of refraction (IOR)' / 'destination material IOR.
  44078. */
  44079. protected _indexOfRefraction: number;
  44080. /**
  44081. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44082. */
  44083. protected _invertRefractionY: boolean;
  44084. /**
  44085. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44086. * Materials half opaque for instance using refraction could benefit from this control.
  44087. */
  44088. protected _linkRefractionWithTransparency: boolean;
  44089. /**
  44090. * Specifies that the material will use the light map as a show map.
  44091. */
  44092. protected _useLightmapAsShadowmap: boolean;
  44093. /**
  44094. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44095. * makes the reflect vector face the model (under horizon).
  44096. */
  44097. protected _useHorizonOcclusion: boolean;
  44098. /**
  44099. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44100. * too much the area relying on ambient texture to define their ambient occlusion.
  44101. */
  44102. protected _useRadianceOcclusion: boolean;
  44103. /**
  44104. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44105. */
  44106. protected _useAlphaFromAlbedoTexture: boolean;
  44107. /**
  44108. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44109. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44110. */
  44111. protected _useSpecularOverAlpha: boolean;
  44112. /**
  44113. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44114. */
  44115. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44116. /**
  44117. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44118. */
  44119. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44120. /**
  44121. * Specifies if the metallic texture contains the roughness information in its green channel.
  44122. */
  44123. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44124. /**
  44125. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44126. */
  44127. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44128. /**
  44129. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44130. */
  44131. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44132. /**
  44133. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44134. */
  44135. protected _useAmbientInGrayScale: boolean;
  44136. /**
  44137. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44138. * The material will try to infer what glossiness each pixel should be.
  44139. */
  44140. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44141. /**
  44142. * Defines the falloff type used in this material.
  44143. * It by default is Physical.
  44144. */
  44145. protected _lightFalloff: number;
  44146. /**
  44147. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44148. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44149. */
  44150. protected _useRadianceOverAlpha: boolean;
  44151. /**
  44152. * Allows using an object space normal map (instead of tangent space).
  44153. */
  44154. protected _useObjectSpaceNormalMap: boolean;
  44155. /**
  44156. * Allows using the bump map in parallax mode.
  44157. */
  44158. protected _useParallax: boolean;
  44159. /**
  44160. * Allows using the bump map in parallax occlusion mode.
  44161. */
  44162. protected _useParallaxOcclusion: boolean;
  44163. /**
  44164. * Controls the scale bias of the parallax mode.
  44165. */
  44166. protected _parallaxScaleBias: number;
  44167. /**
  44168. * If sets to true, disables all the lights affecting the material.
  44169. */
  44170. protected _disableLighting: boolean;
  44171. /**
  44172. * Number of Simultaneous lights allowed on the material.
  44173. */
  44174. protected _maxSimultaneousLights: number;
  44175. /**
  44176. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44177. */
  44178. protected _invertNormalMapX: boolean;
  44179. /**
  44180. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44181. */
  44182. protected _invertNormalMapY: boolean;
  44183. /**
  44184. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44185. */
  44186. protected _twoSidedLighting: boolean;
  44187. /**
  44188. * Defines the alpha limits in alpha test mode.
  44189. */
  44190. protected _alphaCutOff: number;
  44191. /**
  44192. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44193. */
  44194. protected _forceAlphaTest: boolean;
  44195. /**
  44196. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44197. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44198. */
  44199. protected _useAlphaFresnel: boolean;
  44200. /**
  44201. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44202. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44203. */
  44204. protected _useLinearAlphaFresnel: boolean;
  44205. /**
  44206. * The transparency mode of the material.
  44207. */
  44208. protected _transparencyMode: Nullable<number>;
  44209. /**
  44210. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44211. * from cos thetav and roughness:
  44212. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44213. */
  44214. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44215. /**
  44216. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44217. */
  44218. protected _forceIrradianceInFragment: boolean;
  44219. /**
  44220. * Force normal to face away from face.
  44221. */
  44222. protected _forceNormalForward: boolean;
  44223. /**
  44224. * Enables specular anti aliasing in the PBR shader.
  44225. * It will both interacts on the Geometry for analytical and IBL lighting.
  44226. * It also prefilter the roughness map based on the bump values.
  44227. */
  44228. protected _enableSpecularAntiAliasing: boolean;
  44229. /**
  44230. * Default configuration related to image processing available in the PBR Material.
  44231. */
  44232. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44233. /**
  44234. * Keep track of the image processing observer to allow dispose and replace.
  44235. */
  44236. private _imageProcessingObserver;
  44237. /**
  44238. * Attaches a new image processing configuration to the PBR Material.
  44239. * @param configuration
  44240. */
  44241. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44242. /**
  44243. * Stores the available render targets.
  44244. */
  44245. private _renderTargets;
  44246. /**
  44247. * Sets the global ambient color for the material used in lighting calculations.
  44248. */
  44249. private _globalAmbientColor;
  44250. /**
  44251. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44252. */
  44253. private _useLogarithmicDepth;
  44254. /**
  44255. * If set to true, no lighting calculations will be applied.
  44256. */
  44257. private _unlit;
  44258. /**
  44259. * Instantiates a new PBRMaterial instance.
  44260. *
  44261. * @param name The material name
  44262. * @param scene The scene the material will be use in.
  44263. */
  44264. constructor(name: string, scene: Scene);
  44265. /**
  44266. * Gets a boolean indicating that current material needs to register RTT
  44267. */
  44268. readonly hasRenderTargetTextures: boolean;
  44269. /**
  44270. * Gets the name of the material class.
  44271. */
  44272. getClassName(): string;
  44273. /**
  44274. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44275. */
  44276. /**
  44277. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44278. */
  44279. useLogarithmicDepth: boolean;
  44280. /**
  44281. * Gets the current transparency mode.
  44282. */
  44283. /**
  44284. * Sets the transparency mode of the material.
  44285. *
  44286. * | Value | Type | Description |
  44287. * | ----- | ----------------------------------- | ----------- |
  44288. * | 0 | OPAQUE | |
  44289. * | 1 | ALPHATEST | |
  44290. * | 2 | ALPHABLEND | |
  44291. * | 3 | ALPHATESTANDBLEND | |
  44292. *
  44293. */
  44294. transparencyMode: Nullable<number>;
  44295. /**
  44296. * Returns true if alpha blending should be disabled.
  44297. */
  44298. private readonly _disableAlphaBlending;
  44299. /**
  44300. * Specifies whether or not this material should be rendered in alpha blend mode.
  44301. */
  44302. needAlphaBlending(): boolean;
  44303. /**
  44304. * Specifies if the mesh will require alpha blending.
  44305. * @param mesh - BJS mesh.
  44306. */
  44307. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44308. /**
  44309. * Specifies whether or not this material should be rendered in alpha test mode.
  44310. */
  44311. needAlphaTesting(): boolean;
  44312. /**
  44313. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44314. */
  44315. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44316. /**
  44317. * Gets the texture used for the alpha test.
  44318. */
  44319. getAlphaTestTexture(): BaseTexture;
  44320. /**
  44321. * Specifies that the submesh is ready to be used.
  44322. * @param mesh - BJS mesh.
  44323. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44324. * @param useInstances - Specifies that instances should be used.
  44325. * @returns - boolean indicating that the submesh is ready or not.
  44326. */
  44327. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44328. /**
  44329. * Specifies if the material uses metallic roughness workflow.
  44330. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44331. */
  44332. isMetallicWorkflow(): boolean;
  44333. private _prepareEffect;
  44334. private _prepareDefines;
  44335. /**
  44336. * Force shader compilation
  44337. */
  44338. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44339. clipPlane: boolean;
  44340. }>): void;
  44341. /**
  44342. * Initializes the uniform buffer layout for the shader.
  44343. */
  44344. buildUniformLayout(): void;
  44345. /**
  44346. * Unbinds the textures.
  44347. */
  44348. unbind(): void;
  44349. /**
  44350. * Binds the submesh data.
  44351. * @param world - The world matrix.
  44352. * @param mesh - The BJS mesh.
  44353. * @param subMesh - A submesh of the BJS mesh.
  44354. */
  44355. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44356. /**
  44357. * Returns the animatable textures.
  44358. * @returns - Array of animatable textures.
  44359. */
  44360. getAnimatables(): IAnimatable[];
  44361. /**
  44362. * Returns the texture used for reflections.
  44363. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44364. */
  44365. private _getReflectionTexture;
  44366. /**
  44367. * Returns the texture used for refraction or null if none is used.
  44368. * @returns - Refection texture if present. If no refraction texture and refraction
  44369. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44370. */
  44371. private _getRefractionTexture;
  44372. /**
  44373. * Disposes the resources of the material.
  44374. * @param forceDisposeEffect - Forces the disposal of effects.
  44375. * @param forceDisposeTextures - Forces the disposal of all textures.
  44376. */
  44377. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44378. }
  44379. }
  44380. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  44381. import { Nullable } from "babylonjs/types";
  44382. import { Scene } from "babylonjs/scene";
  44383. import { Color3 } from "babylonjs/Maths/math";
  44384. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44385. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44386. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44387. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  44388. /**
  44389. * The Physically based material of BJS.
  44390. *
  44391. * This offers the main features of a standard PBR material.
  44392. * For more information, please refer to the documentation :
  44393. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44394. */
  44395. export class PBRMaterial extends PBRBaseMaterial {
  44396. /**
  44397. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44398. */
  44399. static readonly PBRMATERIAL_OPAQUE: number;
  44400. /**
  44401. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44402. */
  44403. static readonly PBRMATERIAL_ALPHATEST: number;
  44404. /**
  44405. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44406. */
  44407. static readonly PBRMATERIAL_ALPHABLEND: number;
  44408. /**
  44409. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44410. * They are also discarded below the alpha cutoff threshold to improve performances.
  44411. */
  44412. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44413. /**
  44414. * Defines the default value of how much AO map is occluding the analytical lights
  44415. * (point spot...).
  44416. */
  44417. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44418. /**
  44419. * Intensity of the direct lights e.g. the four lights available in your scene.
  44420. * This impacts both the direct diffuse and specular highlights.
  44421. */
  44422. directIntensity: number;
  44423. /**
  44424. * Intensity of the emissive part of the material.
  44425. * This helps controlling the emissive effect without modifying the emissive color.
  44426. */
  44427. emissiveIntensity: number;
  44428. /**
  44429. * Intensity of the environment e.g. how much the environment will light the object
  44430. * either through harmonics for rough material or through the refelction for shiny ones.
  44431. */
  44432. environmentIntensity: number;
  44433. /**
  44434. * This is a special control allowing the reduction of the specular highlights coming from the
  44435. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44436. */
  44437. specularIntensity: number;
  44438. /**
  44439. * Debug Control allowing disabling the bump map on this material.
  44440. */
  44441. disableBumpMap: boolean;
  44442. /**
  44443. * AKA Diffuse Texture in standard nomenclature.
  44444. */
  44445. albedoTexture: BaseTexture;
  44446. /**
  44447. * AKA Occlusion Texture in other nomenclature.
  44448. */
  44449. ambientTexture: BaseTexture;
  44450. /**
  44451. * AKA Occlusion Texture Intensity in other nomenclature.
  44452. */
  44453. ambientTextureStrength: number;
  44454. /**
  44455. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44456. * 1 means it completely occludes it
  44457. * 0 mean it has no impact
  44458. */
  44459. ambientTextureImpactOnAnalyticalLights: number;
  44460. /**
  44461. * Stores the alpha values in a texture.
  44462. */
  44463. opacityTexture: BaseTexture;
  44464. /**
  44465. * Stores the reflection values in a texture.
  44466. */
  44467. reflectionTexture: Nullable<BaseTexture>;
  44468. /**
  44469. * Stores the emissive values in a texture.
  44470. */
  44471. emissiveTexture: BaseTexture;
  44472. /**
  44473. * AKA Specular texture in other nomenclature.
  44474. */
  44475. reflectivityTexture: BaseTexture;
  44476. /**
  44477. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44478. */
  44479. metallicTexture: BaseTexture;
  44480. /**
  44481. * Specifies the metallic scalar of the metallic/roughness workflow.
  44482. * Can also be used to scale the metalness values of the metallic texture.
  44483. */
  44484. metallic: Nullable<number>;
  44485. /**
  44486. * Specifies the roughness scalar of the metallic/roughness workflow.
  44487. * Can also be used to scale the roughness values of the metallic texture.
  44488. */
  44489. roughness: Nullable<number>;
  44490. /**
  44491. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44492. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44493. */
  44494. microSurfaceTexture: BaseTexture;
  44495. /**
  44496. * Stores surface normal data used to displace a mesh in a texture.
  44497. */
  44498. bumpTexture: BaseTexture;
  44499. /**
  44500. * Stores the pre-calculated light information of a mesh in a texture.
  44501. */
  44502. lightmapTexture: BaseTexture;
  44503. /**
  44504. * Stores the refracted light information in a texture.
  44505. */
  44506. refractionTexture: BaseTexture;
  44507. /**
  44508. * The color of a material in ambient lighting.
  44509. */
  44510. ambientColor: Color3;
  44511. /**
  44512. * AKA Diffuse Color in other nomenclature.
  44513. */
  44514. albedoColor: Color3;
  44515. /**
  44516. * AKA Specular Color in other nomenclature.
  44517. */
  44518. reflectivityColor: Color3;
  44519. /**
  44520. * The color reflected from the material.
  44521. */
  44522. reflectionColor: Color3;
  44523. /**
  44524. * The color emitted from the material.
  44525. */
  44526. emissiveColor: Color3;
  44527. /**
  44528. * AKA Glossiness in other nomenclature.
  44529. */
  44530. microSurface: number;
  44531. /**
  44532. * source material index of refraction (IOR)' / 'destination material IOR.
  44533. */
  44534. indexOfRefraction: number;
  44535. /**
  44536. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44537. */
  44538. invertRefractionY: boolean;
  44539. /**
  44540. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44541. * Materials half opaque for instance using refraction could benefit from this control.
  44542. */
  44543. linkRefractionWithTransparency: boolean;
  44544. /**
  44545. * If true, the light map contains occlusion information instead of lighting info.
  44546. */
  44547. useLightmapAsShadowmap: boolean;
  44548. /**
  44549. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44550. */
  44551. useAlphaFromAlbedoTexture: boolean;
  44552. /**
  44553. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44554. */
  44555. forceAlphaTest: boolean;
  44556. /**
  44557. * Defines the alpha limits in alpha test mode.
  44558. */
  44559. alphaCutOff: number;
  44560. /**
  44561. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44562. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44563. */
  44564. useSpecularOverAlpha: boolean;
  44565. /**
  44566. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44567. */
  44568. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44569. /**
  44570. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44571. */
  44572. useRoughnessFromMetallicTextureAlpha: boolean;
  44573. /**
  44574. * Specifies if the metallic texture contains the roughness information in its green channel.
  44575. */
  44576. useRoughnessFromMetallicTextureGreen: boolean;
  44577. /**
  44578. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44579. */
  44580. useMetallnessFromMetallicTextureBlue: boolean;
  44581. /**
  44582. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44583. */
  44584. useAmbientOcclusionFromMetallicTextureRed: boolean;
  44585. /**
  44586. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44587. */
  44588. useAmbientInGrayScale: boolean;
  44589. /**
  44590. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44591. * The material will try to infer what glossiness each pixel should be.
  44592. */
  44593. useAutoMicroSurfaceFromReflectivityMap: boolean;
  44594. /**
  44595. * BJS is using an harcoded light falloff based on a manually sets up range.
  44596. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44597. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44598. */
  44599. /**
  44600. * BJS is using an harcoded light falloff based on a manually sets up range.
  44601. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44602. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44603. */
  44604. usePhysicalLightFalloff: boolean;
  44605. /**
  44606. * In order to support the falloff compatibility with gltf, a special mode has been added
  44607. * to reproduce the gltf light falloff.
  44608. */
  44609. /**
  44610. * In order to support the falloff compatibility with gltf, a special mode has been added
  44611. * to reproduce the gltf light falloff.
  44612. */
  44613. useGLTFLightFalloff: boolean;
  44614. /**
  44615. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44616. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44617. */
  44618. useRadianceOverAlpha: boolean;
  44619. /**
  44620. * Allows using an object space normal map (instead of tangent space).
  44621. */
  44622. useObjectSpaceNormalMap: boolean;
  44623. /**
  44624. * Allows using the bump map in parallax mode.
  44625. */
  44626. useParallax: boolean;
  44627. /**
  44628. * Allows using the bump map in parallax occlusion mode.
  44629. */
  44630. useParallaxOcclusion: boolean;
  44631. /**
  44632. * Controls the scale bias of the parallax mode.
  44633. */
  44634. parallaxScaleBias: number;
  44635. /**
  44636. * If sets to true, disables all the lights affecting the material.
  44637. */
  44638. disableLighting: boolean;
  44639. /**
  44640. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44641. */
  44642. forceIrradianceInFragment: boolean;
  44643. /**
  44644. * Number of Simultaneous lights allowed on the material.
  44645. */
  44646. maxSimultaneousLights: number;
  44647. /**
  44648. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44649. */
  44650. invertNormalMapX: boolean;
  44651. /**
  44652. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44653. */
  44654. invertNormalMapY: boolean;
  44655. /**
  44656. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44657. */
  44658. twoSidedLighting: boolean;
  44659. /**
  44660. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44661. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44662. */
  44663. useAlphaFresnel: boolean;
  44664. /**
  44665. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44666. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44667. */
  44668. useLinearAlphaFresnel: boolean;
  44669. /**
  44670. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44671. * And/Or occlude the blended part.
  44672. */
  44673. environmentBRDFTexture: Nullable<BaseTexture>;
  44674. /**
  44675. * Force normal to face away from face.
  44676. */
  44677. forceNormalForward: boolean;
  44678. /**
  44679. * Enables specular anti aliasing in the PBR shader.
  44680. * It will both interacts on the Geometry for analytical and IBL lighting.
  44681. * It also prefilter the roughness map based on the bump values.
  44682. */
  44683. enableSpecularAntiAliasing: boolean;
  44684. /**
  44685. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44686. * makes the reflect vector face the model (under horizon).
  44687. */
  44688. useHorizonOcclusion: boolean;
  44689. /**
  44690. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44691. * too much the area relying on ambient texture to define their ambient occlusion.
  44692. */
  44693. useRadianceOcclusion: boolean;
  44694. /**
  44695. * If set to true, no lighting calculations will be applied.
  44696. */
  44697. unlit: boolean;
  44698. /**
  44699. * Gets the image processing configuration used either in this material.
  44700. */
  44701. /**
  44702. * Sets the Default image processing configuration used either in the this material.
  44703. *
  44704. * If sets to null, the scene one is in use.
  44705. */
  44706. imageProcessingConfiguration: ImageProcessingConfiguration;
  44707. /**
  44708. * Gets wether the color curves effect is enabled.
  44709. */
  44710. /**
  44711. * Sets wether the color curves effect is enabled.
  44712. */
  44713. cameraColorCurvesEnabled: boolean;
  44714. /**
  44715. * Gets wether the color grading effect is enabled.
  44716. */
  44717. /**
  44718. * Gets wether the color grading effect is enabled.
  44719. */
  44720. cameraColorGradingEnabled: boolean;
  44721. /**
  44722. * Gets wether tonemapping is enabled or not.
  44723. */
  44724. /**
  44725. * Sets wether tonemapping is enabled or not
  44726. */
  44727. cameraToneMappingEnabled: boolean;
  44728. /**
  44729. * The camera exposure used on this material.
  44730. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44731. * This corresponds to a photographic exposure.
  44732. */
  44733. /**
  44734. * The camera exposure used on this material.
  44735. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44736. * This corresponds to a photographic exposure.
  44737. */
  44738. cameraExposure: number;
  44739. /**
  44740. * Gets The camera contrast used on this material.
  44741. */
  44742. /**
  44743. * Sets The camera contrast used on this material.
  44744. */
  44745. cameraContrast: number;
  44746. /**
  44747. * Gets the Color Grading 2D Lookup Texture.
  44748. */
  44749. /**
  44750. * Sets the Color Grading 2D Lookup Texture.
  44751. */
  44752. cameraColorGradingTexture: Nullable<BaseTexture>;
  44753. /**
  44754. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44755. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44756. * 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;
  44757. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44758. */
  44759. /**
  44760. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44761. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44762. * 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;
  44763. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44764. */
  44765. cameraColorCurves: Nullable<ColorCurves>;
  44766. /**
  44767. * Instantiates a new PBRMaterial instance.
  44768. *
  44769. * @param name The material name
  44770. * @param scene The scene the material will be use in.
  44771. */
  44772. constructor(name: string, scene: Scene);
  44773. /**
  44774. * Returns the name of this material class.
  44775. */
  44776. getClassName(): string;
  44777. /**
  44778. * Returns an array of the actively used textures.
  44779. * @returns - Array of BaseTextures
  44780. */
  44781. getActiveTextures(): BaseTexture[];
  44782. /**
  44783. * Checks to see if a texture is used in the material.
  44784. * @param texture - Base texture to use.
  44785. * @returns - Boolean specifying if a texture is used in the material.
  44786. */
  44787. hasTexture(texture: BaseTexture): boolean;
  44788. /**
  44789. * Makes a duplicate of the current material.
  44790. * @param name - name to use for the new material.
  44791. */
  44792. clone(name: string): PBRMaterial;
  44793. /**
  44794. * Serializes this PBR Material.
  44795. * @returns - An object with the serialized material.
  44796. */
  44797. serialize(): any;
  44798. /**
  44799. * Parses a PBR Material from a serialized object.
  44800. * @param source - Serialized object.
  44801. * @param scene - BJS scene instance.
  44802. * @param rootUrl - url for the scene object
  44803. * @returns - PBRMaterial
  44804. */
  44805. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  44806. }
  44807. }
  44808. declare module "babylonjs/Helpers/sceneHelpers" {
  44809. import { Nullable } from "babylonjs/types";
  44810. import { Mesh } from "babylonjs/Meshes/mesh";
  44811. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44812. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  44813. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44814. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  44815. import "babylonjs/Meshes/Builders/boxBuilder";
  44816. /** @hidden */
  44817. export var _forceSceneHelpersToBundle: boolean;
  44818. module "babylonjs/scene" {
  44819. interface Scene {
  44820. /**
  44821. * Creates a default light for the scene.
  44822. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  44823. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  44824. */
  44825. createDefaultLight(replace?: boolean): void;
  44826. /**
  44827. * Creates a default camera for the scene.
  44828. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  44829. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  44830. * @param replace has default false, when true replaces the active camera in the scene
  44831. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  44832. */
  44833. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  44834. /**
  44835. * Creates a default camera and a default light.
  44836. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  44837. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  44838. * @param replace has the default false, when true replaces the active camera/light in the scene
  44839. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  44840. */
  44841. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  44842. /**
  44843. * Creates a new sky box
  44844. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  44845. * @param environmentTexture defines the texture to use as environment texture
  44846. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  44847. * @param scale defines the overall scale of the skybox
  44848. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  44849. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  44850. * @returns a new mesh holding the sky box
  44851. */
  44852. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  44853. /**
  44854. * Creates a new environment
  44855. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  44856. * @param options defines the options you can use to configure the environment
  44857. * @returns the new EnvironmentHelper
  44858. */
  44859. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  44860. /**
  44861. * Creates a new VREXperienceHelper
  44862. * @see http://doc.babylonjs.com/how_to/webvr_helper
  44863. * @param webVROptions defines the options used to create the new VREXperienceHelper
  44864. * @returns a new VREXperienceHelper
  44865. */
  44866. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  44867. /**
  44868. * Creates a new XREXperienceHelper
  44869. * @see http://doc.babylonjs.com/how_to/webxr
  44870. * @returns a promise for a new XREXperienceHelper
  44871. */
  44872. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  44873. }
  44874. }
  44875. }
  44876. declare module "babylonjs/Helpers/videoDome" {
  44877. import { Scene } from "babylonjs/scene";
  44878. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44879. import { Mesh } from "babylonjs/Meshes/mesh";
  44880. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  44881. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44882. import "babylonjs/Meshes/Builders/sphereBuilder";
  44883. /**
  44884. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  44885. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  44886. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  44887. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44888. */
  44889. export class VideoDome extends TransformNode {
  44890. private _useDirectMapping;
  44891. /**
  44892. * The video texture being displayed on the sphere
  44893. */
  44894. protected _videoTexture: VideoTexture;
  44895. /**
  44896. * Gets the video texture being displayed on the sphere
  44897. */
  44898. readonly videoTexture: VideoTexture;
  44899. /**
  44900. * The skybox material
  44901. */
  44902. protected _material: BackgroundMaterial;
  44903. /**
  44904. * The surface used for the skybox
  44905. */
  44906. protected _mesh: Mesh;
  44907. /**
  44908. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44909. * Also see the options.resolution property.
  44910. */
  44911. fovMultiplier: number;
  44912. /**
  44913. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  44914. * @param name Element's name, child elements will append suffixes for their own names.
  44915. * @param urlsOrVideo defines the url(s) or the video element to use
  44916. * @param options An object containing optional or exposed sub element properties
  44917. */
  44918. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  44919. resolution?: number;
  44920. clickToPlay?: boolean;
  44921. autoPlay?: boolean;
  44922. loop?: boolean;
  44923. size?: number;
  44924. poster?: string;
  44925. useDirectMapping?: boolean;
  44926. }, scene: Scene);
  44927. /**
  44928. * Releases resources associated with this node.
  44929. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44930. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44931. */
  44932. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44933. }
  44934. }
  44935. declare module "babylonjs/Helpers/index" {
  44936. export * from "babylonjs/Helpers/environmentHelper";
  44937. export * from "babylonjs/Helpers/photoDome";
  44938. export * from "babylonjs/Helpers/sceneHelpers";
  44939. export * from "babylonjs/Helpers/videoDome";
  44940. }
  44941. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  44942. import { PerfCounter } from "babylonjs/Misc/tools";
  44943. import { IDisposable } from "babylonjs/scene";
  44944. import { Engine } from "babylonjs/Engines/engine";
  44945. /**
  44946. * This class can be used to get instrumentation data from a Babylon engine
  44947. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  44948. */
  44949. export class EngineInstrumentation implements IDisposable {
  44950. /**
  44951. * Define the instrumented engine.
  44952. */
  44953. engine: Engine;
  44954. private _captureGPUFrameTime;
  44955. private _gpuFrameTimeToken;
  44956. private _gpuFrameTime;
  44957. private _captureShaderCompilationTime;
  44958. private _shaderCompilationTime;
  44959. private _onBeginFrameObserver;
  44960. private _onEndFrameObserver;
  44961. private _onBeforeShaderCompilationObserver;
  44962. private _onAfterShaderCompilationObserver;
  44963. /**
  44964. * Gets the perf counter used for GPU frame time
  44965. */
  44966. readonly gpuFrameTimeCounter: PerfCounter;
  44967. /**
  44968. * Gets the GPU frame time capture status
  44969. */
  44970. /**
  44971. * Enable or disable the GPU frame time capture
  44972. */
  44973. captureGPUFrameTime: boolean;
  44974. /**
  44975. * Gets the perf counter used for shader compilation time
  44976. */
  44977. readonly shaderCompilationTimeCounter: PerfCounter;
  44978. /**
  44979. * Gets the shader compilation time capture status
  44980. */
  44981. /**
  44982. * Enable or disable the shader compilation time capture
  44983. */
  44984. captureShaderCompilationTime: boolean;
  44985. /**
  44986. * Instantiates a new engine instrumentation.
  44987. * This class can be used to get instrumentation data from a Babylon engine
  44988. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  44989. * @param engine Defines the engine to instrument
  44990. */
  44991. constructor(
  44992. /**
  44993. * Define the instrumented engine.
  44994. */
  44995. engine: Engine);
  44996. /**
  44997. * Dispose and release associated resources.
  44998. */
  44999. dispose(): void;
  45000. }
  45001. }
  45002. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  45003. import { PerfCounter } from "babylonjs/Misc/tools";
  45004. import { Scene, IDisposable } from "babylonjs/scene";
  45005. /**
  45006. * This class can be used to get instrumentation data from a Babylon engine
  45007. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45008. */
  45009. export class SceneInstrumentation implements IDisposable {
  45010. /**
  45011. * Defines the scene to instrument
  45012. */
  45013. scene: Scene;
  45014. private _captureActiveMeshesEvaluationTime;
  45015. private _activeMeshesEvaluationTime;
  45016. private _captureRenderTargetsRenderTime;
  45017. private _renderTargetsRenderTime;
  45018. private _captureFrameTime;
  45019. private _frameTime;
  45020. private _captureRenderTime;
  45021. private _renderTime;
  45022. private _captureInterFrameTime;
  45023. private _interFrameTime;
  45024. private _captureParticlesRenderTime;
  45025. private _particlesRenderTime;
  45026. private _captureSpritesRenderTime;
  45027. private _spritesRenderTime;
  45028. private _capturePhysicsTime;
  45029. private _physicsTime;
  45030. private _captureAnimationsTime;
  45031. private _animationsTime;
  45032. private _captureCameraRenderTime;
  45033. private _cameraRenderTime;
  45034. private _onBeforeActiveMeshesEvaluationObserver;
  45035. private _onAfterActiveMeshesEvaluationObserver;
  45036. private _onBeforeRenderTargetsRenderObserver;
  45037. private _onAfterRenderTargetsRenderObserver;
  45038. private _onAfterRenderObserver;
  45039. private _onBeforeDrawPhaseObserver;
  45040. private _onAfterDrawPhaseObserver;
  45041. private _onBeforeAnimationsObserver;
  45042. private _onBeforeParticlesRenderingObserver;
  45043. private _onAfterParticlesRenderingObserver;
  45044. private _onBeforeSpritesRenderingObserver;
  45045. private _onAfterSpritesRenderingObserver;
  45046. private _onBeforePhysicsObserver;
  45047. private _onAfterPhysicsObserver;
  45048. private _onAfterAnimationsObserver;
  45049. private _onBeforeCameraRenderObserver;
  45050. private _onAfterCameraRenderObserver;
  45051. /**
  45052. * Gets the perf counter used for active meshes evaluation time
  45053. */
  45054. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45055. /**
  45056. * Gets the active meshes evaluation time capture status
  45057. */
  45058. /**
  45059. * Enable or disable the active meshes evaluation time capture
  45060. */
  45061. captureActiveMeshesEvaluationTime: boolean;
  45062. /**
  45063. * Gets the perf counter used for render targets render time
  45064. */
  45065. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45066. /**
  45067. * Gets the render targets render time capture status
  45068. */
  45069. /**
  45070. * Enable or disable the render targets render time capture
  45071. */
  45072. captureRenderTargetsRenderTime: boolean;
  45073. /**
  45074. * Gets the perf counter used for particles render time
  45075. */
  45076. readonly particlesRenderTimeCounter: PerfCounter;
  45077. /**
  45078. * Gets the particles render time capture status
  45079. */
  45080. /**
  45081. * Enable or disable the particles render time capture
  45082. */
  45083. captureParticlesRenderTime: boolean;
  45084. /**
  45085. * Gets the perf counter used for sprites render time
  45086. */
  45087. readonly spritesRenderTimeCounter: PerfCounter;
  45088. /**
  45089. * Gets the sprites render time capture status
  45090. */
  45091. /**
  45092. * Enable or disable the sprites render time capture
  45093. */
  45094. captureSpritesRenderTime: boolean;
  45095. /**
  45096. * Gets the perf counter used for physics time
  45097. */
  45098. readonly physicsTimeCounter: PerfCounter;
  45099. /**
  45100. * Gets the physics time capture status
  45101. */
  45102. /**
  45103. * Enable or disable the physics time capture
  45104. */
  45105. capturePhysicsTime: boolean;
  45106. /**
  45107. * Gets the perf counter used for animations time
  45108. */
  45109. readonly animationsTimeCounter: PerfCounter;
  45110. /**
  45111. * Gets the animations time capture status
  45112. */
  45113. /**
  45114. * Enable or disable the animations time capture
  45115. */
  45116. captureAnimationsTime: boolean;
  45117. /**
  45118. * Gets the perf counter used for frame time capture
  45119. */
  45120. readonly frameTimeCounter: PerfCounter;
  45121. /**
  45122. * Gets the frame time capture status
  45123. */
  45124. /**
  45125. * Enable or disable the frame time capture
  45126. */
  45127. captureFrameTime: boolean;
  45128. /**
  45129. * Gets the perf counter used for inter-frames time capture
  45130. */
  45131. readonly interFrameTimeCounter: PerfCounter;
  45132. /**
  45133. * Gets the inter-frames time capture status
  45134. */
  45135. /**
  45136. * Enable or disable the inter-frames time capture
  45137. */
  45138. captureInterFrameTime: boolean;
  45139. /**
  45140. * Gets the perf counter used for render time capture
  45141. */
  45142. readonly renderTimeCounter: PerfCounter;
  45143. /**
  45144. * Gets the render time capture status
  45145. */
  45146. /**
  45147. * Enable or disable the render time capture
  45148. */
  45149. captureRenderTime: boolean;
  45150. /**
  45151. * Gets the perf counter used for camera render time capture
  45152. */
  45153. readonly cameraRenderTimeCounter: PerfCounter;
  45154. /**
  45155. * Gets the camera render time capture status
  45156. */
  45157. /**
  45158. * Enable or disable the camera render time capture
  45159. */
  45160. captureCameraRenderTime: boolean;
  45161. /**
  45162. * Gets the perf counter used for draw calls
  45163. */
  45164. readonly drawCallsCounter: PerfCounter;
  45165. /**
  45166. * Gets the perf counter used for texture collisions
  45167. */
  45168. readonly textureCollisionsCounter: PerfCounter;
  45169. /**
  45170. * Instantiates a new scene instrumentation.
  45171. * This class can be used to get instrumentation data from a Babylon engine
  45172. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45173. * @param scene Defines the scene to instrument
  45174. */
  45175. constructor(
  45176. /**
  45177. * Defines the scene to instrument
  45178. */
  45179. scene: Scene);
  45180. /**
  45181. * Dispose and release associated resources.
  45182. */
  45183. dispose(): void;
  45184. }
  45185. }
  45186. declare module "babylonjs/Instrumentation/index" {
  45187. export * from "babylonjs/Instrumentation/engineInstrumentation";
  45188. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  45189. export * from "babylonjs/Instrumentation/timeToken";
  45190. }
  45191. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  45192. /** @hidden */
  45193. export var glowMapGenerationPixelShader: {
  45194. name: string;
  45195. shader: string;
  45196. };
  45197. }
  45198. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  45199. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45200. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45201. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45202. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45203. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45204. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45205. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45206. /** @hidden */
  45207. export var glowMapGenerationVertexShader: {
  45208. name: string;
  45209. shader: string;
  45210. };
  45211. }
  45212. declare module "babylonjs/Layers/effectLayer" {
  45213. import { Observable } from "babylonjs/Misc/observable";
  45214. import { Nullable } from "babylonjs/types";
  45215. import { Camera } from "babylonjs/Cameras/camera";
  45216. import { Scene } from "babylonjs/scene";
  45217. import { Color4, ISize } from "babylonjs/Maths/math";
  45218. import { Engine } from "babylonjs/Engines/engine";
  45219. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45221. import { Mesh } from "babylonjs/Meshes/mesh";
  45222. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  45223. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45224. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45225. import { Effect } from "babylonjs/Materials/effect";
  45226. import { Material } from "babylonjs/Materials/material";
  45227. import "babylonjs/Shaders/glowMapGeneration.fragment";
  45228. import "babylonjs/Shaders/glowMapGeneration.vertex";
  45229. /**
  45230. * Effect layer options. This helps customizing the behaviour
  45231. * of the effect layer.
  45232. */
  45233. export interface IEffectLayerOptions {
  45234. /**
  45235. * Multiplication factor apply to the canvas size to compute the render target size
  45236. * used to generated the objects (the smaller the faster).
  45237. */
  45238. mainTextureRatio: number;
  45239. /**
  45240. * Enforces a fixed size texture to ensure effect stability across devices.
  45241. */
  45242. mainTextureFixedSize?: number;
  45243. /**
  45244. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  45245. */
  45246. alphaBlendingMode: number;
  45247. /**
  45248. * The camera attached to the layer.
  45249. */
  45250. camera: Nullable<Camera>;
  45251. /**
  45252. * The rendering group to draw the layer in.
  45253. */
  45254. renderingGroupId: number;
  45255. }
  45256. /**
  45257. * The effect layer Helps adding post process effect blended with the main pass.
  45258. *
  45259. * This can be for instance use to generate glow or higlight effects on the scene.
  45260. *
  45261. * The effect layer class can not be used directly and is intented to inherited from to be
  45262. * customized per effects.
  45263. */
  45264. export abstract class EffectLayer {
  45265. private _vertexBuffers;
  45266. private _indexBuffer;
  45267. private _cachedDefines;
  45268. private _effectLayerMapGenerationEffect;
  45269. private _effectLayerOptions;
  45270. private _mergeEffect;
  45271. protected _scene: Scene;
  45272. protected _engine: Engine;
  45273. protected _maxSize: number;
  45274. protected _mainTextureDesiredSize: ISize;
  45275. protected _mainTexture: RenderTargetTexture;
  45276. protected _shouldRender: boolean;
  45277. protected _postProcesses: PostProcess[];
  45278. protected _textures: BaseTexture[];
  45279. protected _emissiveTextureAndColor: {
  45280. texture: Nullable<BaseTexture>;
  45281. color: Color4;
  45282. };
  45283. /**
  45284. * The name of the layer
  45285. */
  45286. name: string;
  45287. /**
  45288. * The clear color of the texture used to generate the glow map.
  45289. */
  45290. neutralColor: Color4;
  45291. /**
  45292. * Specifies wether the highlight layer is enabled or not.
  45293. */
  45294. isEnabled: boolean;
  45295. /**
  45296. * Gets the camera attached to the layer.
  45297. */
  45298. readonly camera: Nullable<Camera>;
  45299. /**
  45300. * Gets the rendering group id the layer should render in.
  45301. */
  45302. readonly renderingGroupId: number;
  45303. /**
  45304. * An event triggered when the effect layer has been disposed.
  45305. */
  45306. onDisposeObservable: Observable<EffectLayer>;
  45307. /**
  45308. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  45309. */
  45310. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  45311. /**
  45312. * An event triggered when the generated texture is being merged in the scene.
  45313. */
  45314. onBeforeComposeObservable: Observable<EffectLayer>;
  45315. /**
  45316. * An event triggered when the generated texture has been merged in the scene.
  45317. */
  45318. onAfterComposeObservable: Observable<EffectLayer>;
  45319. /**
  45320. * An event triggered when the efffect layer changes its size.
  45321. */
  45322. onSizeChangedObservable: Observable<EffectLayer>;
  45323. /** @hidden */
  45324. static _SceneComponentInitialization: (scene: Scene) => void;
  45325. /**
  45326. * Instantiates a new effect Layer and references it in the scene.
  45327. * @param name The name of the layer
  45328. * @param scene The scene to use the layer in
  45329. */
  45330. constructor(
  45331. /** The Friendly of the effect in the scene */
  45332. name: string, scene: Scene);
  45333. /**
  45334. * Get the effect name of the layer.
  45335. * @return The effect name
  45336. */
  45337. abstract getEffectName(): string;
  45338. /**
  45339. * Checks for the readiness of the element composing the layer.
  45340. * @param subMesh the mesh to check for
  45341. * @param useInstances specify wether or not to use instances to render the mesh
  45342. * @return true if ready otherwise, false
  45343. */
  45344. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45345. /**
  45346. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45347. * @returns true if the effect requires stencil during the main canvas render pass.
  45348. */
  45349. abstract needStencil(): boolean;
  45350. /**
  45351. * Create the merge effect. This is the shader use to blit the information back
  45352. * to the main canvas at the end of the scene rendering.
  45353. * @returns The effect containing the shader used to merge the effect on the main canvas
  45354. */
  45355. protected abstract _createMergeEffect(): Effect;
  45356. /**
  45357. * Creates the render target textures and post processes used in the effect layer.
  45358. */
  45359. protected abstract _createTextureAndPostProcesses(): void;
  45360. /**
  45361. * Implementation specific of rendering the generating effect on the main canvas.
  45362. * @param effect The effect used to render through
  45363. */
  45364. protected abstract _internalRender(effect: Effect): void;
  45365. /**
  45366. * Sets the required values for both the emissive texture and and the main color.
  45367. */
  45368. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45369. /**
  45370. * Free any resources and references associated to a mesh.
  45371. * Internal use
  45372. * @param mesh The mesh to free.
  45373. */
  45374. abstract _disposeMesh(mesh: Mesh): void;
  45375. /**
  45376. * Serializes this layer (Glow or Highlight for example)
  45377. * @returns a serialized layer object
  45378. */
  45379. abstract serialize?(): any;
  45380. /**
  45381. * Initializes the effect layer with the required options.
  45382. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  45383. */
  45384. protected _init(options: Partial<IEffectLayerOptions>): void;
  45385. /**
  45386. * Generates the index buffer of the full screen quad blending to the main canvas.
  45387. */
  45388. private _generateIndexBuffer;
  45389. /**
  45390. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  45391. */
  45392. private _genrateVertexBuffer;
  45393. /**
  45394. * Sets the main texture desired size which is the closest power of two
  45395. * of the engine canvas size.
  45396. */
  45397. private _setMainTextureSize;
  45398. /**
  45399. * Creates the main texture for the effect layer.
  45400. */
  45401. protected _createMainTexture(): void;
  45402. /**
  45403. * Adds specific effects defines.
  45404. * @param defines The defines to add specifics to.
  45405. */
  45406. protected _addCustomEffectDefines(defines: string[]): void;
  45407. /**
  45408. * Checks for the readiness of the element composing the layer.
  45409. * @param subMesh the mesh to check for
  45410. * @param useInstances specify wether or not to use instances to render the mesh
  45411. * @param emissiveTexture the associated emissive texture used to generate the glow
  45412. * @return true if ready otherwise, false
  45413. */
  45414. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  45415. /**
  45416. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  45417. */
  45418. render(): void;
  45419. /**
  45420. * Determine if a given mesh will be used in the current effect.
  45421. * @param mesh mesh to test
  45422. * @returns true if the mesh will be used
  45423. */
  45424. hasMesh(mesh: AbstractMesh): boolean;
  45425. /**
  45426. * Returns true if the layer contains information to display, otherwise false.
  45427. * @returns true if the glow layer should be rendered
  45428. */
  45429. shouldRender(): boolean;
  45430. /**
  45431. * Returns true if the mesh should render, otherwise false.
  45432. * @param mesh The mesh to render
  45433. * @returns true if it should render otherwise false
  45434. */
  45435. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  45436. /**
  45437. * Returns true if the mesh can be rendered, otherwise false.
  45438. * @param mesh The mesh to render
  45439. * @param material The material used on the mesh
  45440. * @returns true if it can be rendered otherwise false
  45441. */
  45442. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  45443. /**
  45444. * Returns true if the mesh should render, otherwise false.
  45445. * @param mesh The mesh to render
  45446. * @returns true if it should render otherwise false
  45447. */
  45448. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  45449. /**
  45450. * Renders the submesh passed in parameter to the generation map.
  45451. */
  45452. protected _renderSubMesh(subMesh: SubMesh): void;
  45453. /**
  45454. * Rebuild the required buffers.
  45455. * @hidden Internal use only.
  45456. */
  45457. _rebuild(): void;
  45458. /**
  45459. * Dispose only the render target textures and post process.
  45460. */
  45461. private _disposeTextureAndPostProcesses;
  45462. /**
  45463. * Dispose the highlight layer and free resources.
  45464. */
  45465. dispose(): void;
  45466. /**
  45467. * Gets the class name of the effect layer
  45468. * @returns the string with the class name of the effect layer
  45469. */
  45470. getClassName(): string;
  45471. /**
  45472. * Creates an effect layer from parsed effect layer data
  45473. * @param parsedEffectLayer defines effect layer data
  45474. * @param scene defines the current scene
  45475. * @param rootUrl defines the root URL containing the effect layer information
  45476. * @returns a parsed effect Layer
  45477. */
  45478. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  45479. }
  45480. }
  45481. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  45482. import { Scene } from "babylonjs/scene";
  45483. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  45484. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45485. import { AbstractScene } from "babylonjs/abstractScene";
  45486. module "babylonjs/abstractScene" {
  45487. interface AbstractScene {
  45488. /**
  45489. * The list of effect layers (highlights/glow) added to the scene
  45490. * @see http://doc.babylonjs.com/how_to/highlight_layer
  45491. * @see http://doc.babylonjs.com/how_to/glow_layer
  45492. */
  45493. effectLayers: Array<EffectLayer>;
  45494. /**
  45495. * Removes the given effect layer from this scene.
  45496. * @param toRemove defines the effect layer to remove
  45497. * @returns the index of the removed effect layer
  45498. */
  45499. removeEffectLayer(toRemove: EffectLayer): number;
  45500. /**
  45501. * Adds the given effect layer to this scene
  45502. * @param newEffectLayer defines the effect layer to add
  45503. */
  45504. addEffectLayer(newEffectLayer: EffectLayer): void;
  45505. }
  45506. }
  45507. /**
  45508. * Defines the layer scene component responsible to manage any effect layers
  45509. * in a given scene.
  45510. */
  45511. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  45512. /**
  45513. * The component name helpfull to identify the component in the list of scene components.
  45514. */
  45515. readonly name: string;
  45516. /**
  45517. * The scene the component belongs to.
  45518. */
  45519. scene: Scene;
  45520. private _engine;
  45521. private _renderEffects;
  45522. private _needStencil;
  45523. private _previousStencilState;
  45524. /**
  45525. * Creates a new instance of the component for the given scene
  45526. * @param scene Defines the scene to register the component in
  45527. */
  45528. constructor(scene: Scene);
  45529. /**
  45530. * Registers the component in a given scene
  45531. */
  45532. register(): void;
  45533. /**
  45534. * Rebuilds the elements related to this component in case of
  45535. * context lost for instance.
  45536. */
  45537. rebuild(): void;
  45538. /**
  45539. * Serializes the component data to the specified json object
  45540. * @param serializationObject The object to serialize to
  45541. */
  45542. serialize(serializationObject: any): void;
  45543. /**
  45544. * Adds all the element from the container to the scene
  45545. * @param container the container holding the elements
  45546. */
  45547. addFromContainer(container: AbstractScene): void;
  45548. /**
  45549. * Removes all the elements in the container from the scene
  45550. * @param container contains the elements to remove
  45551. */
  45552. removeFromContainer(container: AbstractScene): void;
  45553. /**
  45554. * Disposes the component and the associated ressources.
  45555. */
  45556. dispose(): void;
  45557. private _isReadyForMesh;
  45558. private _renderMainTexture;
  45559. private _setStencil;
  45560. private _setStencilBack;
  45561. private _draw;
  45562. private _drawCamera;
  45563. private _drawRenderingGroup;
  45564. }
  45565. }
  45566. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  45567. /** @hidden */
  45568. export var glowMapMergePixelShader: {
  45569. name: string;
  45570. shader: string;
  45571. };
  45572. }
  45573. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  45574. /** @hidden */
  45575. export var glowMapMergeVertexShader: {
  45576. name: string;
  45577. shader: string;
  45578. };
  45579. }
  45580. declare module "babylonjs/Layers/glowLayer" {
  45581. import { Nullable } from "babylonjs/types";
  45582. import { Camera } from "babylonjs/Cameras/camera";
  45583. import { Scene } from "babylonjs/scene";
  45584. import { Color4 } from "babylonjs/Maths/math";
  45585. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45587. import { Mesh } from "babylonjs/Meshes/mesh";
  45588. import { Texture } from "babylonjs/Materials/Textures/texture";
  45589. import { Effect } from "babylonjs/Materials/effect";
  45590. import { Material } from "babylonjs/Materials/material";
  45591. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45592. import "babylonjs/Shaders/glowMapMerge.fragment";
  45593. import "babylonjs/Shaders/glowMapMerge.vertex";
  45594. module "babylonjs/abstractScene" {
  45595. interface AbstractScene {
  45596. /**
  45597. * Return a the first highlight layer of the scene with a given name.
  45598. * @param name The name of the highlight layer to look for.
  45599. * @return The highlight layer if found otherwise null.
  45600. */
  45601. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  45602. }
  45603. }
  45604. /**
  45605. * Glow layer options. This helps customizing the behaviour
  45606. * of the glow layer.
  45607. */
  45608. export interface IGlowLayerOptions {
  45609. /**
  45610. * Multiplication factor apply to the canvas size to compute the render target size
  45611. * used to generated the glowing objects (the smaller the faster).
  45612. */
  45613. mainTextureRatio: number;
  45614. /**
  45615. * Enforces a fixed size texture to ensure resize independant blur.
  45616. */
  45617. mainTextureFixedSize?: number;
  45618. /**
  45619. * How big is the kernel of the blur texture.
  45620. */
  45621. blurKernelSize: number;
  45622. /**
  45623. * The camera attached to the layer.
  45624. */
  45625. camera: Nullable<Camera>;
  45626. /**
  45627. * Enable MSAA by chosing the number of samples.
  45628. */
  45629. mainTextureSamples?: number;
  45630. /**
  45631. * The rendering group to draw the layer in.
  45632. */
  45633. renderingGroupId: number;
  45634. }
  45635. /**
  45636. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  45637. *
  45638. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  45639. * glowy meshes to your scene.
  45640. *
  45641. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  45642. */
  45643. export class GlowLayer extends EffectLayer {
  45644. /**
  45645. * Effect Name of the layer.
  45646. */
  45647. static readonly EffectName: string;
  45648. /**
  45649. * The default blur kernel size used for the glow.
  45650. */
  45651. static DefaultBlurKernelSize: number;
  45652. /**
  45653. * The default texture size ratio used for the glow.
  45654. */
  45655. static DefaultTextureRatio: number;
  45656. /**
  45657. * Sets the kernel size of the blur.
  45658. */
  45659. /**
  45660. * Gets the kernel size of the blur.
  45661. */
  45662. blurKernelSize: number;
  45663. /**
  45664. * Sets the glow intensity.
  45665. */
  45666. /**
  45667. * Gets the glow intensity.
  45668. */
  45669. intensity: number;
  45670. private _options;
  45671. private _intensity;
  45672. private _horizontalBlurPostprocess1;
  45673. private _verticalBlurPostprocess1;
  45674. private _horizontalBlurPostprocess2;
  45675. private _verticalBlurPostprocess2;
  45676. private _blurTexture1;
  45677. private _blurTexture2;
  45678. private _postProcesses1;
  45679. private _postProcesses2;
  45680. private _includedOnlyMeshes;
  45681. private _excludedMeshes;
  45682. /**
  45683. * Callback used to let the user override the color selection on a per mesh basis
  45684. */
  45685. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  45686. /**
  45687. * Callback used to let the user override the texture selection on a per mesh basis
  45688. */
  45689. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  45690. /**
  45691. * Instantiates a new glow Layer and references it to the scene.
  45692. * @param name The name of the layer
  45693. * @param scene The scene to use the layer in
  45694. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  45695. */
  45696. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  45697. /**
  45698. * Get the effect name of the layer.
  45699. * @return The effect name
  45700. */
  45701. getEffectName(): string;
  45702. /**
  45703. * Create the merge effect. This is the shader use to blit the information back
  45704. * to the main canvas at the end of the scene rendering.
  45705. */
  45706. protected _createMergeEffect(): Effect;
  45707. /**
  45708. * Creates the render target textures and post processes used in the glow layer.
  45709. */
  45710. protected _createTextureAndPostProcesses(): void;
  45711. /**
  45712. * Checks for the readiness of the element composing the layer.
  45713. * @param subMesh the mesh to check for
  45714. * @param useInstances specify wether or not to use instances to render the mesh
  45715. * @param emissiveTexture the associated emissive texture used to generate the glow
  45716. * @return true if ready otherwise, false
  45717. */
  45718. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45719. /**
  45720. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45721. */
  45722. needStencil(): boolean;
  45723. /**
  45724. * Returns true if the mesh can be rendered, otherwise false.
  45725. * @param mesh The mesh to render
  45726. * @param material The material used on the mesh
  45727. * @returns true if it can be rendered otherwise false
  45728. */
  45729. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  45730. /**
  45731. * Implementation specific of rendering the generating effect on the main canvas.
  45732. * @param effect The effect used to render through
  45733. */
  45734. protected _internalRender(effect: Effect): void;
  45735. /**
  45736. * Sets the required values for both the emissive texture and and the main color.
  45737. */
  45738. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45739. /**
  45740. * Returns true if the mesh should render, otherwise false.
  45741. * @param mesh The mesh to render
  45742. * @returns true if it should render otherwise false
  45743. */
  45744. protected _shouldRenderMesh(mesh: Mesh): boolean;
  45745. /**
  45746. * Adds specific effects defines.
  45747. * @param defines The defines to add specifics to.
  45748. */
  45749. protected _addCustomEffectDefines(defines: string[]): void;
  45750. /**
  45751. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  45752. * @param mesh The mesh to exclude from the glow layer
  45753. */
  45754. addExcludedMesh(mesh: Mesh): void;
  45755. /**
  45756. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  45757. * @param mesh The mesh to remove
  45758. */
  45759. removeExcludedMesh(mesh: Mesh): void;
  45760. /**
  45761. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  45762. * @param mesh The mesh to include in the glow layer
  45763. */
  45764. addIncludedOnlyMesh(mesh: Mesh): void;
  45765. /**
  45766. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  45767. * @param mesh The mesh to remove
  45768. */
  45769. removeIncludedOnlyMesh(mesh: Mesh): void;
  45770. /**
  45771. * Determine if a given mesh will be used in the glow layer
  45772. * @param mesh The mesh to test
  45773. * @returns true if the mesh will be highlighted by the current glow layer
  45774. */
  45775. hasMesh(mesh: AbstractMesh): boolean;
  45776. /**
  45777. * Free any resources and references associated to a mesh.
  45778. * Internal use
  45779. * @param mesh The mesh to free.
  45780. * @hidden
  45781. */
  45782. _disposeMesh(mesh: Mesh): void;
  45783. /**
  45784. * Gets the class name of the effect layer
  45785. * @returns the string with the class name of the effect layer
  45786. */
  45787. getClassName(): string;
  45788. /**
  45789. * Serializes this glow layer
  45790. * @returns a serialized glow layer object
  45791. */
  45792. serialize(): any;
  45793. /**
  45794. * Creates a Glow Layer from parsed glow layer data
  45795. * @param parsedGlowLayer defines glow layer data
  45796. * @param scene defines the current scene
  45797. * @param rootUrl defines the root URL containing the glow layer information
  45798. * @returns a parsed Glow Layer
  45799. */
  45800. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  45801. }
  45802. }
  45803. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  45804. /** @hidden */
  45805. export var glowBlurPostProcessPixelShader: {
  45806. name: string;
  45807. shader: string;
  45808. };
  45809. }
  45810. declare module "babylonjs/Layers/highlightLayer" {
  45811. import { Observable } from "babylonjs/Misc/observable";
  45812. import { Nullable } from "babylonjs/types";
  45813. import { Camera } from "babylonjs/Cameras/camera";
  45814. import { Scene } from "babylonjs/scene";
  45815. import { Color3, Color4 } from "babylonjs/Maths/math";
  45816. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45817. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45818. import { Mesh } from "babylonjs/Meshes/mesh";
  45819. import { Effect } from "babylonjs/Materials/effect";
  45820. import { Material } from "babylonjs/Materials/material";
  45821. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45822. import "babylonjs/Shaders/glowMapMerge.fragment";
  45823. import "babylonjs/Shaders/glowMapMerge.vertex";
  45824. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  45825. module "babylonjs/abstractScene" {
  45826. interface AbstractScene {
  45827. /**
  45828. * Return a the first highlight layer of the scene with a given name.
  45829. * @param name The name of the highlight layer to look for.
  45830. * @return The highlight layer if found otherwise null.
  45831. */
  45832. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  45833. }
  45834. }
  45835. /**
  45836. * Highlight layer options. This helps customizing the behaviour
  45837. * of the highlight layer.
  45838. */
  45839. export interface IHighlightLayerOptions {
  45840. /**
  45841. * Multiplication factor apply to the canvas size to compute the render target size
  45842. * used to generated the glowing objects (the smaller the faster).
  45843. */
  45844. mainTextureRatio: number;
  45845. /**
  45846. * Enforces a fixed size texture to ensure resize independant blur.
  45847. */
  45848. mainTextureFixedSize?: number;
  45849. /**
  45850. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  45851. * of the picture to blur (the smaller the faster).
  45852. */
  45853. blurTextureSizeRatio: number;
  45854. /**
  45855. * How big in texel of the blur texture is the vertical blur.
  45856. */
  45857. blurVerticalSize: number;
  45858. /**
  45859. * How big in texel of the blur texture is the horizontal blur.
  45860. */
  45861. blurHorizontalSize: number;
  45862. /**
  45863. * Alpha blending mode used to apply the blur. Default is combine.
  45864. */
  45865. alphaBlendingMode: number;
  45866. /**
  45867. * The camera attached to the layer.
  45868. */
  45869. camera: Nullable<Camera>;
  45870. /**
  45871. * Should we display highlight as a solid stroke?
  45872. */
  45873. isStroke?: boolean;
  45874. /**
  45875. * The rendering group to draw the layer in.
  45876. */
  45877. renderingGroupId: number;
  45878. }
  45879. /**
  45880. * The highlight layer Helps adding a glow effect around a mesh.
  45881. *
  45882. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  45883. * glowy meshes to your scene.
  45884. *
  45885. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  45886. */
  45887. export class HighlightLayer extends EffectLayer {
  45888. name: string;
  45889. /**
  45890. * Effect Name of the highlight layer.
  45891. */
  45892. static readonly EffectName: string;
  45893. /**
  45894. * The neutral color used during the preparation of the glow effect.
  45895. * This is black by default as the blend operation is a blend operation.
  45896. */
  45897. static NeutralColor: Color4;
  45898. /**
  45899. * Stencil value used for glowing meshes.
  45900. */
  45901. static GlowingMeshStencilReference: number;
  45902. /**
  45903. * Stencil value used for the other meshes in the scene.
  45904. */
  45905. static NormalMeshStencilReference: number;
  45906. /**
  45907. * Specifies whether or not the inner glow is ACTIVE in the layer.
  45908. */
  45909. innerGlow: boolean;
  45910. /**
  45911. * Specifies whether or not the outer glow is ACTIVE in the layer.
  45912. */
  45913. outerGlow: boolean;
  45914. /**
  45915. * Specifies the horizontal size of the blur.
  45916. */
  45917. /**
  45918. * Gets the horizontal size of the blur.
  45919. */
  45920. blurHorizontalSize: number;
  45921. /**
  45922. * Specifies the vertical size of the blur.
  45923. */
  45924. /**
  45925. * Gets the vertical size of the blur.
  45926. */
  45927. blurVerticalSize: number;
  45928. /**
  45929. * An event triggered when the highlight layer is being blurred.
  45930. */
  45931. onBeforeBlurObservable: Observable<HighlightLayer>;
  45932. /**
  45933. * An event triggered when the highlight layer has been blurred.
  45934. */
  45935. onAfterBlurObservable: Observable<HighlightLayer>;
  45936. private _instanceGlowingMeshStencilReference;
  45937. private _options;
  45938. private _downSamplePostprocess;
  45939. private _horizontalBlurPostprocess;
  45940. private _verticalBlurPostprocess;
  45941. private _blurTexture;
  45942. private _meshes;
  45943. private _excludedMeshes;
  45944. /**
  45945. * Instantiates a new highlight Layer and references it to the scene..
  45946. * @param name The name of the layer
  45947. * @param scene The scene to use the layer in
  45948. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  45949. */
  45950. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  45951. /**
  45952. * Get the effect name of the layer.
  45953. * @return The effect name
  45954. */
  45955. getEffectName(): string;
  45956. /**
  45957. * Create the merge effect. This is the shader use to blit the information back
  45958. * to the main canvas at the end of the scene rendering.
  45959. */
  45960. protected _createMergeEffect(): Effect;
  45961. /**
  45962. * Creates the render target textures and post processes used in the highlight layer.
  45963. */
  45964. protected _createTextureAndPostProcesses(): void;
  45965. /**
  45966. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45967. */
  45968. needStencil(): boolean;
  45969. /**
  45970. * Checks for the readiness of the element composing the layer.
  45971. * @param subMesh the mesh to check for
  45972. * @param useInstances specify wether or not to use instances to render the mesh
  45973. * @param emissiveTexture the associated emissive texture used to generate the glow
  45974. * @return true if ready otherwise, false
  45975. */
  45976. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45977. /**
  45978. * Implementation specific of rendering the generating effect on the main canvas.
  45979. * @param effect The effect used to render through
  45980. */
  45981. protected _internalRender(effect: Effect): void;
  45982. /**
  45983. * Returns true if the layer contains information to display, otherwise false.
  45984. */
  45985. shouldRender(): boolean;
  45986. /**
  45987. * Returns true if the mesh should render, otherwise false.
  45988. * @param mesh The mesh to render
  45989. * @returns true if it should render otherwise false
  45990. */
  45991. protected _shouldRenderMesh(mesh: Mesh): boolean;
  45992. /**
  45993. * Sets the required values for both the emissive texture and and the main color.
  45994. */
  45995. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45996. /**
  45997. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  45998. * @param mesh The mesh to exclude from the highlight layer
  45999. */
  46000. addExcludedMesh(mesh: Mesh): void;
  46001. /**
  46002. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46003. * @param mesh The mesh to highlight
  46004. */
  46005. removeExcludedMesh(mesh: Mesh): void;
  46006. /**
  46007. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46008. * @param mesh mesh to test
  46009. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46010. */
  46011. hasMesh(mesh: AbstractMesh): boolean;
  46012. /**
  46013. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46014. * @param mesh The mesh to highlight
  46015. * @param color The color of the highlight
  46016. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46017. */
  46018. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46019. /**
  46020. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46021. * @param mesh The mesh to highlight
  46022. */
  46023. removeMesh(mesh: Mesh): void;
  46024. /**
  46025. * Force the stencil to the normal expected value for none glowing parts
  46026. */
  46027. private _defaultStencilReference;
  46028. /**
  46029. * Free any resources and references associated to a mesh.
  46030. * Internal use
  46031. * @param mesh The mesh to free.
  46032. * @hidden
  46033. */
  46034. _disposeMesh(mesh: Mesh): void;
  46035. /**
  46036. * Dispose the highlight layer and free resources.
  46037. */
  46038. dispose(): void;
  46039. /**
  46040. * Gets the class name of the effect layer
  46041. * @returns the string with the class name of the effect layer
  46042. */
  46043. getClassName(): string;
  46044. /**
  46045. * Serializes this Highlight layer
  46046. * @returns a serialized Highlight layer object
  46047. */
  46048. serialize(): any;
  46049. /**
  46050. * Creates a Highlight layer from parsed Highlight layer data
  46051. * @param parsedHightlightLayer defines the Highlight layer data
  46052. * @param scene defines the current scene
  46053. * @param rootUrl defines the root URL containing the Highlight layer information
  46054. * @returns a parsed Highlight layer
  46055. */
  46056. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46057. }
  46058. }
  46059. declare module "babylonjs/Layers/index" {
  46060. export * from "babylonjs/Layers/effectLayer";
  46061. export * from "babylonjs/Layers/effectLayerSceneComponent";
  46062. export * from "babylonjs/Layers/glowLayer";
  46063. export * from "babylonjs/Layers/highlightLayer";
  46064. export * from "babylonjs/Layers/layer";
  46065. export * from "babylonjs/Layers/layerSceneComponent";
  46066. }
  46067. declare module "babylonjs/Shaders/lensFlare.fragment" {
  46068. /** @hidden */
  46069. export var lensFlarePixelShader: {
  46070. name: string;
  46071. shader: string;
  46072. };
  46073. }
  46074. declare module "babylonjs/Shaders/lensFlare.vertex" {
  46075. /** @hidden */
  46076. export var lensFlareVertexShader: {
  46077. name: string;
  46078. shader: string;
  46079. };
  46080. }
  46081. declare module "babylonjs/LensFlares/lensFlareSystem" {
  46082. import { Scene } from "babylonjs/scene";
  46083. import { Vector3, Viewport } from "babylonjs/Maths/math";
  46084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46085. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  46086. import "babylonjs/Shaders/lensFlare.fragment";
  46087. import "babylonjs/Shaders/lensFlare.vertex";
  46088. /**
  46089. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46090. * It is usually composed of several `lensFlare`.
  46091. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46092. */
  46093. export class LensFlareSystem {
  46094. /**
  46095. * Define the name of the lens flare system
  46096. */
  46097. name: string;
  46098. /**
  46099. * List of lens flares used in this system.
  46100. */
  46101. lensFlares: LensFlare[];
  46102. /**
  46103. * Define a limit from the border the lens flare can be visible.
  46104. */
  46105. borderLimit: number;
  46106. /**
  46107. * Define a viewport border we do not want to see the lens flare in.
  46108. */
  46109. viewportBorder: number;
  46110. /**
  46111. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46112. */
  46113. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46114. /**
  46115. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46116. */
  46117. layerMask: number;
  46118. /**
  46119. * Define the id of the lens flare system in the scene.
  46120. * (equal to name by default)
  46121. */
  46122. id: string;
  46123. private _scene;
  46124. private _emitter;
  46125. private _vertexBuffers;
  46126. private _indexBuffer;
  46127. private _effect;
  46128. private _positionX;
  46129. private _positionY;
  46130. private _isEnabled;
  46131. /** @hidden */
  46132. static _SceneComponentInitialization: (scene: Scene) => void;
  46133. /**
  46134. * Instantiates a lens flare system.
  46135. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46136. * It is usually composed of several `lensFlare`.
  46137. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46138. * @param name Define the name of the lens flare system in the scene
  46139. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46140. * @param scene Define the scene the lens flare system belongs to
  46141. */
  46142. constructor(
  46143. /**
  46144. * Define the name of the lens flare system
  46145. */
  46146. name: string, emitter: any, scene: Scene);
  46147. /**
  46148. * Define if the lens flare system is enabled.
  46149. */
  46150. isEnabled: boolean;
  46151. /**
  46152. * Get the scene the effects belongs to.
  46153. * @returns the scene holding the lens flare system
  46154. */
  46155. getScene(): Scene;
  46156. /**
  46157. * Get the emitter of the lens flare system.
  46158. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46159. * @returns the emitter of the lens flare system
  46160. */
  46161. getEmitter(): any;
  46162. /**
  46163. * Set the emitter of the lens flare system.
  46164. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46165. * @param newEmitter Define the new emitter of the system
  46166. */
  46167. setEmitter(newEmitter: any): void;
  46168. /**
  46169. * Get the lens flare system emitter position.
  46170. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46171. * @returns the position
  46172. */
  46173. getEmitterPosition(): Vector3;
  46174. /**
  46175. * @hidden
  46176. */
  46177. computeEffectivePosition(globalViewport: Viewport): boolean;
  46178. /** @hidden */
  46179. _isVisible(): boolean;
  46180. /**
  46181. * @hidden
  46182. */
  46183. render(): boolean;
  46184. /**
  46185. * Dispose and release the lens flare with its associated resources.
  46186. */
  46187. dispose(): void;
  46188. /**
  46189. * Parse a lens flare system from a JSON repressentation
  46190. * @param parsedLensFlareSystem Define the JSON to parse
  46191. * @param scene Define the scene the parsed system should be instantiated in
  46192. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46193. * @returns the parsed system
  46194. */
  46195. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46196. /**
  46197. * Serialize the current Lens Flare System into a JSON representation.
  46198. * @returns the serialized JSON
  46199. */
  46200. serialize(): any;
  46201. }
  46202. }
  46203. declare module "babylonjs/LensFlares/lensFlare" {
  46204. import { Nullable } from "babylonjs/types";
  46205. import { Color3 } from "babylonjs/Maths/math";
  46206. import { Texture } from "babylonjs/Materials/Textures/texture";
  46207. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46208. /**
  46209. * This represents one of the lens effect in a `lensFlareSystem`.
  46210. * It controls one of the indiviual texture used in the effect.
  46211. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46212. */
  46213. export class LensFlare {
  46214. /**
  46215. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46216. */
  46217. size: number;
  46218. /**
  46219. * 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.
  46220. */
  46221. position: number;
  46222. /**
  46223. * Define the lens color.
  46224. */
  46225. color: Color3;
  46226. /**
  46227. * Define the lens texture.
  46228. */
  46229. texture: Nullable<Texture>;
  46230. /**
  46231. * Define the alpha mode to render this particular lens.
  46232. */
  46233. alphaMode: number;
  46234. private _system;
  46235. /**
  46236. * Creates a new Lens Flare.
  46237. * This represents one of the lens effect in a `lensFlareSystem`.
  46238. * It controls one of the indiviual texture used in the effect.
  46239. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46240. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46241. * @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.
  46242. * @param color Define the lens color
  46243. * @param imgUrl Define the lens texture url
  46244. * @param system Define the `lensFlareSystem` this flare is part of
  46245. * @returns The newly created Lens Flare
  46246. */
  46247. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46248. /**
  46249. * Instantiates a new Lens Flare.
  46250. * This represents one of the lens effect in a `lensFlareSystem`.
  46251. * It controls one of the indiviual texture used in the effect.
  46252. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46253. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46254. * @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.
  46255. * @param color Define the lens color
  46256. * @param imgUrl Define the lens texture url
  46257. * @param system Define the `lensFlareSystem` this flare is part of
  46258. */
  46259. constructor(
  46260. /**
  46261. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46262. */
  46263. size: number,
  46264. /**
  46265. * 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.
  46266. */
  46267. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  46268. /**
  46269. * Dispose and release the lens flare with its associated resources.
  46270. */
  46271. dispose(): void;
  46272. }
  46273. }
  46274. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  46275. import { Nullable } from "babylonjs/types";
  46276. import { Scene } from "babylonjs/scene";
  46277. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46278. import { AbstractScene } from "babylonjs/abstractScene";
  46279. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46280. module "babylonjs/abstractScene" {
  46281. interface AbstractScene {
  46282. /**
  46283. * The list of lens flare system added to the scene
  46284. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46285. */
  46286. lensFlareSystems: Array<LensFlareSystem>;
  46287. /**
  46288. * Removes the given lens flare system from this scene.
  46289. * @param toRemove The lens flare system to remove
  46290. * @returns The index of the removed lens flare system
  46291. */
  46292. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  46293. /**
  46294. * Adds the given lens flare system to this scene
  46295. * @param newLensFlareSystem The lens flare system to add
  46296. */
  46297. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  46298. /**
  46299. * Gets a lens flare system using its name
  46300. * @param name defines the name to look for
  46301. * @returns the lens flare system or null if not found
  46302. */
  46303. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  46304. /**
  46305. * Gets a lens flare system using its id
  46306. * @param id defines the id to look for
  46307. * @returns the lens flare system or null if not found
  46308. */
  46309. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  46310. }
  46311. }
  46312. /**
  46313. * Defines the lens flare scene component responsible to manage any lens flares
  46314. * in a given scene.
  46315. */
  46316. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  46317. /**
  46318. * The component name helpfull to identify the component in the list of scene components.
  46319. */
  46320. readonly name: string;
  46321. /**
  46322. * The scene the component belongs to.
  46323. */
  46324. scene: Scene;
  46325. /**
  46326. * Creates a new instance of the component for the given scene
  46327. * @param scene Defines the scene to register the component in
  46328. */
  46329. constructor(scene: Scene);
  46330. /**
  46331. * Registers the component in a given scene
  46332. */
  46333. register(): void;
  46334. /**
  46335. * Rebuilds the elements related to this component in case of
  46336. * context lost for instance.
  46337. */
  46338. rebuild(): void;
  46339. /**
  46340. * Adds all the element from the container to the scene
  46341. * @param container the container holding the elements
  46342. */
  46343. addFromContainer(container: AbstractScene): void;
  46344. /**
  46345. * Removes all the elements in the container from the scene
  46346. * @param container contains the elements to remove
  46347. */
  46348. removeFromContainer(container: AbstractScene): void;
  46349. /**
  46350. * Serializes the component data to the specified json object
  46351. * @param serializationObject The object to serialize to
  46352. */
  46353. serialize(serializationObject: any): void;
  46354. /**
  46355. * Disposes the component and the associated ressources.
  46356. */
  46357. dispose(): void;
  46358. private _draw;
  46359. }
  46360. }
  46361. declare module "babylonjs/LensFlares/index" {
  46362. export * from "babylonjs/LensFlares/lensFlare";
  46363. export * from "babylonjs/LensFlares/lensFlareSystem";
  46364. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  46365. }
  46366. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  46367. import { Scene } from "babylonjs/scene";
  46368. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46369. import { AbstractScene } from "babylonjs/abstractScene";
  46370. /**
  46371. * Defines the shadow generator component responsible to manage any shadow generators
  46372. * in a given scene.
  46373. */
  46374. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  46375. /**
  46376. * The component name helpfull to identify the component in the list of scene components.
  46377. */
  46378. readonly name: string;
  46379. /**
  46380. * The scene the component belongs to.
  46381. */
  46382. scene: Scene;
  46383. /**
  46384. * Creates a new instance of the component for the given scene
  46385. * @param scene Defines the scene to register the component in
  46386. */
  46387. constructor(scene: Scene);
  46388. /**
  46389. * Registers the component in a given scene
  46390. */
  46391. register(): void;
  46392. /**
  46393. * Rebuilds the elements related to this component in case of
  46394. * context lost for instance.
  46395. */
  46396. rebuild(): void;
  46397. /**
  46398. * Serializes the component data to the specified json object
  46399. * @param serializationObject The object to serialize to
  46400. */
  46401. serialize(serializationObject: any): void;
  46402. /**
  46403. * Adds all the element from the container to the scene
  46404. * @param container the container holding the elements
  46405. */
  46406. addFromContainer(container: AbstractScene): void;
  46407. /**
  46408. * Removes all the elements in the container from the scene
  46409. * @param container contains the elements to remove
  46410. */
  46411. removeFromContainer(container: AbstractScene): void;
  46412. /**
  46413. * Rebuilds the elements related to this component in case of
  46414. * context lost for instance.
  46415. */
  46416. dispose(): void;
  46417. private _gatherRenderTargets;
  46418. }
  46419. }
  46420. declare module "babylonjs/Lights/Shadows/index" {
  46421. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  46422. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  46423. }
  46424. declare module "babylonjs/Lights/directionalLight" {
  46425. import { Camera } from "babylonjs/Cameras/camera";
  46426. import { Scene } from "babylonjs/scene";
  46427. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46429. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46430. import { Effect } from "babylonjs/Materials/effect";
  46431. /**
  46432. * A directional light is defined by a direction (what a surprise!).
  46433. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46434. * 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.
  46435. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46436. */
  46437. export class DirectionalLight extends ShadowLight {
  46438. private _shadowFrustumSize;
  46439. /**
  46440. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46441. */
  46442. /**
  46443. * Specifies a fix frustum size for the shadow generation.
  46444. */
  46445. shadowFrustumSize: number;
  46446. private _shadowOrthoScale;
  46447. /**
  46448. * Gets the shadow projection scale against the optimal computed one.
  46449. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46450. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46451. */
  46452. /**
  46453. * Sets the shadow projection scale against the optimal computed one.
  46454. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46455. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46456. */
  46457. shadowOrthoScale: number;
  46458. /**
  46459. * Automatically compute the projection matrix to best fit (including all the casters)
  46460. * on each frame.
  46461. */
  46462. autoUpdateExtends: boolean;
  46463. private _orthoLeft;
  46464. private _orthoRight;
  46465. private _orthoTop;
  46466. private _orthoBottom;
  46467. /**
  46468. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46469. * The directional light is emitted from everywhere in the given direction.
  46470. * It can cast shadows.
  46471. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46472. * @param name The friendly name of the light
  46473. * @param direction The direction of the light
  46474. * @param scene The scene the light belongs to
  46475. */
  46476. constructor(name: string, direction: Vector3, scene: Scene);
  46477. /**
  46478. * Returns the string "DirectionalLight".
  46479. * @return The class name
  46480. */
  46481. getClassName(): string;
  46482. /**
  46483. * Returns the integer 1.
  46484. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46485. */
  46486. getTypeID(): number;
  46487. /**
  46488. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46489. * Returns the DirectionalLight Shadow projection matrix.
  46490. */
  46491. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46492. /**
  46493. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46494. * Returns the DirectionalLight Shadow projection matrix.
  46495. */
  46496. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46497. /**
  46498. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46499. * Returns the DirectionalLight Shadow projection matrix.
  46500. */
  46501. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46502. protected _buildUniformLayout(): void;
  46503. /**
  46504. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46505. * @param effect The effect to update
  46506. * @param lightIndex The index of the light in the effect to update
  46507. * @returns The directional light
  46508. */
  46509. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46510. /**
  46511. * Gets the minZ used for shadow according to both the scene and the light.
  46512. *
  46513. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46514. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46515. * @param activeCamera The camera we are returning the min for
  46516. * @returns the depth min z
  46517. */
  46518. getDepthMinZ(activeCamera: Camera): number;
  46519. /**
  46520. * Gets the maxZ used for shadow according to both the scene and the light.
  46521. *
  46522. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46523. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46524. * @param activeCamera The camera we are returning the max for
  46525. * @returns the depth max z
  46526. */
  46527. getDepthMaxZ(activeCamera: Camera): number;
  46528. /**
  46529. * Prepares the list of defines specific to the light type.
  46530. * @param defines the list of defines
  46531. * @param lightIndex defines the index of the light for the effect
  46532. */
  46533. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46534. }
  46535. }
  46536. declare module "babylonjs/Lights/pointLight" {
  46537. import { Scene } from "babylonjs/scene";
  46538. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46540. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46541. import { Effect } from "babylonjs/Materials/effect";
  46542. /**
  46543. * A point light is a light defined by an unique point in world space.
  46544. * The light is emitted in every direction from this point.
  46545. * A good example of a point light is a standard light bulb.
  46546. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46547. */
  46548. export class PointLight extends ShadowLight {
  46549. private _shadowAngle;
  46550. /**
  46551. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46552. * This specifies what angle the shadow will use to be created.
  46553. *
  46554. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46555. */
  46556. /**
  46557. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46558. * This specifies what angle the shadow will use to be created.
  46559. *
  46560. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46561. */
  46562. shadowAngle: number;
  46563. /**
  46564. * Gets the direction if it has been set.
  46565. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46566. */
  46567. /**
  46568. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46569. */
  46570. direction: Vector3;
  46571. /**
  46572. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  46573. * A PointLight emits the light in every direction.
  46574. * It can cast shadows.
  46575. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  46576. * ```javascript
  46577. * var pointLight = new PointLight("pl", camera.position, scene);
  46578. * ```
  46579. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46580. * @param name The light friendly name
  46581. * @param position The position of the point light in the scene
  46582. * @param scene The scene the lights belongs to
  46583. */
  46584. constructor(name: string, position: Vector3, scene: Scene);
  46585. /**
  46586. * Returns the string "PointLight"
  46587. * @returns the class name
  46588. */
  46589. getClassName(): string;
  46590. /**
  46591. * Returns the integer 0.
  46592. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46593. */
  46594. getTypeID(): number;
  46595. /**
  46596. * Specifies wether or not the shadowmap should be a cube texture.
  46597. * @returns true if the shadowmap needs to be a cube texture.
  46598. */
  46599. needCube(): boolean;
  46600. /**
  46601. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  46602. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46603. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46604. */
  46605. getShadowDirection(faceIndex?: number): Vector3;
  46606. /**
  46607. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  46608. * - fov = PI / 2
  46609. * - aspect ratio : 1.0
  46610. * - z-near and far equal to the active camera minZ and maxZ.
  46611. * Returns the PointLight.
  46612. */
  46613. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46614. protected _buildUniformLayout(): void;
  46615. /**
  46616. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  46617. * @param effect The effect to update
  46618. * @param lightIndex The index of the light in the effect to update
  46619. * @returns The point light
  46620. */
  46621. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  46622. /**
  46623. * Prepares the list of defines specific to the light type.
  46624. * @param defines the list of defines
  46625. * @param lightIndex defines the index of the light for the effect
  46626. */
  46627. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46628. }
  46629. }
  46630. declare module "babylonjs/Lights/spotLight" {
  46631. import { Nullable } from "babylonjs/types";
  46632. import { Scene } from "babylonjs/scene";
  46633. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46635. import { Effect } from "babylonjs/Materials/effect";
  46636. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46637. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46638. /**
  46639. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46640. * These values define a cone of light starting from the position, emitting toward the direction.
  46641. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46642. * and the exponent defines the speed of the decay of the light with distance (reach).
  46643. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46644. */
  46645. export class SpotLight extends ShadowLight {
  46646. private _angle;
  46647. private _innerAngle;
  46648. private _cosHalfAngle;
  46649. private _lightAngleScale;
  46650. private _lightAngleOffset;
  46651. /**
  46652. * Gets the cone angle of the spot light in Radians.
  46653. */
  46654. /**
  46655. * Sets the cone angle of the spot light in Radians.
  46656. */
  46657. angle: number;
  46658. /**
  46659. * Only used in gltf falloff mode, this defines the angle where
  46660. * the directional falloff will start before cutting at angle which could be seen
  46661. * as outer angle.
  46662. */
  46663. /**
  46664. * Only used in gltf falloff mode, this defines the angle where
  46665. * the directional falloff will start before cutting at angle which could be seen
  46666. * as outer angle.
  46667. */
  46668. innerAngle: number;
  46669. private _shadowAngleScale;
  46670. /**
  46671. * Allows scaling the angle of the light for shadow generation only.
  46672. */
  46673. /**
  46674. * Allows scaling the angle of the light for shadow generation only.
  46675. */
  46676. shadowAngleScale: number;
  46677. /**
  46678. * The light decay speed with the distance from the emission spot.
  46679. */
  46680. exponent: number;
  46681. private _projectionTextureMatrix;
  46682. /**
  46683. * Allows reading the projecton texture
  46684. */
  46685. readonly projectionTextureMatrix: Matrix;
  46686. protected _projectionTextureLightNear: number;
  46687. /**
  46688. * Gets the near clip of the Spotlight for texture projection.
  46689. */
  46690. /**
  46691. * Sets the near clip of the Spotlight for texture projection.
  46692. */
  46693. projectionTextureLightNear: number;
  46694. protected _projectionTextureLightFar: number;
  46695. /**
  46696. * Gets the far clip of the Spotlight for texture projection.
  46697. */
  46698. /**
  46699. * Sets the far clip of the Spotlight for texture projection.
  46700. */
  46701. projectionTextureLightFar: number;
  46702. protected _projectionTextureUpDirection: Vector3;
  46703. /**
  46704. * Gets the Up vector of the Spotlight for texture projection.
  46705. */
  46706. /**
  46707. * Sets the Up vector of the Spotlight for texture projection.
  46708. */
  46709. projectionTextureUpDirection: Vector3;
  46710. private _projectionTexture;
  46711. /**
  46712. * Gets the projection texture of the light.
  46713. */
  46714. /**
  46715. * Sets the projection texture of the light.
  46716. */
  46717. projectionTexture: Nullable<BaseTexture>;
  46718. private _projectionTextureViewLightDirty;
  46719. private _projectionTextureProjectionLightDirty;
  46720. private _projectionTextureDirty;
  46721. private _projectionTextureViewTargetVector;
  46722. private _projectionTextureViewLightMatrix;
  46723. private _projectionTextureProjectionLightMatrix;
  46724. private _projectionTextureScalingMatrix;
  46725. /**
  46726. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46727. * It can cast shadows.
  46728. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46729. * @param name The light friendly name
  46730. * @param position The position of the spot light in the scene
  46731. * @param direction The direction of the light in the scene
  46732. * @param angle The cone angle of the light in Radians
  46733. * @param exponent The light decay speed with the distance from the emission spot
  46734. * @param scene The scene the lights belongs to
  46735. */
  46736. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46737. /**
  46738. * Returns the string "SpotLight".
  46739. * @returns the class name
  46740. */
  46741. getClassName(): string;
  46742. /**
  46743. * Returns the integer 2.
  46744. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46745. */
  46746. getTypeID(): number;
  46747. /**
  46748. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46749. */
  46750. protected _setDirection(value: Vector3): void;
  46751. /**
  46752. * Overrides the position setter to recompute the projection texture view light Matrix.
  46753. */
  46754. protected _setPosition(value: Vector3): void;
  46755. /**
  46756. * 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.
  46757. * Returns the SpotLight.
  46758. */
  46759. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46760. protected _computeProjectionTextureViewLightMatrix(): void;
  46761. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46762. /**
  46763. * Main function for light texture projection matrix computing.
  46764. */
  46765. protected _computeProjectionTextureMatrix(): void;
  46766. protected _buildUniformLayout(): void;
  46767. private _computeAngleValues;
  46768. /**
  46769. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46770. * @param effect The effect to update
  46771. * @param lightIndex The index of the light in the effect to update
  46772. * @returns The spot light
  46773. */
  46774. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46775. /**
  46776. * Disposes the light and the associated resources.
  46777. */
  46778. dispose(): void;
  46779. /**
  46780. * Prepares the list of defines specific to the light type.
  46781. * @param defines the list of defines
  46782. * @param lightIndex defines the index of the light for the effect
  46783. */
  46784. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46785. }
  46786. }
  46787. declare module "babylonjs/Lights/index" {
  46788. export * from "babylonjs/Lights/light";
  46789. export * from "babylonjs/Lights/shadowLight";
  46790. export * from "babylonjs/Lights/Shadows/index";
  46791. export * from "babylonjs/Lights/directionalLight";
  46792. export * from "babylonjs/Lights/hemisphericLight";
  46793. export * from "babylonjs/Lights/pointLight";
  46794. export * from "babylonjs/Lights/spotLight";
  46795. }
  46796. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  46797. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46798. /**
  46799. * Header information of HDR texture files.
  46800. */
  46801. export interface HDRInfo {
  46802. /**
  46803. * The height of the texture in pixels.
  46804. */
  46805. height: number;
  46806. /**
  46807. * The width of the texture in pixels.
  46808. */
  46809. width: number;
  46810. /**
  46811. * The index of the beginning of the data in the binary file.
  46812. */
  46813. dataPosition: number;
  46814. }
  46815. /**
  46816. * This groups tools to convert HDR texture to native colors array.
  46817. */
  46818. export class HDRTools {
  46819. private static Ldexp;
  46820. private static Rgbe2float;
  46821. private static readStringLine;
  46822. /**
  46823. * Reads header information from an RGBE texture stored in a native array.
  46824. * More information on this format are available here:
  46825. * https://en.wikipedia.org/wiki/RGBE_image_format
  46826. *
  46827. * @param uint8array The binary file stored in native array.
  46828. * @return The header information.
  46829. */
  46830. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  46831. /**
  46832. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  46833. * This RGBE texture needs to store the information as a panorama.
  46834. *
  46835. * More information on this format are available here:
  46836. * https://en.wikipedia.org/wiki/RGBE_image_format
  46837. *
  46838. * @param buffer The binary file stored in an array buffer.
  46839. * @param size The expected size of the extracted cubemap.
  46840. * @return The Cube Map information.
  46841. */
  46842. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  46843. /**
  46844. * Returns the pixels data extracted from an RGBE texture.
  46845. * This pixels will be stored left to right up to down in the R G B order in one array.
  46846. *
  46847. * More information on this format are available here:
  46848. * https://en.wikipedia.org/wiki/RGBE_image_format
  46849. *
  46850. * @param uint8array The binary file stored in an array buffer.
  46851. * @param hdrInfo The header information of the file.
  46852. * @return The pixels data in RGB right to left up to down order.
  46853. */
  46854. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  46855. private static RGBE_ReadPixels_RLE;
  46856. }
  46857. }
  46858. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  46859. import { Nullable } from "babylonjs/types";
  46860. import { Scene } from "babylonjs/scene";
  46861. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46862. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46863. /**
  46864. * This represents a texture coming from an HDR input.
  46865. *
  46866. * The only supported format is currently panorama picture stored in RGBE format.
  46867. * Example of such files can be found on HDRLib: http://hdrlib.com/
  46868. */
  46869. export class HDRCubeTexture extends BaseTexture {
  46870. private static _facesMapping;
  46871. private _generateHarmonics;
  46872. private _noMipmap;
  46873. private _textureMatrix;
  46874. private _size;
  46875. private _onLoad;
  46876. private _onError;
  46877. /**
  46878. * The texture URL.
  46879. */
  46880. url: string;
  46881. /**
  46882. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  46883. */
  46884. coordinatesMode: number;
  46885. protected _isBlocking: boolean;
  46886. /**
  46887. * Sets wether or not the texture is blocking during loading.
  46888. */
  46889. /**
  46890. * Gets wether or not the texture is blocking during loading.
  46891. */
  46892. isBlocking: boolean;
  46893. protected _rotationY: number;
  46894. /**
  46895. * Sets texture matrix rotation angle around Y axis in radians.
  46896. */
  46897. /**
  46898. * Gets texture matrix rotation angle around Y axis radians.
  46899. */
  46900. rotationY: number;
  46901. /**
  46902. * Gets or sets the center of the bounding box associated with the cube texture
  46903. * It must define where the camera used to render the texture was set
  46904. */
  46905. boundingBoxPosition: Vector3;
  46906. private _boundingBoxSize;
  46907. /**
  46908. * Gets or sets the size of the bounding box associated with the cube texture
  46909. * When defined, the cubemap will switch to local mode
  46910. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46911. * @example https://www.babylonjs-playground.com/#RNASML
  46912. */
  46913. boundingBoxSize: Vector3;
  46914. /**
  46915. * Instantiates an HDRTexture from the following parameters.
  46916. *
  46917. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  46918. * @param scene The scene the texture will be used in
  46919. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  46920. * @param noMipmap Forces to not generate the mipmap if true
  46921. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  46922. * @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)
  46923. * @param reserved Reserved flag for internal use.
  46924. */
  46925. 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>);
  46926. /**
  46927. * Get the current class name of the texture useful for serialization or dynamic coding.
  46928. * @returns "HDRCubeTexture"
  46929. */
  46930. getClassName(): string;
  46931. /**
  46932. * Occurs when the file is raw .hdr file.
  46933. */
  46934. private loadTexture;
  46935. clone(): HDRCubeTexture;
  46936. delayLoad(): void;
  46937. /**
  46938. * Get the texture reflection matrix used to rotate/transform the reflection.
  46939. * @returns the reflection matrix
  46940. */
  46941. getReflectionTextureMatrix(): Matrix;
  46942. /**
  46943. * Set the texture reflection matrix used to rotate/transform the reflection.
  46944. * @param value Define the reflection matrix to set
  46945. */
  46946. setReflectionTextureMatrix(value: Matrix): void;
  46947. /**
  46948. * Parses a JSON representation of an HDR Texture in order to create the texture
  46949. * @param parsedTexture Define the JSON representation
  46950. * @param scene Define the scene the texture should be created in
  46951. * @param rootUrl Define the root url in case we need to load relative dependencies
  46952. * @returns the newly created texture after parsing
  46953. */
  46954. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  46955. serialize(): any;
  46956. }
  46957. }
  46958. declare module "babylonjs/Physics/physicsEngine" {
  46959. import { Nullable } from "babylonjs/types";
  46960. import { Vector3 } from "babylonjs/Maths/math";
  46961. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  46962. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  46963. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  46964. /**
  46965. * Class used to control physics engine
  46966. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  46967. */
  46968. export class PhysicsEngine implements IPhysicsEngine {
  46969. private _physicsPlugin;
  46970. /**
  46971. * Global value used to control the smallest number supported by the simulation
  46972. */
  46973. static Epsilon: number;
  46974. private _impostors;
  46975. private _joints;
  46976. /**
  46977. * Gets the gravity vector used by the simulation
  46978. */
  46979. gravity: Vector3;
  46980. /**
  46981. * Factory used to create the default physics plugin.
  46982. * @returns The default physics plugin
  46983. */
  46984. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  46985. /**
  46986. * Creates a new Physics Engine
  46987. * @param gravity defines the gravity vector used by the simulation
  46988. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  46989. */
  46990. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  46991. /**
  46992. * Sets the gravity vector used by the simulation
  46993. * @param gravity defines the gravity vector to use
  46994. */
  46995. setGravity(gravity: Vector3): void;
  46996. /**
  46997. * Set the time step of the physics engine.
  46998. * Default is 1/60.
  46999. * To slow it down, enter 1/600 for example.
  47000. * To speed it up, 1/30
  47001. * @param newTimeStep defines the new timestep to apply to this world.
  47002. */
  47003. setTimeStep(newTimeStep?: number): void;
  47004. /**
  47005. * Get the time step of the physics engine.
  47006. * @returns the current time step
  47007. */
  47008. getTimeStep(): number;
  47009. /**
  47010. * Release all resources
  47011. */
  47012. dispose(): void;
  47013. /**
  47014. * Gets the name of the current physics plugin
  47015. * @returns the name of the plugin
  47016. */
  47017. getPhysicsPluginName(): string;
  47018. /**
  47019. * Adding a new impostor for the impostor tracking.
  47020. * This will be done by the impostor itself.
  47021. * @param impostor the impostor to add
  47022. */
  47023. addImpostor(impostor: PhysicsImpostor): void;
  47024. /**
  47025. * Remove an impostor from the engine.
  47026. * This impostor and its mesh will not longer be updated by the physics engine.
  47027. * @param impostor the impostor to remove
  47028. */
  47029. removeImpostor(impostor: PhysicsImpostor): void;
  47030. /**
  47031. * Add a joint to the physics engine
  47032. * @param mainImpostor defines the main impostor to which the joint is added.
  47033. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47034. * @param joint defines the joint that will connect both impostors.
  47035. */
  47036. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47037. /**
  47038. * Removes a joint from the simulation
  47039. * @param mainImpostor defines the impostor used with the joint
  47040. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47041. * @param joint defines the joint to remove
  47042. */
  47043. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47044. /**
  47045. * Called by the scene. No need to call it.
  47046. * @param delta defines the timespam between frames
  47047. */
  47048. _step(delta: number): void;
  47049. /**
  47050. * Gets the current plugin used to run the simulation
  47051. * @returns current plugin
  47052. */
  47053. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47054. /**
  47055. * Gets the list of physic impostors
  47056. * @returns an array of PhysicsImpostor
  47057. */
  47058. getImpostors(): Array<PhysicsImpostor>;
  47059. /**
  47060. * Gets the impostor for a physics enabled object
  47061. * @param object defines the object impersonated by the impostor
  47062. * @returns the PhysicsImpostor or null if not found
  47063. */
  47064. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47065. /**
  47066. * Gets the impostor for a physics body object
  47067. * @param body defines physics body used by the impostor
  47068. * @returns the PhysicsImpostor or null if not found
  47069. */
  47070. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47071. }
  47072. }
  47073. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  47074. import { Nullable } from "babylonjs/types";
  47075. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47077. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47078. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47079. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47080. /** @hidden */
  47081. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47082. private _useDeltaForWorldStep;
  47083. world: any;
  47084. name: string;
  47085. private _physicsMaterials;
  47086. private _fixedTimeStep;
  47087. BJSCANNON: any;
  47088. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47089. setGravity(gravity: Vector3): void;
  47090. setTimeStep(timeStep: number): void;
  47091. getTimeStep(): number;
  47092. executeStep(delta: number): void;
  47093. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47094. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47095. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47096. private _processChildMeshes;
  47097. removePhysicsBody(impostor: PhysicsImpostor): void;
  47098. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47099. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47100. private _addMaterial;
  47101. private _checkWithEpsilon;
  47102. private _createShape;
  47103. private _createHeightmap;
  47104. private _minus90X;
  47105. private _plus90X;
  47106. private _tmpPosition;
  47107. private _tmpDeltaPosition;
  47108. private _tmpUnityRotation;
  47109. private _updatePhysicsBodyTransformation;
  47110. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47111. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47112. isSupported(): boolean;
  47113. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47114. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47115. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47116. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47117. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47118. getBodyMass(impostor: PhysicsImpostor): number;
  47119. getBodyFriction(impostor: PhysicsImpostor): number;
  47120. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47121. getBodyRestitution(impostor: PhysicsImpostor): number;
  47122. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47123. sleepBody(impostor: PhysicsImpostor): void;
  47124. wakeUpBody(impostor: PhysicsImpostor): void;
  47125. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47126. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47127. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47128. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47129. getRadius(impostor: PhysicsImpostor): number;
  47130. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47131. dispose(): void;
  47132. private _extendNamespace;
  47133. }
  47134. }
  47135. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  47136. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47137. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47138. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47139. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47140. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47141. import { Nullable } from "babylonjs/types";
  47142. /** @hidden */
  47143. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47144. world: any;
  47145. name: string;
  47146. BJSOIMO: any;
  47147. constructor(iterations?: number, oimoInjection?: any);
  47148. setGravity(gravity: Vector3): void;
  47149. setTimeStep(timeStep: number): void;
  47150. getTimeStep(): number;
  47151. private _tmpImpostorsArray;
  47152. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47153. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47154. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47155. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47156. private _tmpPositionVector;
  47157. removePhysicsBody(impostor: PhysicsImpostor): void;
  47158. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47159. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47160. isSupported(): boolean;
  47161. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47162. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47163. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47164. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47165. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47166. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47167. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47168. getBodyMass(impostor: PhysicsImpostor): number;
  47169. getBodyFriction(impostor: PhysicsImpostor): number;
  47170. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47171. getBodyRestitution(impostor: PhysicsImpostor): number;
  47172. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47173. sleepBody(impostor: PhysicsImpostor): void;
  47174. wakeUpBody(impostor: PhysicsImpostor): void;
  47175. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47176. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  47177. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47178. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47179. getRadius(impostor: PhysicsImpostor): number;
  47180. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47181. dispose(): void;
  47182. }
  47183. }
  47184. declare module "babylonjs/Probes/reflectionProbe" {
  47185. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47186. import { Vector3 } from "babylonjs/Maths/math";
  47187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47188. import { Nullable } from "babylonjs/types";
  47189. import { Scene } from "babylonjs/scene";
  47190. module "babylonjs/abstractScene" {
  47191. interface AbstractScene {
  47192. /**
  47193. * The list of reflection probes added to the scene
  47194. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47195. */
  47196. reflectionProbes: Array<ReflectionProbe>;
  47197. /**
  47198. * Removes the given reflection probe from this scene.
  47199. * @param toRemove The reflection probe to remove
  47200. * @returns The index of the removed reflection probe
  47201. */
  47202. removeReflectionProbe(toRemove: ReflectionProbe): number;
  47203. /**
  47204. * Adds the given reflection probe to this scene.
  47205. * @param newReflectionProbe The reflection probe to add
  47206. */
  47207. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  47208. }
  47209. }
  47210. /**
  47211. * Class used to generate realtime reflection / refraction cube textures
  47212. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47213. */
  47214. export class ReflectionProbe {
  47215. /** defines the name of the probe */
  47216. name: string;
  47217. private _scene;
  47218. private _renderTargetTexture;
  47219. private _projectionMatrix;
  47220. private _viewMatrix;
  47221. private _target;
  47222. private _add;
  47223. private _attachedMesh;
  47224. private _invertYAxis;
  47225. /** Gets or sets probe position (center of the cube map) */
  47226. position: Vector3;
  47227. /**
  47228. * Creates a new reflection probe
  47229. * @param name defines the name of the probe
  47230. * @param size defines the texture resolution (for each face)
  47231. * @param scene defines the hosting scene
  47232. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  47233. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  47234. */
  47235. constructor(
  47236. /** defines the name of the probe */
  47237. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  47238. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  47239. samples: number;
  47240. /** Gets or sets the refresh rate to use (on every frame by default) */
  47241. refreshRate: number;
  47242. /**
  47243. * Gets the hosting scene
  47244. * @returns a Scene
  47245. */
  47246. getScene(): Scene;
  47247. /** Gets the internal CubeTexture used to render to */
  47248. readonly cubeTexture: RenderTargetTexture;
  47249. /** Gets the list of meshes to render */
  47250. readonly renderList: Nullable<AbstractMesh[]>;
  47251. /**
  47252. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  47253. * @param mesh defines the mesh to attach to
  47254. */
  47255. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47256. /**
  47257. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  47258. * @param renderingGroupId The rendering group id corresponding to its index
  47259. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47260. */
  47261. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47262. /**
  47263. * Clean all associated resources
  47264. */
  47265. dispose(): void;
  47266. /**
  47267. * Converts the reflection probe information to a readable string for debug purpose.
  47268. * @param fullDetails Supports for multiple levels of logging within scene loading
  47269. * @returns the human readable reflection probe info
  47270. */
  47271. toString(fullDetails?: boolean): string;
  47272. /**
  47273. * Get the class name of the relfection probe.
  47274. * @returns "ReflectionProbe"
  47275. */
  47276. getClassName(): string;
  47277. /**
  47278. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  47279. * @returns The JSON representation of the texture
  47280. */
  47281. serialize(): any;
  47282. /**
  47283. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  47284. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  47285. * @param scene Define the scene the parsed reflection probe should be instantiated in
  47286. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47287. * @returns The parsed reflection probe if successful
  47288. */
  47289. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  47290. }
  47291. }
  47292. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  47293. /** @hidden */
  47294. export var _BabylonLoaderRegistered: boolean;
  47295. }
  47296. declare module "babylonjs/Loading/Plugins/index" {
  47297. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  47298. }
  47299. declare module "babylonjs/Loading/index" {
  47300. export * from "babylonjs/Loading/loadingScreen";
  47301. export * from "babylonjs/Loading/Plugins/index";
  47302. export * from "babylonjs/Loading/sceneLoader";
  47303. export * from "babylonjs/Loading/sceneLoaderFlags";
  47304. }
  47305. declare module "babylonjs/Materials/Background/index" {
  47306. export * from "babylonjs/Materials/Background/backgroundMaterial";
  47307. }
  47308. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  47309. import { Scene } from "babylonjs/scene";
  47310. import { Color3 } from "babylonjs/Maths/math";
  47311. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47312. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47313. /**
  47314. * The Physically based simple base material of BJS.
  47315. *
  47316. * This enables better naming and convention enforcements on top of the pbrMaterial.
  47317. * It is used as the base class for both the specGloss and metalRough conventions.
  47318. */
  47319. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  47320. /**
  47321. * Number of Simultaneous lights allowed on the material.
  47322. */
  47323. maxSimultaneousLights: number;
  47324. /**
  47325. * If sets to true, disables all the lights affecting the material.
  47326. */
  47327. disableLighting: boolean;
  47328. /**
  47329. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  47330. */
  47331. environmentTexture: BaseTexture;
  47332. /**
  47333. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47334. */
  47335. invertNormalMapX: boolean;
  47336. /**
  47337. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47338. */
  47339. invertNormalMapY: boolean;
  47340. /**
  47341. * Normal map used in the model.
  47342. */
  47343. normalTexture: BaseTexture;
  47344. /**
  47345. * Emissivie color used to self-illuminate the model.
  47346. */
  47347. emissiveColor: Color3;
  47348. /**
  47349. * Emissivie texture used to self-illuminate the model.
  47350. */
  47351. emissiveTexture: BaseTexture;
  47352. /**
  47353. * Occlusion Channel Strenght.
  47354. */
  47355. occlusionStrength: number;
  47356. /**
  47357. * Occlusion Texture of the material (adding extra occlusion effects).
  47358. */
  47359. occlusionTexture: BaseTexture;
  47360. /**
  47361. * Defines the alpha limits in alpha test mode.
  47362. */
  47363. alphaCutOff: number;
  47364. /**
  47365. * Gets the current double sided mode.
  47366. */
  47367. /**
  47368. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47369. */
  47370. doubleSided: boolean;
  47371. /**
  47372. * Stores the pre-calculated light information of a mesh in a texture.
  47373. */
  47374. lightmapTexture: BaseTexture;
  47375. /**
  47376. * If true, the light map contains occlusion information instead of lighting info.
  47377. */
  47378. useLightmapAsShadowmap: boolean;
  47379. /**
  47380. * Return the active textures of the material.
  47381. */
  47382. getActiveTextures(): BaseTexture[];
  47383. hasTexture(texture: BaseTexture): boolean;
  47384. /**
  47385. * Instantiates a new PBRMaterial instance.
  47386. *
  47387. * @param name The material name
  47388. * @param scene The scene the material will be use in.
  47389. */
  47390. constructor(name: string, scene: Scene);
  47391. getClassName(): string;
  47392. }
  47393. }
  47394. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  47395. import { Scene } from "babylonjs/scene";
  47396. import { Color3 } from "babylonjs/Maths/math";
  47397. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47398. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47399. /**
  47400. * The PBR material of BJS following the metal roughness convention.
  47401. *
  47402. * This fits to the PBR convention in the GLTF definition:
  47403. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  47404. */
  47405. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  47406. /**
  47407. * The base color has two different interpretations depending on the value of metalness.
  47408. * When the material is a metal, the base color is the specific measured reflectance value
  47409. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  47410. * of the material.
  47411. */
  47412. baseColor: Color3;
  47413. /**
  47414. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  47415. * well as opacity information in the alpha channel.
  47416. */
  47417. baseTexture: BaseTexture;
  47418. /**
  47419. * Specifies the metallic scalar value of the material.
  47420. * Can also be used to scale the metalness values of the metallic texture.
  47421. */
  47422. metallic: number;
  47423. /**
  47424. * Specifies the roughness scalar value of the material.
  47425. * Can also be used to scale the roughness values of the metallic texture.
  47426. */
  47427. roughness: number;
  47428. /**
  47429. * Texture containing both the metallic value in the B channel and the
  47430. * roughness value in the G channel to keep better precision.
  47431. */
  47432. metallicRoughnessTexture: BaseTexture;
  47433. /**
  47434. * Instantiates a new PBRMetalRoughnessMaterial instance.
  47435. *
  47436. * @param name The material name
  47437. * @param scene The scene the material will be use in.
  47438. */
  47439. constructor(name: string, scene: Scene);
  47440. /**
  47441. * Return the currrent class name of the material.
  47442. */
  47443. getClassName(): string;
  47444. /**
  47445. * Return the active textures of the material.
  47446. */
  47447. getActiveTextures(): BaseTexture[];
  47448. /**
  47449. * Checks to see if a texture is used in the material.
  47450. * @param texture - Base texture to use.
  47451. * @returns - Boolean specifying if a texture is used in the material.
  47452. */
  47453. hasTexture(texture: BaseTexture): boolean;
  47454. /**
  47455. * Makes a duplicate of the current material.
  47456. * @param name - name to use for the new material.
  47457. */
  47458. clone(name: string): PBRMetallicRoughnessMaterial;
  47459. /**
  47460. * Serialize the material to a parsable JSON object.
  47461. */
  47462. serialize(): any;
  47463. /**
  47464. * Parses a JSON object correponding to the serialize function.
  47465. */
  47466. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  47467. }
  47468. }
  47469. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  47470. import { Scene } from "babylonjs/scene";
  47471. import { Color3 } from "babylonjs/Maths/math";
  47472. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47473. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47474. /**
  47475. * The PBR material of BJS following the specular glossiness convention.
  47476. *
  47477. * This fits to the PBR convention in the GLTF definition:
  47478. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  47479. */
  47480. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  47481. /**
  47482. * Specifies the diffuse color of the material.
  47483. */
  47484. diffuseColor: Color3;
  47485. /**
  47486. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  47487. * channel.
  47488. */
  47489. diffuseTexture: BaseTexture;
  47490. /**
  47491. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  47492. */
  47493. specularColor: Color3;
  47494. /**
  47495. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  47496. */
  47497. glossiness: number;
  47498. /**
  47499. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  47500. */
  47501. specularGlossinessTexture: BaseTexture;
  47502. /**
  47503. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  47504. *
  47505. * @param name The material name
  47506. * @param scene The scene the material will be use in.
  47507. */
  47508. constructor(name: string, scene: Scene);
  47509. /**
  47510. * Return the currrent class name of the material.
  47511. */
  47512. getClassName(): string;
  47513. /**
  47514. * Return the active textures of the material.
  47515. */
  47516. getActiveTextures(): BaseTexture[];
  47517. /**
  47518. * Checks to see if a texture is used in the material.
  47519. * @param texture - Base texture to use.
  47520. * @returns - Boolean specifying if a texture is used in the material.
  47521. */
  47522. hasTexture(texture: BaseTexture): boolean;
  47523. /**
  47524. * Makes a duplicate of the current material.
  47525. * @param name - name to use for the new material.
  47526. */
  47527. clone(name: string): PBRSpecularGlossinessMaterial;
  47528. /**
  47529. * Serialize the material to a parsable JSON object.
  47530. */
  47531. serialize(): any;
  47532. /**
  47533. * Parses a JSON object correponding to the serialize function.
  47534. */
  47535. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  47536. }
  47537. }
  47538. declare module "babylonjs/Materials/PBR/index" {
  47539. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47540. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47541. export * from "babylonjs/Materials/PBR/pbrMaterial";
  47542. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  47543. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  47544. }
  47545. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  47546. import { Nullable } from "babylonjs/types";
  47547. import { Scene } from "babylonjs/scene";
  47548. import { Matrix } from "babylonjs/Maths/math";
  47549. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47550. /**
  47551. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  47552. * It can help converting any input color in a desired output one. This can then be used to create effects
  47553. * from sepia, black and white to sixties or futuristic rendering...
  47554. *
  47555. * The only supported format is currently 3dl.
  47556. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  47557. */
  47558. export class ColorGradingTexture extends BaseTexture {
  47559. /**
  47560. * The current texture matrix. (will always be identity in color grading texture)
  47561. */
  47562. private _textureMatrix;
  47563. /**
  47564. * The texture URL.
  47565. */
  47566. url: string;
  47567. /**
  47568. * Empty line regex stored for GC.
  47569. */
  47570. private static _noneEmptyLineRegex;
  47571. private _engine;
  47572. /**
  47573. * Instantiates a ColorGradingTexture from the following parameters.
  47574. *
  47575. * @param url The location of the color gradind data (currently only supporting 3dl)
  47576. * @param scene The scene the texture will be used in
  47577. */
  47578. constructor(url: string, scene: Scene);
  47579. /**
  47580. * Returns the texture matrix used in most of the material.
  47581. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  47582. */
  47583. getTextureMatrix(): Matrix;
  47584. /**
  47585. * Occurs when the file being loaded is a .3dl LUT file.
  47586. */
  47587. private load3dlTexture;
  47588. /**
  47589. * Starts the loading process of the texture.
  47590. */
  47591. private loadTexture;
  47592. /**
  47593. * Clones the color gradind texture.
  47594. */
  47595. clone(): ColorGradingTexture;
  47596. /**
  47597. * Called during delayed load for textures.
  47598. */
  47599. delayLoad(): void;
  47600. /**
  47601. * Parses a color grading texture serialized by Babylon.
  47602. * @param parsedTexture The texture information being parsedTexture
  47603. * @param scene The scene to load the texture in
  47604. * @param rootUrl The root url of the data assets to load
  47605. * @return A color gradind texture
  47606. */
  47607. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  47608. /**
  47609. * Serializes the LUT texture to json format.
  47610. */
  47611. serialize(): any;
  47612. }
  47613. }
  47614. declare module "babylonjs/Misc/dds" {
  47615. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47616. import { Engine } from "babylonjs/Engines/engine";
  47617. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47618. import { Nullable } from "babylonjs/types";
  47619. import { Scene } from "babylonjs/scene";
  47620. /**
  47621. * Direct draw surface info
  47622. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47623. */
  47624. export interface DDSInfo {
  47625. /**
  47626. * Width of the texture
  47627. */
  47628. width: number;
  47629. /**
  47630. * Width of the texture
  47631. */
  47632. height: number;
  47633. /**
  47634. * Number of Mipmaps for the texture
  47635. * @see https://en.wikipedia.org/wiki/Mipmap
  47636. */
  47637. mipmapCount: number;
  47638. /**
  47639. * If the textures format is a known fourCC format
  47640. * @see https://www.fourcc.org/
  47641. */
  47642. isFourCC: boolean;
  47643. /**
  47644. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47645. */
  47646. isRGB: boolean;
  47647. /**
  47648. * If the texture is a lumincance format
  47649. */
  47650. isLuminance: boolean;
  47651. /**
  47652. * If this is a cube texture
  47653. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47654. */
  47655. isCube: boolean;
  47656. /**
  47657. * If the texture is a compressed format eg. FOURCC_DXT1
  47658. */
  47659. isCompressed: boolean;
  47660. /**
  47661. * The dxgiFormat of the texture
  47662. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47663. */
  47664. dxgiFormat: number;
  47665. /**
  47666. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47667. */
  47668. textureType: number;
  47669. /**
  47670. * Sphericle polynomial created for the dds texture
  47671. */
  47672. sphericalPolynomial?: SphericalPolynomial;
  47673. }
  47674. /**
  47675. * Class used to provide DDS decompression tools
  47676. */
  47677. export class DDSTools {
  47678. /**
  47679. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47680. */
  47681. static StoreLODInAlphaChannel: boolean;
  47682. /**
  47683. * Gets DDS information from an array buffer
  47684. * @param arrayBuffer defines the array buffer to read data from
  47685. * @returns the DDS information
  47686. */
  47687. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47688. private static _FloatView;
  47689. private static _Int32View;
  47690. private static _ToHalfFloat;
  47691. private static _FromHalfFloat;
  47692. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47693. private static _GetHalfFloatRGBAArrayBuffer;
  47694. private static _GetFloatRGBAArrayBuffer;
  47695. private static _GetFloatAsUIntRGBAArrayBuffer;
  47696. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47697. private static _GetRGBAArrayBuffer;
  47698. private static _ExtractLongWordOrder;
  47699. private static _GetRGBArrayBuffer;
  47700. private static _GetLuminanceArrayBuffer;
  47701. /**
  47702. * Uploads DDS Levels to a Babylon Texture
  47703. * @hidden
  47704. */
  47705. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47706. }
  47707. module "babylonjs/Engines/engine" {
  47708. interface Engine {
  47709. /**
  47710. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47711. * @param rootUrl defines the url where the file to load is located
  47712. * @param scene defines the current scene
  47713. * @param lodScale defines scale to apply to the mip map selection
  47714. * @param lodOffset defines offset to apply to the mip map selection
  47715. * @param onLoad defines an optional callback raised when the texture is loaded
  47716. * @param onError defines an optional callback raised if there is an issue to load the texture
  47717. * @param format defines the format of the data
  47718. * @param forcedExtension defines the extension to use to pick the right loader
  47719. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47720. * @returns the cube texture as an InternalTexture
  47721. */
  47722. 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;
  47723. }
  47724. }
  47725. }
  47726. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47727. import { Nullable } from "babylonjs/types";
  47728. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47729. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47730. /**
  47731. * Implementation of the DDS Texture Loader.
  47732. * @hidden
  47733. */
  47734. export class _DDSTextureLoader implements IInternalTextureLoader {
  47735. /**
  47736. * Defines wether the loader supports cascade loading the different faces.
  47737. */
  47738. readonly supportCascades: boolean;
  47739. /**
  47740. * This returns if the loader support the current file information.
  47741. * @param extension defines the file extension of the file being loaded
  47742. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47743. * @param fallback defines the fallback internal texture if any
  47744. * @param isBase64 defines whether the texture is encoded as a base64
  47745. * @param isBuffer defines whether the texture data are stored as a buffer
  47746. * @returns true if the loader can load the specified file
  47747. */
  47748. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47749. /**
  47750. * Transform the url before loading if required.
  47751. * @param rootUrl the url of the texture
  47752. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47753. * @returns the transformed texture
  47754. */
  47755. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47756. /**
  47757. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47758. * @param rootUrl the url of the texture
  47759. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47760. * @returns the fallback texture
  47761. */
  47762. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47763. /**
  47764. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47765. * @param data contains the texture data
  47766. * @param texture defines the BabylonJS internal texture
  47767. * @param createPolynomials will be true if polynomials have been requested
  47768. * @param onLoad defines the callback to trigger once the texture is ready
  47769. * @param onError defines the callback to trigger in case of error
  47770. */
  47771. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47772. /**
  47773. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47774. * @param data contains the texture data
  47775. * @param texture defines the BabylonJS internal texture
  47776. * @param callback defines the method to call once ready to upload
  47777. */
  47778. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47779. }
  47780. }
  47781. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47782. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47783. /** @hidden */
  47784. export var rgbdEncodePixelShader: {
  47785. name: string;
  47786. shader: string;
  47787. };
  47788. }
  47789. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47790. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47791. /** @hidden */
  47792. export var rgbdDecodePixelShader: {
  47793. name: string;
  47794. shader: string;
  47795. };
  47796. }
  47797. declare module "babylonjs/Misc/environmentTextureTools" {
  47798. import { Nullable } from "babylonjs/types";
  47799. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47800. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47801. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47802. import "babylonjs/Shaders/rgbdEncode.fragment";
  47803. import "babylonjs/Shaders/rgbdDecode.fragment";
  47804. /**
  47805. * Raw texture data and descriptor sufficient for WebGL texture upload
  47806. */
  47807. export interface EnvironmentTextureInfo {
  47808. /**
  47809. * Version of the environment map
  47810. */
  47811. version: number;
  47812. /**
  47813. * Width of image
  47814. */
  47815. width: number;
  47816. /**
  47817. * Irradiance information stored in the file.
  47818. */
  47819. irradiance: any;
  47820. /**
  47821. * Specular information stored in the file.
  47822. */
  47823. specular: any;
  47824. }
  47825. /**
  47826. * Sets of helpers addressing the serialization and deserialization of environment texture
  47827. * stored in a BabylonJS env file.
  47828. * Those files are usually stored as .env files.
  47829. */
  47830. export class EnvironmentTextureTools {
  47831. /**
  47832. * Magic number identifying the env file.
  47833. */
  47834. private static _MagicBytes;
  47835. /**
  47836. * Gets the environment info from an env file.
  47837. * @param data The array buffer containing the .env bytes.
  47838. * @returns the environment file info (the json header) if successfully parsed.
  47839. */
  47840. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47841. /**
  47842. * Creates an environment texture from a loaded cube texture.
  47843. * @param texture defines the cube texture to convert in env file
  47844. * @return a promise containing the environment data if succesfull.
  47845. */
  47846. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47847. /**
  47848. * Creates a JSON representation of the spherical data.
  47849. * @param texture defines the texture containing the polynomials
  47850. * @return the JSON representation of the spherical info
  47851. */
  47852. private static _CreateEnvTextureIrradiance;
  47853. /**
  47854. * Uploads the texture info contained in the env file to the GPU.
  47855. * @param texture defines the internal texture to upload to
  47856. * @param arrayBuffer defines the buffer cotaining the data to load
  47857. * @param info defines the texture info retrieved through the GetEnvInfo method
  47858. * @returns a promise
  47859. */
  47860. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47861. /**
  47862. * Uploads the levels of image data to the GPU.
  47863. * @param texture defines the internal texture to upload to
  47864. * @param imageData defines the array buffer views of image data [mipmap][face]
  47865. * @returns a promise
  47866. */
  47867. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47868. /**
  47869. * Uploads spherical polynomials information to the texture.
  47870. * @param texture defines the texture we are trying to upload the information to
  47871. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47872. */
  47873. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47874. /** @hidden */
  47875. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47876. }
  47877. }
  47878. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  47879. import { Nullable } from "babylonjs/types";
  47880. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47881. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47882. /**
  47883. * Implementation of the ENV Texture Loader.
  47884. * @hidden
  47885. */
  47886. export class _ENVTextureLoader implements IInternalTextureLoader {
  47887. /**
  47888. * Defines wether the loader supports cascade loading the different faces.
  47889. */
  47890. readonly supportCascades: boolean;
  47891. /**
  47892. * This returns if the loader support the current file information.
  47893. * @param extension defines the file extension of the file being loaded
  47894. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47895. * @param fallback defines the fallback internal texture if any
  47896. * @param isBase64 defines whether the texture is encoded as a base64
  47897. * @param isBuffer defines whether the texture data are stored as a buffer
  47898. * @returns true if the loader can load the specified file
  47899. */
  47900. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47901. /**
  47902. * Transform the url before loading if required.
  47903. * @param rootUrl the url of the texture
  47904. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47905. * @returns the transformed texture
  47906. */
  47907. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47908. /**
  47909. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47910. * @param rootUrl the url of the texture
  47911. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47912. * @returns the fallback texture
  47913. */
  47914. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47915. /**
  47916. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47917. * @param data contains the texture data
  47918. * @param texture defines the BabylonJS internal texture
  47919. * @param createPolynomials will be true if polynomials have been requested
  47920. * @param onLoad defines the callback to trigger once the texture is ready
  47921. * @param onError defines the callback to trigger in case of error
  47922. */
  47923. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47924. /**
  47925. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47926. * @param data contains the texture data
  47927. * @param texture defines the BabylonJS internal texture
  47928. * @param callback defines the method to call once ready to upload
  47929. */
  47930. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47931. }
  47932. }
  47933. declare module "babylonjs/Misc/khronosTextureContainer" {
  47934. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47935. /**
  47936. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47937. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47938. */
  47939. export class KhronosTextureContainer {
  47940. /** contents of the KTX container file */
  47941. arrayBuffer: any;
  47942. private static HEADER_LEN;
  47943. private static COMPRESSED_2D;
  47944. private static COMPRESSED_3D;
  47945. private static TEX_2D;
  47946. private static TEX_3D;
  47947. /**
  47948. * Gets the openGL type
  47949. */
  47950. glType: number;
  47951. /**
  47952. * Gets the openGL type size
  47953. */
  47954. glTypeSize: number;
  47955. /**
  47956. * Gets the openGL format
  47957. */
  47958. glFormat: number;
  47959. /**
  47960. * Gets the openGL internal format
  47961. */
  47962. glInternalFormat: number;
  47963. /**
  47964. * Gets the base internal format
  47965. */
  47966. glBaseInternalFormat: number;
  47967. /**
  47968. * Gets image width in pixel
  47969. */
  47970. pixelWidth: number;
  47971. /**
  47972. * Gets image height in pixel
  47973. */
  47974. pixelHeight: number;
  47975. /**
  47976. * Gets image depth in pixels
  47977. */
  47978. pixelDepth: number;
  47979. /**
  47980. * Gets the number of array elements
  47981. */
  47982. numberOfArrayElements: number;
  47983. /**
  47984. * Gets the number of faces
  47985. */
  47986. numberOfFaces: number;
  47987. /**
  47988. * Gets the number of mipmap levels
  47989. */
  47990. numberOfMipmapLevels: number;
  47991. /**
  47992. * Gets the bytes of key value data
  47993. */
  47994. bytesOfKeyValueData: number;
  47995. /**
  47996. * Gets the load type
  47997. */
  47998. loadType: number;
  47999. /**
  48000. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48001. */
  48002. isInvalid: boolean;
  48003. /**
  48004. * Creates a new KhronosTextureContainer
  48005. * @param arrayBuffer contents of the KTX container file
  48006. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48007. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48008. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48009. */
  48010. constructor(
  48011. /** contents of the KTX container file */
  48012. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48013. /**
  48014. * Uploads KTX content to a Babylon Texture.
  48015. * It is assumed that the texture has already been created & is currently bound
  48016. * @hidden
  48017. */
  48018. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48019. private _upload2DCompressedLevels;
  48020. }
  48021. }
  48022. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48023. import { Nullable } from "babylonjs/types";
  48024. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48025. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48026. /**
  48027. * Implementation of the KTX Texture Loader.
  48028. * @hidden
  48029. */
  48030. export class _KTXTextureLoader implements IInternalTextureLoader {
  48031. /**
  48032. * Defines wether the loader supports cascade loading the different faces.
  48033. */
  48034. readonly supportCascades: boolean;
  48035. /**
  48036. * This returns if the loader support the current file information.
  48037. * @param extension defines the file extension of the file being loaded
  48038. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48039. * @param fallback defines the fallback internal texture if any
  48040. * @param isBase64 defines whether the texture is encoded as a base64
  48041. * @param isBuffer defines whether the texture data are stored as a buffer
  48042. * @returns true if the loader can load the specified file
  48043. */
  48044. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48045. /**
  48046. * Transform the url before loading if required.
  48047. * @param rootUrl the url of the texture
  48048. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48049. * @returns the transformed texture
  48050. */
  48051. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48052. /**
  48053. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48054. * @param rootUrl the url of the texture
  48055. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48056. * @returns the fallback texture
  48057. */
  48058. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48059. /**
  48060. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48061. * @param data contains the texture data
  48062. * @param texture defines the BabylonJS internal texture
  48063. * @param createPolynomials will be true if polynomials have been requested
  48064. * @param onLoad defines the callback to trigger once the texture is ready
  48065. * @param onError defines the callback to trigger in case of error
  48066. */
  48067. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48068. /**
  48069. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48070. * @param data contains the texture data
  48071. * @param texture defines the BabylonJS internal texture
  48072. * @param callback defines the method to call once ready to upload
  48073. */
  48074. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48075. }
  48076. }
  48077. declare module "babylonjs/Misc/tga" {
  48078. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48079. /**
  48080. * Based on jsTGALoader - Javascript loader for TGA file
  48081. * By Vincent Thibault
  48082. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48083. */
  48084. export class TGATools {
  48085. private static _TYPE_INDEXED;
  48086. private static _TYPE_RGB;
  48087. private static _TYPE_GREY;
  48088. private static _TYPE_RLE_INDEXED;
  48089. private static _TYPE_RLE_RGB;
  48090. private static _TYPE_RLE_GREY;
  48091. private static _ORIGIN_MASK;
  48092. private static _ORIGIN_SHIFT;
  48093. private static _ORIGIN_BL;
  48094. private static _ORIGIN_BR;
  48095. private static _ORIGIN_UL;
  48096. private static _ORIGIN_UR;
  48097. /**
  48098. * Gets the header of a TGA file
  48099. * @param data defines the TGA data
  48100. * @returns the header
  48101. */
  48102. static GetTGAHeader(data: Uint8Array): any;
  48103. /**
  48104. * Uploads TGA content to a Babylon Texture
  48105. * @hidden
  48106. */
  48107. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48108. /** @hidden */
  48109. 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;
  48110. /** @hidden */
  48111. 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;
  48112. /** @hidden */
  48113. 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;
  48114. /** @hidden */
  48115. 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;
  48116. /** @hidden */
  48117. 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;
  48118. /** @hidden */
  48119. 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;
  48120. }
  48121. }
  48122. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  48123. import { Nullable } from "babylonjs/types";
  48124. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48125. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48126. /**
  48127. * Implementation of the TGA Texture Loader.
  48128. * @hidden
  48129. */
  48130. export class _TGATextureLoader implements IInternalTextureLoader {
  48131. /**
  48132. * Defines wether the loader supports cascade loading the different faces.
  48133. */
  48134. readonly supportCascades: boolean;
  48135. /**
  48136. * This returns if the loader support the current file information.
  48137. * @param extension defines the file extension of the file being loaded
  48138. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48139. * @param fallback defines the fallback internal texture if any
  48140. * @param isBase64 defines whether the texture is encoded as a base64
  48141. * @param isBuffer defines whether the texture data are stored as a buffer
  48142. * @returns true if the loader can load the specified file
  48143. */
  48144. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48145. /**
  48146. * Transform the url before loading if required.
  48147. * @param rootUrl the url of the texture
  48148. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48149. * @returns the transformed texture
  48150. */
  48151. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48152. /**
  48153. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48154. * @param rootUrl the url of the texture
  48155. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48156. * @returns the fallback texture
  48157. */
  48158. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48159. /**
  48160. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48161. * @param data contains the texture data
  48162. * @param texture defines the BabylonJS internal texture
  48163. * @param createPolynomials will be true if polynomials have been requested
  48164. * @param onLoad defines the callback to trigger once the texture is ready
  48165. * @param onError defines the callback to trigger in case of error
  48166. */
  48167. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48168. /**
  48169. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48170. * @param data contains the texture data
  48171. * @param texture defines the BabylonJS internal texture
  48172. * @param callback defines the method to call once ready to upload
  48173. */
  48174. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48175. }
  48176. }
  48177. declare module "babylonjs/Materials/Textures/Loaders/index" {
  48178. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48179. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48180. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48181. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  48182. }
  48183. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  48184. import { Scene } from "babylonjs/scene";
  48185. import { Texture } from "babylonjs/Materials/Textures/texture";
  48186. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48187. /**
  48188. * 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.
  48189. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48190. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48191. */
  48192. export class CustomProceduralTexture extends ProceduralTexture {
  48193. private _animate;
  48194. private _time;
  48195. private _config;
  48196. private _texturePath;
  48197. /**
  48198. * Instantiates a new Custom Procedural Texture.
  48199. * 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.
  48200. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48201. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48202. * @param name Define the name of the texture
  48203. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48204. * @param size Define the size of the texture to create
  48205. * @param scene Define the scene the texture belongs to
  48206. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48207. * @param generateMipMaps Define if the texture should creates mip maps or not
  48208. */
  48209. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48210. private _loadJson;
  48211. /**
  48212. * Is the texture ready to be used ? (rendered at least once)
  48213. * @returns true if ready, otherwise, false.
  48214. */
  48215. isReady(): boolean;
  48216. /**
  48217. * Render the texture to its associated render target.
  48218. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48219. */
  48220. render(useCameraPostProcess?: boolean): void;
  48221. /**
  48222. * Update the list of dependant textures samplers in the shader.
  48223. */
  48224. updateTextures(): void;
  48225. /**
  48226. * Update the uniform values of the procedural texture in the shader.
  48227. */
  48228. updateShaderUniforms(): void;
  48229. /**
  48230. * Define if the texture animates or not.
  48231. */
  48232. animate: boolean;
  48233. }
  48234. }
  48235. declare module "babylonjs/Shaders/noise.fragment" {
  48236. /** @hidden */
  48237. export var noisePixelShader: {
  48238. name: string;
  48239. shader: string;
  48240. };
  48241. }
  48242. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  48243. import { Nullable } from "babylonjs/types";
  48244. import { Scene } from "babylonjs/scene";
  48245. import { Texture } from "babylonjs/Materials/Textures/texture";
  48246. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48247. import "babylonjs/Shaders/noise.fragment";
  48248. /**
  48249. * Class used to generate noise procedural textures
  48250. */
  48251. export class NoiseProceduralTexture extends ProceduralTexture {
  48252. private _time;
  48253. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48254. brightness: number;
  48255. /** Defines the number of octaves to process */
  48256. octaves: number;
  48257. /** Defines the level of persistence (0.8 by default) */
  48258. persistence: number;
  48259. /** Gets or sets animation speed factor (default is 1) */
  48260. animationSpeedFactor: number;
  48261. /**
  48262. * Creates a new NoiseProceduralTexture
  48263. * @param name defines the name fo the texture
  48264. * @param size defines the size of the texture (default is 256)
  48265. * @param scene defines the hosting scene
  48266. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48267. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48268. */
  48269. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48270. private _updateShaderUniforms;
  48271. protected _getDefines(): string;
  48272. /** Generate the current state of the procedural texture */
  48273. render(useCameraPostProcess?: boolean): void;
  48274. /**
  48275. * Serializes this noise procedural texture
  48276. * @returns a serialized noise procedural texture object
  48277. */
  48278. serialize(): any;
  48279. /**
  48280. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48281. * @param parsedTexture defines parsed texture data
  48282. * @param scene defines the current scene
  48283. * @param rootUrl defines the root URL containing noise procedural texture information
  48284. * @returns a parsed NoiseProceduralTexture
  48285. */
  48286. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48287. }
  48288. }
  48289. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  48290. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  48291. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  48292. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48293. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  48294. }
  48295. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  48296. import { Nullable } from "babylonjs/types";
  48297. import { Scene } from "babylonjs/scene";
  48298. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48299. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48300. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48301. /**
  48302. * Raw cube texture where the raw buffers are passed in
  48303. */
  48304. export class RawCubeTexture extends CubeTexture {
  48305. /**
  48306. * Creates a cube texture where the raw buffers are passed in.
  48307. * @param scene defines the scene the texture is attached to
  48308. * @param data defines the array of data to use to create each face
  48309. * @param size defines the size of the textures
  48310. * @param format defines the format of the data
  48311. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48312. * @param generateMipMaps defines if the engine should generate the mip levels
  48313. * @param invertY defines if data must be stored with Y axis inverted
  48314. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48315. * @param compression defines the compression used (null by default)
  48316. */
  48317. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48318. /**
  48319. * Updates the raw cube texture.
  48320. * @param data defines the data to store
  48321. * @param format defines the data format
  48322. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48323. * @param invertY defines if data must be stored with Y axis inverted
  48324. * @param compression defines the compression used (null by default)
  48325. * @param level defines which level of the texture to update
  48326. */
  48327. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48328. /**
  48329. * Updates a raw cube texture with RGBD encoded data.
  48330. * @param data defines the array of data [mipmap][face] to use to create each face
  48331. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48332. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48333. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48334. * @returns a promsie that resolves when the operation is complete
  48335. */
  48336. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48337. /**
  48338. * Clones the raw cube texture.
  48339. * @return a new cube texture
  48340. */
  48341. clone(): CubeTexture;
  48342. /** @hidden */
  48343. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48344. }
  48345. }
  48346. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  48347. import { Scene } from "babylonjs/scene";
  48348. import { Texture } from "babylonjs/Materials/Textures/texture";
  48349. /**
  48350. * Class used to store 3D textures containing user data
  48351. */
  48352. export class RawTexture3D extends Texture {
  48353. /** Gets or sets the texture format to use */
  48354. format: number;
  48355. private _engine;
  48356. /**
  48357. * Create a new RawTexture3D
  48358. * @param data defines the data of the texture
  48359. * @param width defines the width of the texture
  48360. * @param height defines the height of the texture
  48361. * @param depth defines the depth of the texture
  48362. * @param format defines the texture format to use
  48363. * @param scene defines the hosting scene
  48364. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48365. * @param invertY defines if texture must be stored with Y axis inverted
  48366. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48367. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48368. */
  48369. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48370. /** Gets or sets the texture format to use */
  48371. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48372. /**
  48373. * Update the texture with new data
  48374. * @param data defines the data to store in the texture
  48375. */
  48376. update(data: ArrayBufferView): void;
  48377. }
  48378. }
  48379. declare module "babylonjs/Materials/Textures/refractionTexture" {
  48380. import { Scene } from "babylonjs/scene";
  48381. import { Plane } from "babylonjs/Maths/math";
  48382. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48383. /**
  48384. * Creates a refraction texture used by refraction channel of the standard material.
  48385. * It is like a mirror but to see through a material.
  48386. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48387. */
  48388. export class RefractionTexture extends RenderTargetTexture {
  48389. /**
  48390. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48391. * 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.
  48392. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48393. */
  48394. refractionPlane: Plane;
  48395. /**
  48396. * Define how deep under the surface we should see.
  48397. */
  48398. depth: number;
  48399. /**
  48400. * Creates a refraction texture used by refraction channel of the standard material.
  48401. * It is like a mirror but to see through a material.
  48402. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48403. * @param name Define the texture name
  48404. * @param size Define the size of the underlying texture
  48405. * @param scene Define the scene the refraction belongs to
  48406. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48407. */
  48408. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48409. /**
  48410. * Clone the refraction texture.
  48411. * @returns the cloned texture
  48412. */
  48413. clone(): RefractionTexture;
  48414. /**
  48415. * Serialize the texture to a JSON representation you could use in Parse later on
  48416. * @returns the serialized JSON representation
  48417. */
  48418. serialize(): any;
  48419. }
  48420. }
  48421. declare module "babylonjs/Materials/Textures/index" {
  48422. export * from "babylonjs/Materials/Textures/baseTexture";
  48423. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  48424. export * from "babylonjs/Materials/Textures/cubeTexture";
  48425. export * from "babylonjs/Materials/Textures/dynamicTexture";
  48426. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  48427. export * from "babylonjs/Materials/Textures/internalTexture";
  48428. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  48429. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  48430. export * from "babylonjs/Materials/Textures/Loaders/index";
  48431. export * from "babylonjs/Materials/Textures/mirrorTexture";
  48432. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  48433. export * from "babylonjs/Materials/Textures/Procedurals/index";
  48434. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  48435. export * from "babylonjs/Materials/Textures/rawTexture";
  48436. export * from "babylonjs/Materials/Textures/rawTexture3D";
  48437. export * from "babylonjs/Materials/Textures/refractionTexture";
  48438. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  48439. export * from "babylonjs/Materials/Textures/texture";
  48440. export * from "babylonjs/Materials/Textures/videoTexture";
  48441. }
  48442. declare module "babylonjs/Materials/index" {
  48443. export * from "babylonjs/Materials/Background/index";
  48444. export * from "babylonjs/Materials/colorCurves";
  48445. export * from "babylonjs/Materials/effect";
  48446. export * from "babylonjs/Materials/fresnelParameters";
  48447. export * from "babylonjs/Materials/imageProcessingConfiguration";
  48448. export * from "babylonjs/Materials/material";
  48449. export * from "babylonjs/Materials/materialDefines";
  48450. export * from "babylonjs/Materials/materialHelper";
  48451. export * from "babylonjs/Materials/multiMaterial";
  48452. export * from "babylonjs/Materials/PBR/index";
  48453. export * from "babylonjs/Materials/pushMaterial";
  48454. export * from "babylonjs/Materials/shaderMaterial";
  48455. export * from "babylonjs/Materials/standardMaterial";
  48456. export * from "babylonjs/Materials/Textures/index";
  48457. export * from "babylonjs/Materials/uniformBuffer";
  48458. export * from "babylonjs/Materials/materialFlags";
  48459. }
  48460. declare module "babylonjs/Maths/index" {
  48461. export * from "babylonjs/Maths/math.scalar";
  48462. export * from "babylonjs/Maths/math";
  48463. export * from "babylonjs/Maths/sphericalPolynomial";
  48464. }
  48465. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  48466. import { IDisposable } from "babylonjs/scene";
  48467. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  48468. /**
  48469. * Configuration for Draco compression
  48470. */
  48471. export interface IDracoCompressionConfiguration {
  48472. /**
  48473. * Configuration for the decoder.
  48474. */
  48475. decoder?: {
  48476. /**
  48477. * The url to the WebAssembly module.
  48478. */
  48479. wasmUrl?: string;
  48480. /**
  48481. * The url to the WebAssembly binary.
  48482. */
  48483. wasmBinaryUrl?: string;
  48484. /**
  48485. * The url to the fallback JavaScript module.
  48486. */
  48487. fallbackUrl?: string;
  48488. };
  48489. }
  48490. /**
  48491. * Draco compression (https://google.github.io/draco/)
  48492. *
  48493. * This class wraps the Draco module.
  48494. *
  48495. * **Encoder**
  48496. *
  48497. * The encoder is not currently implemented.
  48498. *
  48499. * **Decoder**
  48500. *
  48501. * 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.
  48502. *
  48503. * To update the configuration, use the following code:
  48504. * ```javascript
  48505. * DracoCompression.Configuration = {
  48506. * decoder: {
  48507. * wasmUrl: "<url to the WebAssembly library>",
  48508. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48509. * fallbackUrl: "<url to the fallback JavaScript library>",
  48510. * }
  48511. * };
  48512. * ```
  48513. *
  48514. * 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.
  48515. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48516. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48517. *
  48518. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48519. * ```javascript
  48520. * var dracoCompression = new DracoCompression();
  48521. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48522. * [VertexBuffer.PositionKind]: 0
  48523. * });
  48524. * ```
  48525. *
  48526. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48527. */
  48528. export class DracoCompression implements IDisposable {
  48529. private static _DecoderModulePromise;
  48530. /**
  48531. * The configuration. Defaults to the following urls:
  48532. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48533. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48534. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48535. */
  48536. static Configuration: IDracoCompressionConfiguration;
  48537. /**
  48538. * Returns true if the decoder is available.
  48539. */
  48540. static readonly DecoderAvailable: boolean;
  48541. /**
  48542. * Constructor
  48543. */
  48544. constructor();
  48545. /**
  48546. * Stop all async operations and release resources.
  48547. */
  48548. dispose(): void;
  48549. /**
  48550. * Decode Draco compressed mesh data to vertex data.
  48551. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48552. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48553. * @returns A promise that resolves with the decoded vertex data
  48554. */
  48555. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48556. [kind: string]: number;
  48557. }): Promise<VertexData>;
  48558. private static _GetDecoderModule;
  48559. private static _LoadScriptAsync;
  48560. private static _LoadFileAsync;
  48561. }
  48562. }
  48563. declare module "babylonjs/Meshes/Compression/index" {
  48564. export * from "babylonjs/Meshes/Compression/dracoCompression";
  48565. }
  48566. declare module "babylonjs/Meshes/csg" {
  48567. import { Nullable } from "babylonjs/types";
  48568. import { Scene } from "babylonjs/scene";
  48569. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  48570. import { Mesh } from "babylonjs/Meshes/mesh";
  48571. import { Material } from "babylonjs/Materials/material";
  48572. /**
  48573. * Class for building Constructive Solid Geometry
  48574. */
  48575. export class CSG {
  48576. private polygons;
  48577. /**
  48578. * The world matrix
  48579. */
  48580. matrix: Matrix;
  48581. /**
  48582. * Stores the position
  48583. */
  48584. position: Vector3;
  48585. /**
  48586. * Stores the rotation
  48587. */
  48588. rotation: Vector3;
  48589. /**
  48590. * Stores the rotation quaternion
  48591. */
  48592. rotationQuaternion: Nullable<Quaternion>;
  48593. /**
  48594. * Stores the scaling vector
  48595. */
  48596. scaling: Vector3;
  48597. /**
  48598. * Convert the Mesh to CSG
  48599. * @param mesh The Mesh to convert to CSG
  48600. * @returns A new CSG from the Mesh
  48601. */
  48602. static FromMesh(mesh: Mesh): CSG;
  48603. /**
  48604. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  48605. * @param polygons Polygons used to construct a CSG solid
  48606. */
  48607. private static FromPolygons;
  48608. /**
  48609. * Clones, or makes a deep copy, of the CSG
  48610. * @returns A new CSG
  48611. */
  48612. clone(): CSG;
  48613. /**
  48614. * Unions this CSG with another CSG
  48615. * @param csg The CSG to union against this CSG
  48616. * @returns The unioned CSG
  48617. */
  48618. union(csg: CSG): CSG;
  48619. /**
  48620. * Unions this CSG with another CSG in place
  48621. * @param csg The CSG to union against this CSG
  48622. */
  48623. unionInPlace(csg: CSG): void;
  48624. /**
  48625. * Subtracts this CSG with another CSG
  48626. * @param csg The CSG to subtract against this CSG
  48627. * @returns A new CSG
  48628. */
  48629. subtract(csg: CSG): CSG;
  48630. /**
  48631. * Subtracts this CSG with another CSG in place
  48632. * @param csg The CSG to subtact against this CSG
  48633. */
  48634. subtractInPlace(csg: CSG): void;
  48635. /**
  48636. * Intersect this CSG with another CSG
  48637. * @param csg The CSG to intersect against this CSG
  48638. * @returns A new CSG
  48639. */
  48640. intersect(csg: CSG): CSG;
  48641. /**
  48642. * Intersects this CSG with another CSG in place
  48643. * @param csg The CSG to intersect against this CSG
  48644. */
  48645. intersectInPlace(csg: CSG): void;
  48646. /**
  48647. * Return a new CSG solid with solid and empty space switched. This solid is
  48648. * not modified.
  48649. * @returns A new CSG solid with solid and empty space switched
  48650. */
  48651. inverse(): CSG;
  48652. /**
  48653. * Inverses the CSG in place
  48654. */
  48655. inverseInPlace(): void;
  48656. /**
  48657. * This is used to keep meshes transformations so they can be restored
  48658. * when we build back a Babylon Mesh
  48659. * NB : All CSG operations are performed in world coordinates
  48660. * @param csg The CSG to copy the transform attributes from
  48661. * @returns This CSG
  48662. */
  48663. copyTransformAttributes(csg: CSG): CSG;
  48664. /**
  48665. * Build Raw mesh from CSG
  48666. * Coordinates here are in world space
  48667. * @param name The name of the mesh geometry
  48668. * @param scene The Scene
  48669. * @param keepSubMeshes Specifies if the submeshes should be kept
  48670. * @returns A new Mesh
  48671. */
  48672. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  48673. /**
  48674. * Build Mesh from CSG taking material and transforms into account
  48675. * @param name The name of the Mesh
  48676. * @param material The material of the Mesh
  48677. * @param scene The Scene
  48678. * @param keepSubMeshes Specifies if submeshes should be kept
  48679. * @returns The new Mesh
  48680. */
  48681. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  48682. }
  48683. }
  48684. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  48685. import { Nullable } from "babylonjs/types";
  48686. import { Scene } from "babylonjs/scene";
  48687. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  48688. import { Mesh } from "babylonjs/Meshes/mesh";
  48689. /**
  48690. * Class containing static functions to help procedurally build meshes
  48691. */
  48692. export class RibbonBuilder {
  48693. /**
  48694. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48695. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48696. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48697. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48698. * * 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
  48699. * * 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
  48700. * * 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
  48701. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48702. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48703. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48704. * * 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
  48705. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48706. * * 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
  48707. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48709. * @param name defines the name of the mesh
  48710. * @param options defines the options used to create the mesh
  48711. * @param scene defines the hosting scene
  48712. * @returns the ribbon mesh
  48713. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48714. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48715. */
  48716. static CreateRibbon(name: string, options: {
  48717. pathArray: Vector3[][];
  48718. closeArray?: boolean;
  48719. closePath?: boolean;
  48720. offset?: number;
  48721. updatable?: boolean;
  48722. sideOrientation?: number;
  48723. frontUVs?: Vector4;
  48724. backUVs?: Vector4;
  48725. instance?: Mesh;
  48726. invertUV?: boolean;
  48727. uvs?: Vector2[];
  48728. colors?: Color4[];
  48729. }, scene?: Nullable<Scene>): Mesh;
  48730. }
  48731. }
  48732. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  48733. import { Vector4 } from "babylonjs/Maths/math";
  48734. import { Mesh } from "babylonjs/Meshes/mesh";
  48735. /**
  48736. * Class containing static functions to help procedurally build meshes
  48737. */
  48738. export class TorusKnotBuilder {
  48739. /**
  48740. * Creates a torus knot mesh
  48741. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  48742. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  48743. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  48744. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  48745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48746. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48748. * @param name defines the name of the mesh
  48749. * @param options defines the options used to create the mesh
  48750. * @param scene defines the hosting scene
  48751. * @returns the torus knot mesh
  48752. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  48753. */
  48754. static CreateTorusKnot(name: string, options: {
  48755. radius?: number;
  48756. tube?: number;
  48757. radialSegments?: number;
  48758. tubularSegments?: number;
  48759. p?: number;
  48760. q?: number;
  48761. updatable?: boolean;
  48762. sideOrientation?: number;
  48763. frontUVs?: Vector4;
  48764. backUVs?: Vector4;
  48765. }, scene: any): Mesh;
  48766. }
  48767. }
  48768. declare module "babylonjs/Meshes/polygonMesh" {
  48769. import { Scene } from "babylonjs/scene";
  48770. import { Vector2, Path2 } from "babylonjs/Maths/math";
  48771. import { Mesh } from "babylonjs/Meshes/mesh";
  48772. /**
  48773. * Polygon
  48774. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  48775. */
  48776. export class Polygon {
  48777. /**
  48778. * Creates a rectangle
  48779. * @param xmin bottom X coord
  48780. * @param ymin bottom Y coord
  48781. * @param xmax top X coord
  48782. * @param ymax top Y coord
  48783. * @returns points that make the resulting rectation
  48784. */
  48785. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  48786. /**
  48787. * Creates a circle
  48788. * @param radius radius of circle
  48789. * @param cx scale in x
  48790. * @param cy scale in y
  48791. * @param numberOfSides number of sides that make up the circle
  48792. * @returns points that make the resulting circle
  48793. */
  48794. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  48795. /**
  48796. * Creates a polygon from input string
  48797. * @param input Input polygon data
  48798. * @returns the parsed points
  48799. */
  48800. static Parse(input: string): Vector2[];
  48801. /**
  48802. * Starts building a polygon from x and y coordinates
  48803. * @param x x coordinate
  48804. * @param y y coordinate
  48805. * @returns the started path2
  48806. */
  48807. static StartingAt(x: number, y: number): Path2;
  48808. }
  48809. /**
  48810. * Builds a polygon
  48811. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  48812. */
  48813. export class PolygonMeshBuilder {
  48814. private _points;
  48815. private _outlinepoints;
  48816. private _holes;
  48817. private _name;
  48818. private _scene;
  48819. private _epoints;
  48820. private _eholes;
  48821. private _addToepoint;
  48822. /**
  48823. * Babylon reference to the earcut plugin.
  48824. */
  48825. bjsEarcut: any;
  48826. /**
  48827. * Creates a PolygonMeshBuilder
  48828. * @param name name of the builder
  48829. * @param contours Path of the polygon
  48830. * @param scene scene to add to
  48831. * @param earcutInjection can be used to inject your own earcut reference
  48832. */
  48833. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  48834. /**
  48835. * Adds a whole within the polygon
  48836. * @param hole Array of points defining the hole
  48837. * @returns this
  48838. */
  48839. addHole(hole: Vector2[]): PolygonMeshBuilder;
  48840. /**
  48841. * Creates the polygon
  48842. * @param updatable If the mesh should be updatable
  48843. * @param depth The depth of the mesh created
  48844. * @returns the created mesh
  48845. */
  48846. build(updatable?: boolean, depth?: number): Mesh;
  48847. /**
  48848. * Adds a side to the polygon
  48849. * @param positions points that make the polygon
  48850. * @param normals normals of the polygon
  48851. * @param uvs uvs of the polygon
  48852. * @param indices indices of the polygon
  48853. * @param bounds bounds of the polygon
  48854. * @param points points of the polygon
  48855. * @param depth depth of the polygon
  48856. * @param flip flip of the polygon
  48857. */
  48858. private addSide;
  48859. }
  48860. }
  48861. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  48862. import { Scene } from "babylonjs/scene";
  48863. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  48864. import { Mesh } from "babylonjs/Meshes/mesh";
  48865. /**
  48866. * Class containing static functions to help procedurally build meshes
  48867. */
  48868. export class PolygonBuilder {
  48869. /**
  48870. * Creates a polygon mesh
  48871. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  48872. * * 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
  48873. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  48874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48875. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  48876. * * Remember you can only change the shape positions, not their number when updating a polygon
  48877. * @param name defines the name of the mesh
  48878. * @param options defines the options used to create the mesh
  48879. * @param scene defines the hosting scene
  48880. * @param earcutInjection can be used to inject your own earcut reference
  48881. * @returns the polygon mesh
  48882. */
  48883. static CreatePolygon(name: string, options: {
  48884. shape: Vector3[];
  48885. holes?: Vector3[][];
  48886. depth?: number;
  48887. faceUV?: Vector4[];
  48888. faceColors?: Color4[];
  48889. updatable?: boolean;
  48890. sideOrientation?: number;
  48891. frontUVs?: Vector4;
  48892. backUVs?: Vector4;
  48893. }, scene: Scene, earcutInjection?: any): Mesh;
  48894. /**
  48895. * Creates an extruded polygon mesh, with depth in the Y direction.
  48896. * * 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)
  48897. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48898. * @param name defines the name of the mesh
  48899. * @param options defines the options used to create the mesh
  48900. * @param scene defines the hosting scene
  48901. * @param earcutInjection can be used to inject your own earcut reference
  48902. * @returns the polygon mesh
  48903. */
  48904. static ExtrudePolygon(name: string, options: {
  48905. shape: Vector3[];
  48906. holes?: Vector3[][];
  48907. depth?: number;
  48908. faceUV?: Vector4[];
  48909. faceColors?: Color4[];
  48910. updatable?: boolean;
  48911. sideOrientation?: number;
  48912. frontUVs?: Vector4;
  48913. backUVs?: Vector4;
  48914. }, scene: Scene, earcutInjection?: any): Mesh;
  48915. }
  48916. }
  48917. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  48918. import { Nullable } from "babylonjs/types";
  48919. import { Scene } from "babylonjs/scene";
  48920. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  48921. import { Mesh } from "babylonjs/Meshes/mesh";
  48922. /**
  48923. * Class containing static functions to help procedurally build meshes
  48924. */
  48925. export class ShapeBuilder {
  48926. /**
  48927. * 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.
  48928. * * 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.
  48929. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48930. * * 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.
  48931. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48932. * * 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
  48933. * * 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
  48934. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48936. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48937. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48939. * @param name defines the name of the mesh
  48940. * @param options defines the options used to create the mesh
  48941. * @param scene defines the hosting scene
  48942. * @returns the extruded shape mesh
  48943. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48944. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48945. */
  48946. static ExtrudeShape(name: string, options: {
  48947. shape: Vector3[];
  48948. path: Vector3[];
  48949. scale?: number;
  48950. rotation?: number;
  48951. cap?: number;
  48952. updatable?: boolean;
  48953. sideOrientation?: number;
  48954. frontUVs?: Vector4;
  48955. backUVs?: Vector4;
  48956. instance?: Mesh;
  48957. invertUV?: boolean;
  48958. }, scene?: Nullable<Scene>): Mesh;
  48959. /**
  48960. * Creates an custom extruded shape mesh.
  48961. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48962. * * 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.
  48963. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48964. * * 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
  48965. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48966. * * 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
  48967. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48968. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48969. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48970. * * 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
  48971. * * 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
  48972. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48974. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48975. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48977. * @param name defines the name of the mesh
  48978. * @param options defines the options used to create the mesh
  48979. * @param scene defines the hosting scene
  48980. * @returns the custom extruded shape mesh
  48981. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48982. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48983. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48984. */
  48985. static ExtrudeShapeCustom(name: string, options: {
  48986. shape: Vector3[];
  48987. path: Vector3[];
  48988. scaleFunction?: any;
  48989. rotationFunction?: any;
  48990. ribbonCloseArray?: boolean;
  48991. ribbonClosePath?: boolean;
  48992. cap?: number;
  48993. updatable?: boolean;
  48994. sideOrientation?: number;
  48995. frontUVs?: Vector4;
  48996. backUVs?: Vector4;
  48997. instance?: Mesh;
  48998. invertUV?: boolean;
  48999. }, scene: Scene): Mesh;
  49000. private static _ExtrudeShapeGeneric;
  49001. }
  49002. }
  49003. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  49004. import { Scene } from "babylonjs/scene";
  49005. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49006. import { Mesh } from "babylonjs/Meshes/mesh";
  49007. /**
  49008. * Class containing static functions to help procedurally build meshes
  49009. */
  49010. export class LatheBuilder {
  49011. /**
  49012. * Creates lathe mesh.
  49013. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49014. * * 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
  49015. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49016. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49017. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49018. * * 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
  49019. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49020. * * 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
  49021. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49022. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49023. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49025. * @param name defines the name of the mesh
  49026. * @param options defines the options used to create the mesh
  49027. * @param scene defines the hosting scene
  49028. * @returns the lathe mesh
  49029. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49030. */
  49031. static CreateLathe(name: string, options: {
  49032. shape: Vector3[];
  49033. radius?: number;
  49034. tessellation?: number;
  49035. clip?: number;
  49036. arc?: number;
  49037. closed?: boolean;
  49038. updatable?: boolean;
  49039. sideOrientation?: number;
  49040. frontUVs?: Vector4;
  49041. backUVs?: Vector4;
  49042. cap?: number;
  49043. invertUV?: boolean;
  49044. }, scene: Scene): Mesh;
  49045. }
  49046. }
  49047. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  49048. import { Scene } from "babylonjs/scene";
  49049. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49050. import { Mesh } from "babylonjs/Meshes/mesh";
  49051. /**
  49052. * Class containing static functions to help procedurally build meshes
  49053. */
  49054. export class TubeBuilder {
  49055. /**
  49056. * Creates a tube mesh.
  49057. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49058. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49059. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49060. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49061. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49062. * * 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)
  49063. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49064. * * 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
  49065. * * 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
  49066. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49067. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49068. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49070. * @param name defines the name of the mesh
  49071. * @param options defines the options used to create the mesh
  49072. * @param scene defines the hosting scene
  49073. * @returns the tube mesh
  49074. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49075. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49076. */
  49077. static CreateTube(name: string, options: {
  49078. path: Vector3[];
  49079. radius?: number;
  49080. tessellation?: number;
  49081. radiusFunction?: {
  49082. (i: number, distance: number): number;
  49083. };
  49084. cap?: number;
  49085. arc?: number;
  49086. updatable?: boolean;
  49087. sideOrientation?: number;
  49088. frontUVs?: Vector4;
  49089. backUVs?: Vector4;
  49090. instance?: Mesh;
  49091. invertUV?: boolean;
  49092. }, scene: Scene): Mesh;
  49093. }
  49094. }
  49095. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  49096. import { Scene } from "babylonjs/scene";
  49097. import { Vector4 } from "babylonjs/Maths/math";
  49098. import { Mesh } from "babylonjs/Meshes/mesh";
  49099. /**
  49100. * Class containing static functions to help procedurally build meshes
  49101. */
  49102. export class IcoSphereBuilder {
  49103. /**
  49104. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49105. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49106. * * 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`)
  49107. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49108. * * 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
  49109. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49110. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49112. * @param name defines the name of the mesh
  49113. * @param options defines the options used to create the mesh
  49114. * @param scene defines the hosting scene
  49115. * @returns the icosahedron mesh
  49116. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49117. */
  49118. static CreateIcoSphere(name: string, options: {
  49119. radius?: number;
  49120. radiusX?: number;
  49121. radiusY?: number;
  49122. radiusZ?: number;
  49123. flat?: boolean;
  49124. subdivisions?: number;
  49125. sideOrientation?: number;
  49126. frontUVs?: Vector4;
  49127. backUVs?: Vector4;
  49128. updatable?: boolean;
  49129. }, scene: Scene): Mesh;
  49130. }
  49131. }
  49132. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  49133. import { Vector3 } from "babylonjs/Maths/math";
  49134. import { Mesh } from "babylonjs/Meshes/mesh";
  49135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49136. /**
  49137. * Class containing static functions to help procedurally build meshes
  49138. */
  49139. export class DecalBuilder {
  49140. /**
  49141. * Creates a decal mesh.
  49142. * 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
  49143. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49144. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49145. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49146. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49147. * @param name defines the name of the mesh
  49148. * @param sourceMesh defines the mesh where the decal must be applied
  49149. * @param options defines the options used to create the mesh
  49150. * @param scene defines the hosting scene
  49151. * @returns the decal mesh
  49152. * @see https://doc.babylonjs.com/how_to/decals
  49153. */
  49154. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49155. position?: Vector3;
  49156. normal?: Vector3;
  49157. size?: Vector3;
  49158. angle?: number;
  49159. }): Mesh;
  49160. }
  49161. }
  49162. declare module "babylonjs/Meshes/meshBuilder" {
  49163. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  49164. import { Nullable } from "babylonjs/types";
  49165. import { Scene } from "babylonjs/scene";
  49166. import { Mesh } from "babylonjs/Meshes/mesh";
  49167. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49168. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  49169. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49170. /**
  49171. * Class containing static functions to help procedurally build meshes
  49172. */
  49173. export class MeshBuilder {
  49174. /**
  49175. * Creates a box mesh
  49176. * * The parameter `size` sets the size (float) of each box side (default 1)
  49177. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49178. * * 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)
  49179. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49180. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49181. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49183. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49184. * @param name defines the name of the mesh
  49185. * @param options defines the options used to create the mesh
  49186. * @param scene defines the hosting scene
  49187. * @returns the box mesh
  49188. */
  49189. static CreateBox(name: string, options: {
  49190. size?: number;
  49191. width?: number;
  49192. height?: number;
  49193. depth?: number;
  49194. faceUV?: Vector4[];
  49195. faceColors?: Color4[];
  49196. sideOrientation?: number;
  49197. frontUVs?: Vector4;
  49198. backUVs?: Vector4;
  49199. updatable?: boolean;
  49200. }, scene?: Nullable<Scene>): Mesh;
  49201. /**
  49202. * Creates a sphere mesh
  49203. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49204. * * 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`)
  49205. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49206. * * 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
  49207. * * 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)
  49208. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49209. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49211. * @param name defines the name of the mesh
  49212. * @param options defines the options used to create the mesh
  49213. * @param scene defines the hosting scene
  49214. * @returns the sphere mesh
  49215. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49216. */
  49217. static CreateSphere(name: string, options: {
  49218. segments?: number;
  49219. diameter?: number;
  49220. diameterX?: number;
  49221. diameterY?: number;
  49222. diameterZ?: number;
  49223. arc?: number;
  49224. slice?: number;
  49225. sideOrientation?: number;
  49226. frontUVs?: Vector4;
  49227. backUVs?: Vector4;
  49228. updatable?: boolean;
  49229. }, scene: any): Mesh;
  49230. /**
  49231. * Creates a plane polygonal mesh. By default, this is a disc
  49232. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  49233. * * 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
  49234. * * 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
  49235. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49236. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49238. * @param name defines the name of the mesh
  49239. * @param options defines the options used to create the mesh
  49240. * @param scene defines the hosting scene
  49241. * @returns the plane polygonal mesh
  49242. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  49243. */
  49244. static CreateDisc(name: string, options: {
  49245. radius?: number;
  49246. tessellation?: number;
  49247. arc?: number;
  49248. updatable?: boolean;
  49249. sideOrientation?: number;
  49250. frontUVs?: Vector4;
  49251. backUVs?: Vector4;
  49252. }, scene?: Nullable<Scene>): Mesh;
  49253. /**
  49254. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49255. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49256. * * 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`)
  49257. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49258. * * 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
  49259. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49260. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49262. * @param name defines the name of the mesh
  49263. * @param options defines the options used to create the mesh
  49264. * @param scene defines the hosting scene
  49265. * @returns the icosahedron mesh
  49266. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49267. */
  49268. static CreateIcoSphere(name: string, options: {
  49269. radius?: number;
  49270. radiusX?: number;
  49271. radiusY?: number;
  49272. radiusZ?: number;
  49273. flat?: boolean;
  49274. subdivisions?: number;
  49275. sideOrientation?: number;
  49276. frontUVs?: Vector4;
  49277. backUVs?: Vector4;
  49278. updatable?: boolean;
  49279. }, scene: Scene): Mesh;
  49280. /**
  49281. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49282. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49283. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49284. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49285. * * 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
  49286. * * 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
  49287. * * 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
  49288. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49289. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49290. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49291. * * 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
  49292. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49293. * * 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
  49294. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49296. * @param name defines the name of the mesh
  49297. * @param options defines the options used to create the mesh
  49298. * @param scene defines the hosting scene
  49299. * @returns the ribbon mesh
  49300. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49301. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49302. */
  49303. static CreateRibbon(name: string, options: {
  49304. pathArray: Vector3[][];
  49305. closeArray?: boolean;
  49306. closePath?: boolean;
  49307. offset?: number;
  49308. updatable?: boolean;
  49309. sideOrientation?: number;
  49310. frontUVs?: Vector4;
  49311. backUVs?: Vector4;
  49312. instance?: Mesh;
  49313. invertUV?: boolean;
  49314. uvs?: Vector2[];
  49315. colors?: Color4[];
  49316. }, scene?: Nullable<Scene>): Mesh;
  49317. /**
  49318. * Creates a cylinder or a cone mesh
  49319. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49320. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49321. * * 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.
  49322. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49323. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49324. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49325. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49326. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49327. * * 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).
  49328. * * 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
  49329. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49330. * * 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
  49331. * * 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.
  49332. * * If `enclose` is false, a ring surface is one element.
  49333. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49334. * * 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
  49335. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49336. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49338. * @param name defines the name of the mesh
  49339. * @param options defines the options used to create the mesh
  49340. * @param scene defines the hosting scene
  49341. * @returns the cylinder mesh
  49342. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49343. */
  49344. static CreateCylinder(name: string, options: {
  49345. height?: number;
  49346. diameterTop?: number;
  49347. diameterBottom?: number;
  49348. diameter?: number;
  49349. tessellation?: number;
  49350. subdivisions?: number;
  49351. arc?: number;
  49352. faceColors?: Color4[];
  49353. faceUV?: Vector4[];
  49354. updatable?: boolean;
  49355. hasRings?: boolean;
  49356. enclose?: boolean;
  49357. sideOrientation?: number;
  49358. frontUVs?: Vector4;
  49359. backUVs?: Vector4;
  49360. }, scene: any): Mesh;
  49361. /**
  49362. * Creates a torus mesh
  49363. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49364. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49365. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49367. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49369. * @param name defines the name of the mesh
  49370. * @param options defines the options used to create the mesh
  49371. * @param scene defines the hosting scene
  49372. * @returns the torus mesh
  49373. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49374. */
  49375. static CreateTorus(name: string, options: {
  49376. diameter?: number;
  49377. thickness?: number;
  49378. tessellation?: number;
  49379. updatable?: boolean;
  49380. sideOrientation?: number;
  49381. frontUVs?: Vector4;
  49382. backUVs?: Vector4;
  49383. }, scene: any): Mesh;
  49384. /**
  49385. * Creates a torus knot mesh
  49386. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49387. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49388. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49389. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49391. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49393. * @param name defines the name of the mesh
  49394. * @param options defines the options used to create the mesh
  49395. * @param scene defines the hosting scene
  49396. * @returns the torus knot mesh
  49397. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49398. */
  49399. static CreateTorusKnot(name: string, options: {
  49400. radius?: number;
  49401. tube?: number;
  49402. radialSegments?: number;
  49403. tubularSegments?: number;
  49404. p?: number;
  49405. q?: number;
  49406. updatable?: boolean;
  49407. sideOrientation?: number;
  49408. frontUVs?: Vector4;
  49409. backUVs?: Vector4;
  49410. }, scene: any): Mesh;
  49411. /**
  49412. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49413. * * 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
  49414. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49415. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49416. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49417. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49418. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49419. * * 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
  49420. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49422. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49423. * @param name defines the name of the new line system
  49424. * @param options defines the options used to create the line system
  49425. * @param scene defines the hosting scene
  49426. * @returns a new line system mesh
  49427. */
  49428. static CreateLineSystem(name: string, options: {
  49429. lines: Vector3[][];
  49430. updatable?: boolean;
  49431. instance?: Nullable<LinesMesh>;
  49432. colors?: Nullable<Color4[][]>;
  49433. useVertexAlpha?: boolean;
  49434. }, scene: Nullable<Scene>): LinesMesh;
  49435. /**
  49436. * Creates a line mesh
  49437. * 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
  49438. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49439. * * The parameter `points` is an array successive Vector3
  49440. * * 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
  49441. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49442. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49443. * * When updating an instance, remember that only point positions can change, not the number of points
  49444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49445. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49446. * @param name defines the name of the new line system
  49447. * @param options defines the options used to create the line system
  49448. * @param scene defines the hosting scene
  49449. * @returns a new line mesh
  49450. */
  49451. static CreateLines(name: string, options: {
  49452. points: Vector3[];
  49453. updatable?: boolean;
  49454. instance?: Nullable<LinesMesh>;
  49455. colors?: Color4[];
  49456. useVertexAlpha?: boolean;
  49457. }, scene?: Nullable<Scene>): LinesMesh;
  49458. /**
  49459. * Creates a dashed line mesh
  49460. * * 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
  49461. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49462. * * The parameter `points` is an array successive Vector3
  49463. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49464. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49465. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49466. * * 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
  49467. * * When updating an instance, remember that only point positions can change, not the number of points
  49468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49469. * @param name defines the name of the mesh
  49470. * @param options defines the options used to create the mesh
  49471. * @param scene defines the hosting scene
  49472. * @returns the dashed line mesh
  49473. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49474. */
  49475. static CreateDashedLines(name: string, options: {
  49476. points: Vector3[];
  49477. dashSize?: number;
  49478. gapSize?: number;
  49479. dashNb?: number;
  49480. updatable?: boolean;
  49481. instance?: LinesMesh;
  49482. }, scene?: Nullable<Scene>): LinesMesh;
  49483. /**
  49484. * 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.
  49485. * * 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.
  49486. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49487. * * 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.
  49488. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49489. * * 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
  49490. * * 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
  49491. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49493. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49494. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49496. * @param name defines the name of the mesh
  49497. * @param options defines the options used to create the mesh
  49498. * @param scene defines the hosting scene
  49499. * @returns the extruded shape mesh
  49500. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49501. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49502. */
  49503. static ExtrudeShape(name: string, options: {
  49504. shape: Vector3[];
  49505. path: Vector3[];
  49506. scale?: number;
  49507. rotation?: number;
  49508. cap?: number;
  49509. updatable?: boolean;
  49510. sideOrientation?: number;
  49511. frontUVs?: Vector4;
  49512. backUVs?: Vector4;
  49513. instance?: Mesh;
  49514. invertUV?: boolean;
  49515. }, scene?: Nullable<Scene>): Mesh;
  49516. /**
  49517. * Creates an custom extruded shape mesh.
  49518. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49519. * * 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.
  49520. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49521. * * 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
  49522. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49523. * * 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
  49524. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49525. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49526. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49527. * * 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
  49528. * * 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
  49529. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49531. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49532. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49534. * @param name defines the name of the mesh
  49535. * @param options defines the options used to create the mesh
  49536. * @param scene defines the hosting scene
  49537. * @returns the custom extruded shape mesh
  49538. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49539. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49540. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49541. */
  49542. static ExtrudeShapeCustom(name: string, options: {
  49543. shape: Vector3[];
  49544. path: Vector3[];
  49545. scaleFunction?: any;
  49546. rotationFunction?: any;
  49547. ribbonCloseArray?: boolean;
  49548. ribbonClosePath?: boolean;
  49549. cap?: number;
  49550. updatable?: boolean;
  49551. sideOrientation?: number;
  49552. frontUVs?: Vector4;
  49553. backUVs?: Vector4;
  49554. instance?: Mesh;
  49555. invertUV?: boolean;
  49556. }, scene: Scene): Mesh;
  49557. /**
  49558. * Creates lathe mesh.
  49559. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49560. * * 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
  49561. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49562. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49563. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49564. * * 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
  49565. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49566. * * 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
  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 mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49571. * @param name defines the name of the mesh
  49572. * @param options defines the options used to create the mesh
  49573. * @param scene defines the hosting scene
  49574. * @returns the lathe mesh
  49575. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49576. */
  49577. static CreateLathe(name: string, options: {
  49578. shape: Vector3[];
  49579. radius?: number;
  49580. tessellation?: number;
  49581. clip?: number;
  49582. arc?: number;
  49583. closed?: boolean;
  49584. updatable?: boolean;
  49585. sideOrientation?: number;
  49586. frontUVs?: Vector4;
  49587. backUVs?: Vector4;
  49588. cap?: number;
  49589. invertUV?: boolean;
  49590. }, scene: Scene): Mesh;
  49591. /**
  49592. * Creates a plane mesh
  49593. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  49594. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  49595. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  49596. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49597. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49599. * @param name defines the name of the mesh
  49600. * @param options defines the options used to create the mesh
  49601. * @param scene defines the hosting scene
  49602. * @returns the plane mesh
  49603. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  49604. */
  49605. static CreatePlane(name: string, options: {
  49606. size?: number;
  49607. width?: number;
  49608. height?: number;
  49609. sideOrientation?: number;
  49610. frontUVs?: Vector4;
  49611. backUVs?: Vector4;
  49612. updatable?: boolean;
  49613. sourcePlane?: Plane;
  49614. }, scene: Scene): Mesh;
  49615. /**
  49616. * Creates a ground mesh
  49617. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49618. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49620. * @param name defines the name of the mesh
  49621. * @param options defines the options used to create the mesh
  49622. * @param scene defines the hosting scene
  49623. * @returns the ground mesh
  49624. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49625. */
  49626. static CreateGround(name: string, options: {
  49627. width?: number;
  49628. height?: number;
  49629. subdivisions?: number;
  49630. subdivisionsX?: number;
  49631. subdivisionsY?: number;
  49632. updatable?: boolean;
  49633. }, scene: any): Mesh;
  49634. /**
  49635. * Creates a tiled ground mesh
  49636. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49637. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49638. * * 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
  49639. * * 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
  49640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49641. * @param name defines the name of the mesh
  49642. * @param options defines the options used to create the mesh
  49643. * @param scene defines the hosting scene
  49644. * @returns the tiled ground mesh
  49645. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49646. */
  49647. static CreateTiledGround(name: string, options: {
  49648. xmin: number;
  49649. zmin: number;
  49650. xmax: number;
  49651. zmax: number;
  49652. subdivisions?: {
  49653. w: number;
  49654. h: number;
  49655. };
  49656. precision?: {
  49657. w: number;
  49658. h: number;
  49659. };
  49660. updatable?: boolean;
  49661. }, scene: Scene): Mesh;
  49662. /**
  49663. * Creates a ground mesh from a height map
  49664. * * The parameter `url` sets the URL of the height map image resource.
  49665. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49666. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49667. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  49668. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  49669. * * 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.
  49670. * * 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).
  49671. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  49672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49673. * @param name defines the name of the mesh
  49674. * @param url defines the url to the height map
  49675. * @param options defines the options used to create the mesh
  49676. * @param scene defines the hosting scene
  49677. * @returns the ground mesh
  49678. * @see https://doc.babylonjs.com/babylon101/height_map
  49679. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  49680. */
  49681. static CreateGroundFromHeightMap(name: string, url: string, options: {
  49682. width?: number;
  49683. height?: number;
  49684. subdivisions?: number;
  49685. minHeight?: number;
  49686. maxHeight?: number;
  49687. colorFilter?: Color3;
  49688. alphaFilter?: number;
  49689. updatable?: boolean;
  49690. onReady?: (mesh: GroundMesh) => void;
  49691. }, scene: Scene): GroundMesh;
  49692. /**
  49693. * Creates a polygon mesh
  49694. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49695. * * 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
  49696. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49698. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  49699. * * Remember you can only change the shape positions, not their number when updating a polygon
  49700. * @param name defines the name of the mesh
  49701. * @param options defines the options used to create the mesh
  49702. * @param scene defines the hosting scene
  49703. * @param earcutInjection can be used to inject your own earcut reference
  49704. * @returns the polygon mesh
  49705. */
  49706. static CreatePolygon(name: string, options: {
  49707. shape: Vector3[];
  49708. holes?: Vector3[][];
  49709. depth?: number;
  49710. faceUV?: Vector4[];
  49711. faceColors?: Color4[];
  49712. updatable?: boolean;
  49713. sideOrientation?: number;
  49714. frontUVs?: Vector4;
  49715. backUVs?: Vector4;
  49716. }, scene: Scene, earcutInjection?: any): Mesh;
  49717. /**
  49718. * Creates an extruded polygon mesh, with depth in the Y direction.
  49719. * * 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)
  49720. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49721. * @param name defines the name of the mesh
  49722. * @param options defines the options used to create the mesh
  49723. * @param scene defines the hosting scene
  49724. * @param earcutInjection can be used to inject your own earcut reference
  49725. * @returns the polygon mesh
  49726. */
  49727. static ExtrudePolygon(name: string, options: {
  49728. shape: Vector3[];
  49729. holes?: Vector3[][];
  49730. depth?: number;
  49731. faceUV?: Vector4[];
  49732. faceColors?: Color4[];
  49733. updatable?: boolean;
  49734. sideOrientation?: number;
  49735. frontUVs?: Vector4;
  49736. backUVs?: Vector4;
  49737. }, scene: Scene, earcutInjection?: any): Mesh;
  49738. /**
  49739. * Creates a tube mesh.
  49740. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49741. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49742. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49743. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49744. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49745. * * 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)
  49746. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49747. * * 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
  49748. * * 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
  49749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49750. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49751. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49753. * @param name defines the name of the mesh
  49754. * @param options defines the options used to create the mesh
  49755. * @param scene defines the hosting scene
  49756. * @returns the tube mesh
  49757. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49758. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49759. */
  49760. static CreateTube(name: string, options: {
  49761. path: Vector3[];
  49762. radius?: number;
  49763. tessellation?: number;
  49764. radiusFunction?: {
  49765. (i: number, distance: number): number;
  49766. };
  49767. cap?: number;
  49768. arc?: number;
  49769. updatable?: boolean;
  49770. sideOrientation?: number;
  49771. frontUVs?: Vector4;
  49772. backUVs?: Vector4;
  49773. instance?: Mesh;
  49774. invertUV?: boolean;
  49775. }, scene: Scene): Mesh;
  49776. /**
  49777. * Creates a polyhedron mesh
  49778. * * 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
  49779. * * The parameter `size` (positive float, default 1) sets the polygon size
  49780. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49781. * * 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`
  49782. * * 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
  49783. * * 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)`)
  49784. * * 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
  49785. * * 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
  49786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49787. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49789. * @param name defines the name of the mesh
  49790. * @param options defines the options used to create the mesh
  49791. * @param scene defines the hosting scene
  49792. * @returns the polyhedron mesh
  49793. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49794. */
  49795. static CreatePolyhedron(name: string, options: {
  49796. type?: number;
  49797. size?: number;
  49798. sizeX?: number;
  49799. sizeY?: number;
  49800. sizeZ?: number;
  49801. custom?: any;
  49802. faceUV?: Vector4[];
  49803. faceColors?: Color4[];
  49804. flat?: boolean;
  49805. updatable?: boolean;
  49806. sideOrientation?: number;
  49807. frontUVs?: Vector4;
  49808. backUVs?: Vector4;
  49809. }, scene: Scene): Mesh;
  49810. /**
  49811. * Creates a decal mesh.
  49812. * 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
  49813. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49814. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49815. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49816. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49817. * @param name defines the name of the mesh
  49818. * @param sourceMesh defines the mesh where the decal must be applied
  49819. * @param options defines the options used to create the mesh
  49820. * @param scene defines the hosting scene
  49821. * @returns the decal mesh
  49822. * @see https://doc.babylonjs.com/how_to/decals
  49823. */
  49824. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49825. position?: Vector3;
  49826. normal?: Vector3;
  49827. size?: Vector3;
  49828. angle?: number;
  49829. }): Mesh;
  49830. }
  49831. }
  49832. declare module "babylonjs/Meshes/meshSimplification" {
  49833. import { Mesh } from "babylonjs/Meshes/mesh";
  49834. /**
  49835. * A simplifier interface for future simplification implementations
  49836. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49837. */
  49838. export interface ISimplifier {
  49839. /**
  49840. * Simplification of a given mesh according to the given settings.
  49841. * Since this requires computation, it is assumed that the function runs async.
  49842. * @param settings The settings of the simplification, including quality and distance
  49843. * @param successCallback A callback that will be called after the mesh was simplified.
  49844. * @param errorCallback in case of an error, this callback will be called. optional.
  49845. */
  49846. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  49847. }
  49848. /**
  49849. * Expected simplification settings.
  49850. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  49851. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49852. */
  49853. export interface ISimplificationSettings {
  49854. /**
  49855. * Gets or sets the expected quality
  49856. */
  49857. quality: number;
  49858. /**
  49859. * Gets or sets the distance when this optimized version should be used
  49860. */
  49861. distance: number;
  49862. /**
  49863. * Gets an already optimized mesh
  49864. */
  49865. optimizeMesh?: boolean;
  49866. }
  49867. /**
  49868. * Class used to specify simplification options
  49869. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49870. */
  49871. export class SimplificationSettings implements ISimplificationSettings {
  49872. /** expected quality */
  49873. quality: number;
  49874. /** distance when this optimized version should be used */
  49875. distance: number;
  49876. /** already optimized mesh */
  49877. optimizeMesh?: boolean | undefined;
  49878. /**
  49879. * Creates a SimplificationSettings
  49880. * @param quality expected quality
  49881. * @param distance distance when this optimized version should be used
  49882. * @param optimizeMesh already optimized mesh
  49883. */
  49884. constructor(
  49885. /** expected quality */
  49886. quality: number,
  49887. /** distance when this optimized version should be used */
  49888. distance: number,
  49889. /** already optimized mesh */
  49890. optimizeMesh?: boolean | undefined);
  49891. }
  49892. /**
  49893. * Interface used to define a simplification task
  49894. */
  49895. export interface ISimplificationTask {
  49896. /**
  49897. * Array of settings
  49898. */
  49899. settings: Array<ISimplificationSettings>;
  49900. /**
  49901. * Simplification type
  49902. */
  49903. simplificationType: SimplificationType;
  49904. /**
  49905. * Mesh to simplify
  49906. */
  49907. mesh: Mesh;
  49908. /**
  49909. * Callback called on success
  49910. */
  49911. successCallback?: () => void;
  49912. /**
  49913. * Defines if parallel processing can be used
  49914. */
  49915. parallelProcessing: boolean;
  49916. }
  49917. /**
  49918. * Queue used to order the simplification tasks
  49919. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49920. */
  49921. export class SimplificationQueue {
  49922. private _simplificationArray;
  49923. /**
  49924. * Gets a boolean indicating that the process is still running
  49925. */
  49926. running: boolean;
  49927. /**
  49928. * Creates a new queue
  49929. */
  49930. constructor();
  49931. /**
  49932. * Adds a new simplification task
  49933. * @param task defines a task to add
  49934. */
  49935. addTask(task: ISimplificationTask): void;
  49936. /**
  49937. * Execute next task
  49938. */
  49939. executeNext(): void;
  49940. /**
  49941. * Execute a simplification task
  49942. * @param task defines the task to run
  49943. */
  49944. runSimplification(task: ISimplificationTask): void;
  49945. private getSimplifier;
  49946. }
  49947. /**
  49948. * The implemented types of simplification
  49949. * At the moment only Quadratic Error Decimation is implemented
  49950. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49951. */
  49952. export enum SimplificationType {
  49953. /** Quadratic error decimation */
  49954. QUADRATIC = 0
  49955. }
  49956. }
  49957. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  49958. import { Scene } from "babylonjs/scene";
  49959. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  49960. import { ISceneComponent } from "babylonjs/sceneComponent";
  49961. module "babylonjs/scene" {
  49962. interface Scene {
  49963. /** @hidden (Backing field) */
  49964. _simplificationQueue: SimplificationQueue;
  49965. /**
  49966. * Gets or sets the simplification queue attached to the scene
  49967. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49968. */
  49969. simplificationQueue: SimplificationQueue;
  49970. }
  49971. }
  49972. module "babylonjs/Meshes/mesh" {
  49973. interface Mesh {
  49974. /**
  49975. * Simplify the mesh according to the given array of settings.
  49976. * Function will return immediately and will simplify async
  49977. * @param settings a collection of simplification settings
  49978. * @param parallelProcessing should all levels calculate parallel or one after the other
  49979. * @param simplificationType the type of simplification to run
  49980. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  49981. * @returns the current mesh
  49982. */
  49983. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  49984. }
  49985. }
  49986. /**
  49987. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  49988. * created in a scene
  49989. */
  49990. export class SimplicationQueueSceneComponent implements ISceneComponent {
  49991. /**
  49992. * The component name helpfull to identify the component in the list of scene components.
  49993. */
  49994. readonly name: string;
  49995. /**
  49996. * The scene the component belongs to.
  49997. */
  49998. scene: Scene;
  49999. /**
  50000. * Creates a new instance of the component for the given scene
  50001. * @param scene Defines the scene to register the component in
  50002. */
  50003. constructor(scene: Scene);
  50004. /**
  50005. * Registers the component in a given scene
  50006. */
  50007. register(): void;
  50008. /**
  50009. * Rebuilds the elements related to this component in case of
  50010. * context lost for instance.
  50011. */
  50012. rebuild(): void;
  50013. /**
  50014. * Disposes the component and the associated ressources
  50015. */
  50016. dispose(): void;
  50017. private _beforeCameraUpdate;
  50018. }
  50019. }
  50020. declare module "babylonjs/Meshes/Builders/index" {
  50021. export * from "babylonjs/Meshes/Builders/boxBuilder";
  50022. export * from "babylonjs/Meshes/Builders/discBuilder";
  50023. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  50024. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  50025. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  50026. export * from "babylonjs/Meshes/Builders/torusBuilder";
  50027. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  50028. export * from "babylonjs/Meshes/Builders/linesBuilder";
  50029. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  50030. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  50031. export * from "babylonjs/Meshes/Builders/latheBuilder";
  50032. export * from "babylonjs/Meshes/Builders/planeBuilder";
  50033. export * from "babylonjs/Meshes/Builders/groundBuilder";
  50034. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  50035. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  50036. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  50037. export * from "babylonjs/Meshes/Builders/decalBuilder";
  50038. }
  50039. declare module "babylonjs/Meshes/index" {
  50040. export * from "babylonjs/Meshes/abstractMesh";
  50041. export * from "babylonjs/Meshes/buffer";
  50042. export * from "babylonjs/Meshes/Compression/index";
  50043. export * from "babylonjs/Meshes/csg";
  50044. export * from "babylonjs/Meshes/geometry";
  50045. export * from "babylonjs/Meshes/groundMesh";
  50046. export * from "babylonjs/Meshes/instancedMesh";
  50047. export * from "babylonjs/Meshes/linesMesh";
  50048. export * from "babylonjs/Meshes/mesh";
  50049. export * from "babylonjs/Meshes/mesh.vertexData";
  50050. export * from "babylonjs/Meshes/meshBuilder";
  50051. export * from "babylonjs/Meshes/meshSimplification";
  50052. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  50053. export * from "babylonjs/Meshes/polygonMesh";
  50054. export * from "babylonjs/Meshes/subMesh";
  50055. export * from "babylonjs/Meshes/transformNode";
  50056. export * from "babylonjs/Meshes/Builders/index";
  50057. }
  50058. declare module "babylonjs/Morph/index" {
  50059. export * from "babylonjs/Morph/morphTarget";
  50060. export * from "babylonjs/Morph/morphTargetManager";
  50061. }
  50062. declare module "babylonjs/Offline/database" {
  50063. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  50064. /**
  50065. * Class used to enable access to IndexedDB
  50066. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50067. */
  50068. export class Database implements IOfflineProvider {
  50069. private _callbackManifestChecked;
  50070. private _currentSceneUrl;
  50071. private _db;
  50072. private _enableSceneOffline;
  50073. private _enableTexturesOffline;
  50074. private _manifestVersionFound;
  50075. private _mustUpdateRessources;
  50076. private _hasReachedQuota;
  50077. private _isSupported;
  50078. private _idbFactory;
  50079. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50080. private static IsUASupportingBlobStorage;
  50081. /**
  50082. * Gets a boolean indicating if Database storate is enabled (off by default)
  50083. */
  50084. static IDBStorageEnabled: boolean;
  50085. /**
  50086. * Gets a boolean indicating if scene must be saved in the database
  50087. */
  50088. readonly enableSceneOffline: boolean;
  50089. /**
  50090. * Gets a boolean indicating if textures must be saved in the database
  50091. */
  50092. readonly enableTexturesOffline: boolean;
  50093. /**
  50094. * Creates a new Database
  50095. * @param urlToScene defines the url to load the scene
  50096. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50097. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50098. */
  50099. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50100. private static _ParseURL;
  50101. private static _ReturnFullUrlLocation;
  50102. private _checkManifestFile;
  50103. /**
  50104. * Open the database and make it available
  50105. * @param successCallback defines the callback to call on success
  50106. * @param errorCallback defines the callback to call on error
  50107. */
  50108. open(successCallback: () => void, errorCallback: () => void): void;
  50109. /**
  50110. * Loads an image from the database
  50111. * @param url defines the url to load from
  50112. * @param image defines the target DOM image
  50113. */
  50114. loadImage(url: string, image: HTMLImageElement): void;
  50115. private _loadImageFromDBAsync;
  50116. private _saveImageIntoDBAsync;
  50117. private _checkVersionFromDB;
  50118. private _loadVersionFromDBAsync;
  50119. private _saveVersionIntoDBAsync;
  50120. /**
  50121. * Loads a file from database
  50122. * @param url defines the URL to load from
  50123. * @param sceneLoaded defines a callback to call on success
  50124. * @param progressCallBack defines a callback to call when progress changed
  50125. * @param errorCallback defines a callback to call on error
  50126. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50127. */
  50128. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50129. private _loadFileAsync;
  50130. private _saveFileAsync;
  50131. /**
  50132. * Validates if xhr data is correct
  50133. * @param xhr defines the request to validate
  50134. * @param dataType defines the expected data type
  50135. * @returns true if data is correct
  50136. */
  50137. private static _ValidateXHRData;
  50138. }
  50139. }
  50140. declare module "babylonjs/Offline/index" {
  50141. export * from "babylonjs/Offline/database";
  50142. export * from "babylonjs/Offline/IOfflineProvider";
  50143. }
  50144. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  50145. /** @hidden */
  50146. export var gpuUpdateParticlesPixelShader: {
  50147. name: string;
  50148. shader: string;
  50149. };
  50150. }
  50151. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  50152. /** @hidden */
  50153. export var gpuUpdateParticlesVertexShader: {
  50154. name: string;
  50155. shader: string;
  50156. };
  50157. }
  50158. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  50159. /** @hidden */
  50160. export var clipPlaneFragmentDeclaration2: {
  50161. name: string;
  50162. shader: string;
  50163. };
  50164. }
  50165. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  50166. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  50167. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50168. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50169. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50170. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50171. /** @hidden */
  50172. export var gpuRenderParticlesPixelShader: {
  50173. name: string;
  50174. shader: string;
  50175. };
  50176. }
  50177. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  50178. /** @hidden */
  50179. export var clipPlaneVertexDeclaration2: {
  50180. name: string;
  50181. shader: string;
  50182. };
  50183. }
  50184. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  50185. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  50186. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50187. /** @hidden */
  50188. export var gpuRenderParticlesVertexShader: {
  50189. name: string;
  50190. shader: string;
  50191. };
  50192. }
  50193. declare module "babylonjs/Particles/gpuParticleSystem" {
  50194. import { Nullable } from "babylonjs/types";
  50195. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  50196. import { Observable } from "babylonjs/Misc/observable";
  50197. import { Color4, Color3 } from "babylonjs/Maths/math";
  50198. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50199. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  50200. import { Scene, IDisposable } from "babylonjs/scene";
  50201. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  50202. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  50203. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  50204. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  50205. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  50206. /**
  50207. * This represents a GPU particle system in Babylon
  50208. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50209. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50210. */
  50211. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50212. /**
  50213. * The layer mask we are rendering the particles through.
  50214. */
  50215. layerMask: number;
  50216. private _capacity;
  50217. private _activeCount;
  50218. private _currentActiveCount;
  50219. private _accumulatedCount;
  50220. private _renderEffect;
  50221. private _updateEffect;
  50222. private _buffer0;
  50223. private _buffer1;
  50224. private _spriteBuffer;
  50225. private _updateVAO;
  50226. private _renderVAO;
  50227. private _targetIndex;
  50228. private _sourceBuffer;
  50229. private _targetBuffer;
  50230. private _engine;
  50231. private _currentRenderId;
  50232. private _started;
  50233. private _stopped;
  50234. private _timeDelta;
  50235. private _randomTexture;
  50236. private _randomTexture2;
  50237. private _attributesStrideSize;
  50238. private _updateEffectOptions;
  50239. private _randomTextureSize;
  50240. private _actualFrame;
  50241. private readonly _rawTextureWidth;
  50242. /**
  50243. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  50244. */
  50245. static readonly IsSupported: boolean;
  50246. /**
  50247. * An event triggered when the system is disposed.
  50248. */
  50249. onDisposeObservable: Observable<GPUParticleSystem>;
  50250. /**
  50251. * Gets the maximum number of particles active at the same time.
  50252. * @returns The max number of active particles.
  50253. */
  50254. getCapacity(): number;
  50255. /**
  50256. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  50257. * to override the particles.
  50258. */
  50259. forceDepthWrite: boolean;
  50260. /**
  50261. * Gets or set the number of active particles
  50262. */
  50263. activeParticleCount: number;
  50264. private _preWarmDone;
  50265. /**
  50266. * Is this system ready to be used/rendered
  50267. * @return true if the system is ready
  50268. */
  50269. isReady(): boolean;
  50270. /**
  50271. * Gets if the system has been started. (Note: this will still be true after stop is called)
  50272. * @returns True if it has been started, otherwise false.
  50273. */
  50274. isStarted(): boolean;
  50275. /**
  50276. * Starts the particle system and begins to emit
  50277. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  50278. */
  50279. start(delay?: number): void;
  50280. /**
  50281. * Stops the particle system.
  50282. */
  50283. stop(): void;
  50284. /**
  50285. * Remove all active particles
  50286. */
  50287. reset(): void;
  50288. /**
  50289. * Returns the string "GPUParticleSystem"
  50290. * @returns a string containing the class name
  50291. */
  50292. getClassName(): string;
  50293. private _colorGradientsTexture;
  50294. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  50295. /**
  50296. * Adds a new color gradient
  50297. * @param gradient defines the gradient to use (between 0 and 1)
  50298. * @param color1 defines the color to affect to the specified gradient
  50299. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  50300. * @returns the current particle system
  50301. */
  50302. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  50303. /**
  50304. * Remove a specific color gradient
  50305. * @param gradient defines the gradient to remove
  50306. * @returns the current particle system
  50307. */
  50308. removeColorGradient(gradient: number): GPUParticleSystem;
  50309. private _angularSpeedGradientsTexture;
  50310. private _sizeGradientsTexture;
  50311. private _velocityGradientsTexture;
  50312. private _limitVelocityGradientsTexture;
  50313. private _dragGradientsTexture;
  50314. private _addFactorGradient;
  50315. /**
  50316. * Adds a new size gradient
  50317. * @param gradient defines the gradient to use (between 0 and 1)
  50318. * @param factor defines the size factor to affect to the specified gradient
  50319. * @returns the current particle system
  50320. */
  50321. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  50322. /**
  50323. * Remove a specific size gradient
  50324. * @param gradient defines the gradient to remove
  50325. * @returns the current particle system
  50326. */
  50327. removeSizeGradient(gradient: number): GPUParticleSystem;
  50328. /**
  50329. * Adds a new angular speed gradient
  50330. * @param gradient defines the gradient to use (between 0 and 1)
  50331. * @param factor defines the angular speed to affect to the specified gradient
  50332. * @returns the current particle system
  50333. */
  50334. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50335. /**
  50336. * Remove a specific angular speed gradient
  50337. * @param gradient defines the gradient to remove
  50338. * @returns the current particle system
  50339. */
  50340. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  50341. /**
  50342. * Adds a new velocity gradient
  50343. * @param gradient defines the gradient to use (between 0 and 1)
  50344. * @param factor defines the velocity to affect to the specified gradient
  50345. * @returns the current particle system
  50346. */
  50347. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50348. /**
  50349. * Remove a specific velocity gradient
  50350. * @param gradient defines the gradient to remove
  50351. * @returns the current particle system
  50352. */
  50353. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50354. /**
  50355. * Adds a new limit velocity gradient
  50356. * @param gradient defines the gradient to use (between 0 and 1)
  50357. * @param factor defines the limit velocity value to affect to the specified gradient
  50358. * @returns the current particle system
  50359. */
  50360. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50361. /**
  50362. * Remove a specific limit velocity gradient
  50363. * @param gradient defines the gradient to remove
  50364. * @returns the current particle system
  50365. */
  50366. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50367. /**
  50368. * Adds a new drag gradient
  50369. * @param gradient defines the gradient to use (between 0 and 1)
  50370. * @param factor defines the drag value to affect to the specified gradient
  50371. * @returns the current particle system
  50372. */
  50373. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50374. /**
  50375. * Remove a specific drag gradient
  50376. * @param gradient defines the gradient to remove
  50377. * @returns the current particle system
  50378. */
  50379. removeDragGradient(gradient: number): GPUParticleSystem;
  50380. /**
  50381. * Not supported by GPUParticleSystem
  50382. * @param gradient defines the gradient to use (between 0 and 1)
  50383. * @param factor defines the emit rate value to affect to the specified gradient
  50384. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50385. * @returns the current particle system
  50386. */
  50387. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50388. /**
  50389. * Not supported by GPUParticleSystem
  50390. * @param gradient defines the gradient to remove
  50391. * @returns the current particle system
  50392. */
  50393. removeEmitRateGradient(gradient: number): IParticleSystem;
  50394. /**
  50395. * Not supported by GPUParticleSystem
  50396. * @param gradient defines the gradient to use (between 0 and 1)
  50397. * @param factor defines the start size value to affect to the specified gradient
  50398. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50399. * @returns the current particle system
  50400. */
  50401. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50402. /**
  50403. * Not supported by GPUParticleSystem
  50404. * @param gradient defines the gradient to remove
  50405. * @returns the current particle system
  50406. */
  50407. removeStartSizeGradient(gradient: number): IParticleSystem;
  50408. /**
  50409. * Not supported by GPUParticleSystem
  50410. * @param gradient defines the gradient to use (between 0 and 1)
  50411. * @param min defines the color remap minimal range
  50412. * @param max defines the color remap maximal range
  50413. * @returns the current particle system
  50414. */
  50415. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50416. /**
  50417. * Not supported by GPUParticleSystem
  50418. * @param gradient defines the gradient to remove
  50419. * @returns the current particle system
  50420. */
  50421. removeColorRemapGradient(): IParticleSystem;
  50422. /**
  50423. * Not supported by GPUParticleSystem
  50424. * @param gradient defines the gradient to use (between 0 and 1)
  50425. * @param min defines the alpha remap minimal range
  50426. * @param max defines the alpha remap maximal range
  50427. * @returns the current particle system
  50428. */
  50429. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50430. /**
  50431. * Not supported by GPUParticleSystem
  50432. * @param gradient defines the gradient to remove
  50433. * @returns the current particle system
  50434. */
  50435. removeAlphaRemapGradient(): IParticleSystem;
  50436. /**
  50437. * Not supported by GPUParticleSystem
  50438. * @param gradient defines the gradient to use (between 0 and 1)
  50439. * @param color defines the color to affect to the specified gradient
  50440. * @returns the current particle system
  50441. */
  50442. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  50443. /**
  50444. * Not supported by GPUParticleSystem
  50445. * @param gradient defines the gradient to remove
  50446. * @returns the current particle system
  50447. */
  50448. removeRampGradient(): IParticleSystem;
  50449. /**
  50450. * Not supported by GPUParticleSystem
  50451. * @returns the list of ramp gradients
  50452. */
  50453. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50454. /**
  50455. * Not supported by GPUParticleSystem
  50456. * Gets or sets a boolean indicating that ramp gradients must be used
  50457. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50458. */
  50459. useRampGradients: boolean;
  50460. /**
  50461. * Not supported by GPUParticleSystem
  50462. * @param gradient defines the gradient to use (between 0 and 1)
  50463. * @param factor defines the life time factor to affect to the specified gradient
  50464. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50465. * @returns the current particle system
  50466. */
  50467. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50468. /**
  50469. * Not supported by GPUParticleSystem
  50470. * @param gradient defines the gradient to remove
  50471. * @returns the current particle system
  50472. */
  50473. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50474. /**
  50475. * Instantiates a GPU particle system.
  50476. * 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.
  50477. * @param name The name of the particle system
  50478. * @param options The options used to create the system
  50479. * @param scene The scene the particle system belongs to
  50480. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50481. */
  50482. constructor(name: string, options: Partial<{
  50483. capacity: number;
  50484. randomTextureSize: number;
  50485. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50486. protected _reset(): void;
  50487. private _createUpdateVAO;
  50488. private _createRenderVAO;
  50489. private _initialize;
  50490. /** @hidden */
  50491. _recreateUpdateEffect(): void;
  50492. /** @hidden */
  50493. _recreateRenderEffect(): void;
  50494. /**
  50495. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50496. * @param preWarm defines if we are in the pre-warmimg phase
  50497. */
  50498. animate(preWarm?: boolean): void;
  50499. private _createFactorGradientTexture;
  50500. private _createSizeGradientTexture;
  50501. private _createAngularSpeedGradientTexture;
  50502. private _createVelocityGradientTexture;
  50503. private _createLimitVelocityGradientTexture;
  50504. private _createDragGradientTexture;
  50505. private _createColorGradientTexture;
  50506. /**
  50507. * Renders the particle system in its current state
  50508. * @param preWarm defines if the system should only update the particles but not render them
  50509. * @returns the current number of particles
  50510. */
  50511. render(preWarm?: boolean): number;
  50512. /**
  50513. * Rebuilds the particle system
  50514. */
  50515. rebuild(): void;
  50516. private _releaseBuffers;
  50517. private _releaseVAOs;
  50518. /**
  50519. * Disposes the particle system and free the associated resources
  50520. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50521. */
  50522. dispose(disposeTexture?: boolean): void;
  50523. /**
  50524. * Clones the particle system.
  50525. * @param name The name of the cloned object
  50526. * @param newEmitter The new emitter to use
  50527. * @returns the cloned particle system
  50528. */
  50529. clone(name: string, newEmitter: any): GPUParticleSystem;
  50530. /**
  50531. * Serializes the particle system to a JSON object.
  50532. * @returns the JSON object
  50533. */
  50534. serialize(): any;
  50535. /**
  50536. * Parses a JSON object to create a GPU particle system.
  50537. * @param parsedParticleSystem The JSON object to parse
  50538. * @param scene The scene to create the particle system in
  50539. * @param rootUrl The root url to use to load external dependencies like texture
  50540. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50541. * @returns the parsed GPU particle system
  50542. */
  50543. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50544. }
  50545. }
  50546. declare module "babylonjs/Particles/particleSystemSet" {
  50547. import { Nullable } from "babylonjs/types";
  50548. import { Color3 } from "babylonjs/Maths/math";
  50549. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50551. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50552. import { Scene, IDisposable } from "babylonjs/scene";
  50553. /**
  50554. * Represents a set of particle systems working together to create a specific effect
  50555. */
  50556. export class ParticleSystemSet implements IDisposable {
  50557. private _emitterCreationOptions;
  50558. private _emitterNode;
  50559. /**
  50560. * Gets the particle system list
  50561. */
  50562. systems: IParticleSystem[];
  50563. /**
  50564. * Gets the emitter node used with this set
  50565. */
  50566. readonly emitterNode: Nullable<TransformNode>;
  50567. /**
  50568. * Creates a new emitter mesh as a sphere
  50569. * @param options defines the options used to create the sphere
  50570. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50571. * @param scene defines the hosting scene
  50572. */
  50573. setEmitterAsSphere(options: {
  50574. diameter: number;
  50575. segments: number;
  50576. color: Color3;
  50577. }, renderingGroupId: number, scene: Scene): void;
  50578. /**
  50579. * Starts all particle systems of the set
  50580. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50581. */
  50582. start(emitter?: AbstractMesh): void;
  50583. /**
  50584. * Release all associated resources
  50585. */
  50586. dispose(): void;
  50587. /**
  50588. * Serialize the set into a JSON compatible object
  50589. * @returns a JSON compatible representation of the set
  50590. */
  50591. serialize(): any;
  50592. /**
  50593. * Parse a new ParticleSystemSet from a serialized source
  50594. * @param data defines a JSON compatible representation of the set
  50595. * @param scene defines the hosting scene
  50596. * @param gpu defines if we want GPU particles or CPU particles
  50597. * @returns a new ParticleSystemSet
  50598. */
  50599. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50600. }
  50601. }
  50602. declare module "babylonjs/Particles/particleHelper" {
  50603. import { Nullable } from "babylonjs/types";
  50604. import { Scene } from "babylonjs/scene";
  50605. import { Vector3 } from "babylonjs/Maths/math";
  50606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50607. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50608. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  50609. /**
  50610. * This class is made for on one-liner static method to help creating particle system set.
  50611. */
  50612. export class ParticleHelper {
  50613. /**
  50614. * Gets or sets base Assets URL
  50615. */
  50616. static BaseAssetsUrl: string;
  50617. /**
  50618. * Create a default particle system that you can tweak
  50619. * @param emitter defines the emitter to use
  50620. * @param capacity defines the system capacity (default is 500 particles)
  50621. * @param scene defines the hosting scene
  50622. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50623. * @returns the new Particle system
  50624. */
  50625. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50626. /**
  50627. * This is the main static method (one-liner) of this helper to create different particle systems
  50628. * @param type This string represents the type to the particle system to create
  50629. * @param scene The scene where the particle system should live
  50630. * @param gpu If the system will use gpu
  50631. * @returns the ParticleSystemSet created
  50632. */
  50633. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50634. /**
  50635. * Static function used to export a particle system to a ParticleSystemSet variable.
  50636. * Please note that the emitter shape is not exported
  50637. * @param systems defines the particle systems to export
  50638. * @returns the created particle system set
  50639. */
  50640. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50641. }
  50642. }
  50643. declare module "babylonjs/Particles/particleSystemComponent" {
  50644. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50645. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  50646. import "babylonjs/Shaders/particles.vertex";
  50647. module "babylonjs/Engines/engine" {
  50648. interface Engine {
  50649. /**
  50650. * Create an effect to use with particle systems.
  50651. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50652. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50653. * @param uniformsNames defines a list of attribute names
  50654. * @param samplers defines an array of string used to represent textures
  50655. * @param defines defines the string containing the defines to use to compile the shaders
  50656. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50657. * @param onCompiled defines a function to call when the effect creation is successful
  50658. * @param onError defines a function to call when the effect creation has failed
  50659. * @returns the new Effect
  50660. */
  50661. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50662. }
  50663. }
  50664. module "babylonjs/Meshes/mesh" {
  50665. interface Mesh {
  50666. /**
  50667. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50668. * @returns an array of IParticleSystem
  50669. */
  50670. getEmittedParticleSystems(): IParticleSystem[];
  50671. /**
  50672. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50673. * @returns an array of IParticleSystem
  50674. */
  50675. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  50676. }
  50677. }
  50678. /**
  50679. * @hidden
  50680. */
  50681. export var _IDoNeedToBeInTheBuild: number;
  50682. }
  50683. declare module "babylonjs/Particles/index" {
  50684. export * from "babylonjs/Particles/baseParticleSystem";
  50685. export * from "babylonjs/Particles/EmitterTypes/index";
  50686. export * from "babylonjs/Particles/gpuParticleSystem";
  50687. export * from "babylonjs/Particles/IParticleSystem";
  50688. export * from "babylonjs/Particles/particle";
  50689. export * from "babylonjs/Particles/particleHelper";
  50690. export * from "babylonjs/Particles/particleSystem";
  50691. export * from "babylonjs/Particles/particleSystemComponent";
  50692. export * from "babylonjs/Particles/particleSystemSet";
  50693. export * from "babylonjs/Particles/solidParticle";
  50694. export * from "babylonjs/Particles/solidParticleSystem";
  50695. export * from "babylonjs/Particles/subEmitter";
  50696. }
  50697. declare module "babylonjs/Physics/physicsEngineComponent" {
  50698. import { Nullable } from "babylonjs/types";
  50699. import { Observable, Observer } from "babylonjs/Misc/observable";
  50700. import { Vector3 } from "babylonjs/Maths/math";
  50701. import { Mesh } from "babylonjs/Meshes/mesh";
  50702. import { ISceneComponent } from "babylonjs/sceneComponent";
  50703. import { Scene } from "babylonjs/scene";
  50704. import { Node } from "babylonjs/node";
  50705. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50706. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50707. module "babylonjs/scene" {
  50708. interface Scene {
  50709. /** @hidden (Backing field) */
  50710. _physicsEngine: Nullable<IPhysicsEngine>;
  50711. /**
  50712. * Gets the current physics engine
  50713. * @returns a IPhysicsEngine or null if none attached
  50714. */
  50715. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  50716. /**
  50717. * Enables physics to the current scene
  50718. * @param gravity defines the scene's gravity for the physics engine
  50719. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  50720. * @return a boolean indicating if the physics engine was initialized
  50721. */
  50722. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  50723. /**
  50724. * Disables and disposes the physics engine associated with the scene
  50725. */
  50726. disablePhysicsEngine(): void;
  50727. /**
  50728. * Gets a boolean indicating if there is an active physics engine
  50729. * @returns a boolean indicating if there is an active physics engine
  50730. */
  50731. isPhysicsEnabled(): boolean;
  50732. /**
  50733. * Deletes a physics compound impostor
  50734. * @param compound defines the compound to delete
  50735. */
  50736. deleteCompoundImpostor(compound: any): void;
  50737. /**
  50738. * An event triggered when physic simulation is about to be run
  50739. */
  50740. onBeforePhysicsObservable: Observable<Scene>;
  50741. /**
  50742. * An event triggered when physic simulation has been done
  50743. */
  50744. onAfterPhysicsObservable: Observable<Scene>;
  50745. }
  50746. }
  50747. module "babylonjs/Meshes/abstractMesh" {
  50748. interface AbstractMesh {
  50749. /** @hidden */
  50750. _physicsImpostor: Nullable<PhysicsImpostor>;
  50751. /**
  50752. * Gets or sets impostor used for physic simulation
  50753. * @see http://doc.babylonjs.com/features/physics_engine
  50754. */
  50755. physicsImpostor: Nullable<PhysicsImpostor>;
  50756. /**
  50757. * Gets the current physics impostor
  50758. * @see http://doc.babylonjs.com/features/physics_engine
  50759. * @returns a physics impostor or null
  50760. */
  50761. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  50762. /** Apply a physic impulse to the mesh
  50763. * @param force defines the force to apply
  50764. * @param contactPoint defines where to apply the force
  50765. * @returns the current mesh
  50766. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50767. */
  50768. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  50769. /**
  50770. * Creates a physic joint between two meshes
  50771. * @param otherMesh defines the other mesh to use
  50772. * @param pivot1 defines the pivot to use on this mesh
  50773. * @param pivot2 defines the pivot to use on the other mesh
  50774. * @param options defines additional options (can be plugin dependent)
  50775. * @returns the current mesh
  50776. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  50777. */
  50778. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  50779. /** @hidden */
  50780. _disposePhysicsObserver: Nullable<Observer<Node>>;
  50781. }
  50782. }
  50783. /**
  50784. * Defines the physics engine scene component responsible to manage a physics engine
  50785. */
  50786. export class PhysicsEngineSceneComponent implements ISceneComponent {
  50787. /**
  50788. * The component name helpful to identify the component in the list of scene components.
  50789. */
  50790. readonly name: string;
  50791. /**
  50792. * The scene the component belongs to.
  50793. */
  50794. scene: Scene;
  50795. /**
  50796. * Creates a new instance of the component for the given scene
  50797. * @param scene Defines the scene to register the component in
  50798. */
  50799. constructor(scene: Scene);
  50800. /**
  50801. * Registers the component in a given scene
  50802. */
  50803. register(): void;
  50804. /**
  50805. * Rebuilds the elements related to this component in case of
  50806. * context lost for instance.
  50807. */
  50808. rebuild(): void;
  50809. /**
  50810. * Disposes the component and the associated ressources
  50811. */
  50812. dispose(): void;
  50813. }
  50814. }
  50815. declare module "babylonjs/Physics/physicsHelper" {
  50816. import { Nullable } from "babylonjs/types";
  50817. import { Vector3 } from "babylonjs/Maths/math";
  50818. import { Mesh } from "babylonjs/Meshes/mesh";
  50819. import { Ray } from "babylonjs/Culling/ray";
  50820. import { Scene } from "babylonjs/scene";
  50821. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50822. /**
  50823. * A helper for physics simulations
  50824. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50825. */
  50826. export class PhysicsHelper {
  50827. private _scene;
  50828. private _physicsEngine;
  50829. /**
  50830. * Initializes the Physics helper
  50831. * @param scene Babylon.js scene
  50832. */
  50833. constructor(scene: Scene);
  50834. /**
  50835. * Applies a radial explosion impulse
  50836. * @param origin the origin of the explosion
  50837. * @param radius the explosion radius
  50838. * @param strength the explosion strength
  50839. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50840. * @returns A physics radial explosion event, or null
  50841. */
  50842. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50843. /**
  50844. * Applies a radial explosion force
  50845. * @param origin the origin of the explosion
  50846. * @param radius the explosion radius
  50847. * @param strength the explosion strength
  50848. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50849. * @returns A physics radial explosion event, or null
  50850. */
  50851. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50852. /**
  50853. * Creates a gravitational field
  50854. * @param origin the origin of the explosion
  50855. * @param radius the explosion radius
  50856. * @param strength the explosion strength
  50857. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50858. * @returns A physics gravitational field event, or null
  50859. */
  50860. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  50861. /**
  50862. * Creates a physics updraft event
  50863. * @param origin the origin of the updraft
  50864. * @param radius the radius of the updraft
  50865. * @param strength the strength of the updraft
  50866. * @param height the height of the updraft
  50867. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  50868. * @returns A physics updraft event, or null
  50869. */
  50870. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  50871. /**
  50872. * Creates a physics vortex event
  50873. * @param origin the of the vortex
  50874. * @param radius the radius of the vortex
  50875. * @param strength the strength of the vortex
  50876. * @param height the height of the vortex
  50877. * @returns a Physics vortex event, or null
  50878. * A physics vortex event or null
  50879. */
  50880. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  50881. }
  50882. /**
  50883. * Represents a physics radial explosion event
  50884. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50885. */
  50886. export class PhysicsRadialExplosionEvent {
  50887. private _scene;
  50888. private _sphere;
  50889. private _sphereOptions;
  50890. private _rays;
  50891. private _dataFetched;
  50892. /**
  50893. * Initializes a radial explosioin event
  50894. * @param scene BabylonJS scene
  50895. */
  50896. constructor(scene: Scene);
  50897. /**
  50898. * Returns the data related to the radial explosion event (sphere & rays).
  50899. * @returns The radial explosion event data
  50900. */
  50901. getData(): PhysicsRadialExplosionEventData;
  50902. /**
  50903. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  50904. * @param impostor A physics imposter
  50905. * @param origin the origin of the explosion
  50906. * @param radius the explosion radius
  50907. * @param strength the explosion strength
  50908. * @param falloff possible options: Constant & Linear
  50909. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  50910. */
  50911. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  50912. /**
  50913. * Disposes the sphere.
  50914. * @param force Specifies if the sphere should be disposed by force
  50915. */
  50916. dispose(force?: boolean): void;
  50917. /*** Helpers ***/
  50918. private _prepareSphere;
  50919. private _intersectsWithSphere;
  50920. }
  50921. /**
  50922. * Represents a gravitational field event
  50923. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50924. */
  50925. export class PhysicsGravitationalFieldEvent {
  50926. private _physicsHelper;
  50927. private _scene;
  50928. private _origin;
  50929. private _radius;
  50930. private _strength;
  50931. private _falloff;
  50932. private _tickCallback;
  50933. private _sphere;
  50934. private _dataFetched;
  50935. /**
  50936. * Initializes the physics gravitational field event
  50937. * @param physicsHelper A physics helper
  50938. * @param scene BabylonJS scene
  50939. * @param origin The origin position of the gravitational field event
  50940. * @param radius The radius of the gravitational field event
  50941. * @param strength The strength of the gravitational field event
  50942. * @param falloff The falloff for the gravitational field event
  50943. */
  50944. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  50945. /**
  50946. * Returns the data related to the gravitational field event (sphere).
  50947. * @returns A gravitational field event
  50948. */
  50949. getData(): PhysicsGravitationalFieldEventData;
  50950. /**
  50951. * Enables the gravitational field.
  50952. */
  50953. enable(): void;
  50954. /**
  50955. * Disables the gravitational field.
  50956. */
  50957. disable(): void;
  50958. /**
  50959. * Disposes the sphere.
  50960. * @param force The force to dispose from the gravitational field event
  50961. */
  50962. dispose(force?: boolean): void;
  50963. private _tick;
  50964. }
  50965. /**
  50966. * Represents a physics updraft event
  50967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50968. */
  50969. export class PhysicsUpdraftEvent {
  50970. private _scene;
  50971. private _origin;
  50972. private _radius;
  50973. private _strength;
  50974. private _height;
  50975. private _updraftMode;
  50976. private _physicsEngine;
  50977. private _originTop;
  50978. private _originDirection;
  50979. private _tickCallback;
  50980. private _cylinder;
  50981. private _cylinderPosition;
  50982. private _dataFetched;
  50983. /**
  50984. * Initializes the physics updraft event
  50985. * @param _scene BabylonJS scene
  50986. * @param _origin The origin position of the updraft
  50987. * @param _radius The radius of the updraft
  50988. * @param _strength The strength of the updraft
  50989. * @param _height The height of the updraft
  50990. * @param _updraftMode The mode of the updraft
  50991. */
  50992. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  50993. /**
  50994. * Returns the data related to the updraft event (cylinder).
  50995. * @returns A physics updraft event
  50996. */
  50997. getData(): PhysicsUpdraftEventData;
  50998. /**
  50999. * Enables the updraft.
  51000. */
  51001. enable(): void;
  51002. /**
  51003. * Disables the cortex.
  51004. */
  51005. disable(): void;
  51006. /**
  51007. * Disposes the sphere.
  51008. * @param force Specifies if the updraft should be disposed by force
  51009. */
  51010. dispose(force?: boolean): void;
  51011. private getImpostorForceAndContactPoint;
  51012. private _tick;
  51013. /*** Helpers ***/
  51014. private _prepareCylinder;
  51015. private _intersectsWithCylinder;
  51016. }
  51017. /**
  51018. * Represents a physics vortex event
  51019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51020. */
  51021. export class PhysicsVortexEvent {
  51022. private _scene;
  51023. private _origin;
  51024. private _radius;
  51025. private _strength;
  51026. private _height;
  51027. private _physicsEngine;
  51028. private _originTop;
  51029. private _centripetalForceThreshold;
  51030. private _updraftMultiplier;
  51031. private _tickCallback;
  51032. private _cylinder;
  51033. private _cylinderPosition;
  51034. private _dataFetched;
  51035. /**
  51036. * Initializes the physics vortex event
  51037. * @param _scene The BabylonJS scene
  51038. * @param _origin The origin position of the vortex
  51039. * @param _radius The radius of the vortex
  51040. * @param _strength The strength of the vortex
  51041. * @param _height The height of the vortex
  51042. */
  51043. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  51044. /**
  51045. * Returns the data related to the vortex event (cylinder).
  51046. * @returns The physics vortex event data
  51047. */
  51048. getData(): PhysicsVortexEventData;
  51049. /**
  51050. * Enables the vortex.
  51051. */
  51052. enable(): void;
  51053. /**
  51054. * Disables the cortex.
  51055. */
  51056. disable(): void;
  51057. /**
  51058. * Disposes the sphere.
  51059. * @param force
  51060. */
  51061. dispose(force?: boolean): void;
  51062. private getImpostorForceAndContactPoint;
  51063. private _tick;
  51064. /*** Helpers ***/
  51065. private _prepareCylinder;
  51066. private _intersectsWithCylinder;
  51067. }
  51068. /**
  51069. * The strenght of the force in correspondence to the distance of the affected object
  51070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51071. */
  51072. export enum PhysicsRadialImpulseFalloff {
  51073. /** Defines that impulse is constant in strength across it's whole radius */
  51074. Constant = 0,
  51075. /** DEfines that impulse gets weaker if it's further from the origin */
  51076. Linear = 1
  51077. }
  51078. /**
  51079. * The strength of the force in correspondence to the distance of the affected object
  51080. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51081. */
  51082. export enum PhysicsUpdraftMode {
  51083. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51084. Center = 0,
  51085. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51086. Perpendicular = 1
  51087. }
  51088. /**
  51089. * Interface for a physics force and contact point
  51090. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51091. */
  51092. export interface PhysicsForceAndContactPoint {
  51093. /**
  51094. * The force applied at the contact point
  51095. */
  51096. force: Vector3;
  51097. /**
  51098. * The contact point
  51099. */
  51100. contactPoint: Vector3;
  51101. }
  51102. /**
  51103. * Interface for radial explosion event data
  51104. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51105. */
  51106. export interface PhysicsRadialExplosionEventData {
  51107. /**
  51108. * A sphere used for the radial explosion event
  51109. */
  51110. sphere: Mesh;
  51111. /**
  51112. * An array of rays for the radial explosion event
  51113. */
  51114. rays: Array<Ray>;
  51115. }
  51116. /**
  51117. * Interface for gravitational field event data
  51118. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51119. */
  51120. export interface PhysicsGravitationalFieldEventData {
  51121. /**
  51122. * A sphere mesh used for the gravitational field event
  51123. */
  51124. sphere: Mesh;
  51125. }
  51126. /**
  51127. * Interface for updraft event data
  51128. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51129. */
  51130. export interface PhysicsUpdraftEventData {
  51131. /**
  51132. * A cylinder used for the updraft event
  51133. */
  51134. cylinder: Mesh;
  51135. }
  51136. /**
  51137. * Interface for vortex event data
  51138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51139. */
  51140. export interface PhysicsVortexEventData {
  51141. /**
  51142. * A cylinder used for the vortex event
  51143. */
  51144. cylinder: Mesh;
  51145. }
  51146. }
  51147. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51148. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51149. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51150. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51151. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51152. import { Nullable } from "babylonjs/types";
  51153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51154. /**
  51155. * AmmoJS Physics plugin
  51156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51157. * @see https://github.com/kripken/ammo.js/
  51158. */
  51159. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51160. private _useDeltaForWorldStep;
  51161. /**
  51162. * Reference to the Ammo library
  51163. */
  51164. bjsAMMO: any;
  51165. /**
  51166. * Created ammoJS world which physics bodies are added to
  51167. */
  51168. world: any;
  51169. /**
  51170. * Name of the plugin
  51171. */
  51172. name: string;
  51173. private _timeStep;
  51174. private _fixedTimeStep;
  51175. private _maxSteps;
  51176. private _tmpQuaternion;
  51177. private _tmpAmmoTransform;
  51178. private _tmpAmmoQuaternion;
  51179. private _tmpAmmoConcreteContactResultCallback;
  51180. private _collisionConfiguration;
  51181. private _dispatcher;
  51182. private _overlappingPairCache;
  51183. private _solver;
  51184. private _tmpAmmoVectorA;
  51185. private _tmpAmmoVectorB;
  51186. private _tmpAmmoVectorC;
  51187. private _tmpContactCallbackResult;
  51188. private static readonly DISABLE_COLLISION_FLAG;
  51189. private static readonly KINEMATIC_FLAG;
  51190. private static readonly DISABLE_DEACTIVATION_FLAG;
  51191. /**
  51192. * Initializes the ammoJS plugin
  51193. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51194. * @param ammoInjection can be used to inject your own ammo reference
  51195. */
  51196. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  51197. /**
  51198. * Sets the gravity of the physics world (m/(s^2))
  51199. * @param gravity Gravity to set
  51200. */
  51201. setGravity(gravity: Vector3): void;
  51202. /**
  51203. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51204. * @param timeStep timestep to use in seconds
  51205. */
  51206. setTimeStep(timeStep: number): void;
  51207. /**
  51208. * 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)
  51209. * @param fixedTimeStep fixedTimeStep to use in seconds
  51210. */
  51211. setFixedTimeStep(fixedTimeStep: number): void;
  51212. /**
  51213. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51214. * @param maxSteps the maximum number of steps by the physics engine per frame
  51215. */
  51216. setMaxSteps(maxSteps: number): void;
  51217. /**
  51218. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51219. * @returns the current timestep in seconds
  51220. */
  51221. getTimeStep(): number;
  51222. private _isImpostorInContact;
  51223. private _isImpostorPairInContact;
  51224. private _stepSimulation;
  51225. /**
  51226. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51227. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51228. * After the step the babylon meshes are set to the position of the physics imposters
  51229. * @param delta amount of time to step forward
  51230. * @param impostors array of imposters to update before/after the step
  51231. */
  51232. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51233. private _tmpVector;
  51234. private _tmpMatrix;
  51235. /**
  51236. * Applies an implulse on the imposter
  51237. * @param impostor imposter to apply impulse
  51238. * @param force amount of force to be applied to the imposter
  51239. * @param contactPoint the location to apply the impulse on the imposter
  51240. */
  51241. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51242. /**
  51243. * Applies a force on the imposter
  51244. * @param impostor imposter to apply force
  51245. * @param force amount of force to be applied to the imposter
  51246. * @param contactPoint the location to apply the force on the imposter
  51247. */
  51248. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51249. /**
  51250. * Creates a physics body using the plugin
  51251. * @param impostor the imposter to create the physics body on
  51252. */
  51253. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51254. /**
  51255. * Removes the physics body from the imposter and disposes of the body's memory
  51256. * @param impostor imposter to remove the physics body from
  51257. */
  51258. removePhysicsBody(impostor: PhysicsImpostor): void;
  51259. /**
  51260. * Generates a joint
  51261. * @param impostorJoint the imposter joint to create the joint with
  51262. */
  51263. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51264. /**
  51265. * Removes a joint
  51266. * @param impostorJoint the imposter joint to remove the joint from
  51267. */
  51268. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51269. private _addMeshVerts;
  51270. private _createShape;
  51271. /**
  51272. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51273. * @param impostor imposter containing the physics body and babylon object
  51274. */
  51275. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51276. /**
  51277. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51278. * @param impostor imposter containing the physics body and babylon object
  51279. * @param newPosition new position
  51280. * @param newRotation new rotation
  51281. */
  51282. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51283. /**
  51284. * If this plugin is supported
  51285. * @returns true if its supported
  51286. */
  51287. isSupported(): boolean;
  51288. /**
  51289. * Sets the linear velocity of the physics body
  51290. * @param impostor imposter to set the velocity on
  51291. * @param velocity velocity to set
  51292. */
  51293. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51294. /**
  51295. * Sets the angular velocity of the physics body
  51296. * @param impostor imposter to set the velocity on
  51297. * @param velocity velocity to set
  51298. */
  51299. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51300. /**
  51301. * gets the linear velocity
  51302. * @param impostor imposter to get linear velocity from
  51303. * @returns linear velocity
  51304. */
  51305. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51306. /**
  51307. * gets the angular velocity
  51308. * @param impostor imposter to get angular velocity from
  51309. * @returns angular velocity
  51310. */
  51311. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51312. /**
  51313. * Sets the mass of physics body
  51314. * @param impostor imposter to set the mass on
  51315. * @param mass mass to set
  51316. */
  51317. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51318. /**
  51319. * Gets the mass of the physics body
  51320. * @param impostor imposter to get the mass from
  51321. * @returns mass
  51322. */
  51323. getBodyMass(impostor: PhysicsImpostor): number;
  51324. /**
  51325. * Gets friction of the impostor
  51326. * @param impostor impostor to get friction from
  51327. * @returns friction value
  51328. */
  51329. getBodyFriction(impostor: PhysicsImpostor): number;
  51330. /**
  51331. * Sets friction of the impostor
  51332. * @param impostor impostor to set friction on
  51333. * @param friction friction value
  51334. */
  51335. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51336. /**
  51337. * Gets restitution of the impostor
  51338. * @param impostor impostor to get restitution from
  51339. * @returns restitution value
  51340. */
  51341. getBodyRestitution(impostor: PhysicsImpostor): number;
  51342. /**
  51343. * Sets resitution of the impostor
  51344. * @param impostor impostor to set resitution on
  51345. * @param restitution resitution value
  51346. */
  51347. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51348. /**
  51349. * Sleeps the physics body and stops it from being active
  51350. * @param impostor impostor to sleep
  51351. */
  51352. sleepBody(impostor: PhysicsImpostor): void;
  51353. /**
  51354. * Activates the physics body
  51355. * @param impostor impostor to activate
  51356. */
  51357. wakeUpBody(impostor: PhysicsImpostor): void;
  51358. /**
  51359. * Updates the distance parameters of the joint
  51360. * @param joint joint to update
  51361. * @param maxDistance maximum distance of the joint
  51362. * @param minDistance minimum distance of the joint
  51363. */
  51364. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51365. /**
  51366. * Sets a motor on the joint
  51367. * @param joint joint to set motor on
  51368. * @param speed speed of the motor
  51369. * @param maxForce maximum force of the motor
  51370. * @param motorIndex index of the motor
  51371. */
  51372. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51373. /**
  51374. * Sets the motors limit
  51375. * @param joint joint to set limit on
  51376. * @param upperLimit upper limit
  51377. * @param lowerLimit lower limit
  51378. */
  51379. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51380. /**
  51381. * Syncs the position and rotation of a mesh with the impostor
  51382. * @param mesh mesh to sync
  51383. * @param impostor impostor to update the mesh with
  51384. */
  51385. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51386. /**
  51387. * Gets the radius of the impostor
  51388. * @param impostor impostor to get radius from
  51389. * @returns the radius
  51390. */
  51391. getRadius(impostor: PhysicsImpostor): number;
  51392. /**
  51393. * Gets the box size of the impostor
  51394. * @param impostor impostor to get box size from
  51395. * @param result the resulting box size
  51396. */
  51397. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51398. /**
  51399. * Disposes of the impostor
  51400. */
  51401. dispose(): void;
  51402. }
  51403. }
  51404. declare module "babylonjs/Physics/Plugins/index" {
  51405. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  51406. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  51407. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  51408. }
  51409. declare module "babylonjs/Physics/index" {
  51410. export * from "babylonjs/Physics/IPhysicsEngine";
  51411. export * from "babylonjs/Physics/physicsEngine";
  51412. export * from "babylonjs/Physics/physicsEngineComponent";
  51413. export * from "babylonjs/Physics/physicsHelper";
  51414. export * from "babylonjs/Physics/physicsImpostor";
  51415. export * from "babylonjs/Physics/physicsJoint";
  51416. export * from "babylonjs/Physics/Plugins/index";
  51417. }
  51418. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  51419. /** @hidden */
  51420. export var blackAndWhitePixelShader: {
  51421. name: string;
  51422. shader: string;
  51423. };
  51424. }
  51425. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  51426. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51427. import { Camera } from "babylonjs/Cameras/camera";
  51428. import { Engine } from "babylonjs/Engines/engine";
  51429. import "babylonjs/Shaders/blackAndWhite.fragment";
  51430. /**
  51431. * Post process used to render in black and white
  51432. */
  51433. export class BlackAndWhitePostProcess extends PostProcess {
  51434. /**
  51435. * Linear about to convert he result to black and white (default: 1)
  51436. */
  51437. degree: number;
  51438. /**
  51439. * Creates a black and white post process
  51440. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51441. * @param name The name of the effect.
  51442. * @param options The required width/height ratio to downsize to before computing the render pass.
  51443. * @param camera The camera to apply the render pass to.
  51444. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51445. * @param engine The engine which the post process will be applied. (default: current engine)
  51446. * @param reusable If the post process can be reused on the same frame. (default: false)
  51447. */
  51448. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51449. }
  51450. }
  51451. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  51452. import { Nullable } from "babylonjs/types";
  51453. import { Camera } from "babylonjs/Cameras/camera";
  51454. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51455. import { Engine } from "babylonjs/Engines/engine";
  51456. /**
  51457. * This represents a set of one or more post processes in Babylon.
  51458. * A post process can be used to apply a shader to a texture after it is rendered.
  51459. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51460. */
  51461. export class PostProcessRenderEffect {
  51462. private _postProcesses;
  51463. private _getPostProcesses;
  51464. private _singleInstance;
  51465. private _cameras;
  51466. private _indicesForCamera;
  51467. /**
  51468. * Name of the effect
  51469. * @hidden
  51470. */
  51471. _name: string;
  51472. /**
  51473. * Instantiates a post process render effect.
  51474. * A post process can be used to apply a shader to a texture after it is rendered.
  51475. * @param engine The engine the effect is tied to
  51476. * @param name The name of the effect
  51477. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51478. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51479. */
  51480. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51481. /**
  51482. * Checks if all the post processes in the effect are supported.
  51483. */
  51484. readonly isSupported: boolean;
  51485. /**
  51486. * Updates the current state of the effect
  51487. * @hidden
  51488. */
  51489. _update(): void;
  51490. /**
  51491. * Attaches the effect on cameras
  51492. * @param cameras The camera to attach to.
  51493. * @hidden
  51494. */
  51495. _attachCameras(cameras: Camera): void;
  51496. /**
  51497. * Attaches the effect on cameras
  51498. * @param cameras The camera to attach to.
  51499. * @hidden
  51500. */
  51501. _attachCameras(cameras: Camera[]): void;
  51502. /**
  51503. * Detatches the effect on cameras
  51504. * @param cameras The camera to detatch from.
  51505. * @hidden
  51506. */
  51507. _detachCameras(cameras: Camera): void;
  51508. /**
  51509. * Detatches the effect on cameras
  51510. * @param cameras The camera to detatch from.
  51511. * @hidden
  51512. */
  51513. _detachCameras(cameras: Camera[]): void;
  51514. /**
  51515. * Enables the effect on given cameras
  51516. * @param cameras The camera to enable.
  51517. * @hidden
  51518. */
  51519. _enable(cameras: Camera): void;
  51520. /**
  51521. * Enables the effect on given cameras
  51522. * @param cameras The camera to enable.
  51523. * @hidden
  51524. */
  51525. _enable(cameras: Nullable<Camera[]>): void;
  51526. /**
  51527. * Disables the effect on the given cameras
  51528. * @param cameras The camera to disable.
  51529. * @hidden
  51530. */
  51531. _disable(cameras: Camera): void;
  51532. /**
  51533. * Disables the effect on the given cameras
  51534. * @param cameras The camera to disable.
  51535. * @hidden
  51536. */
  51537. _disable(cameras: Nullable<Camera[]>): void;
  51538. /**
  51539. * Gets a list of the post processes contained in the effect.
  51540. * @param camera The camera to get the post processes on.
  51541. * @returns The list of the post processes in the effect.
  51542. */
  51543. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51544. }
  51545. }
  51546. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  51547. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51548. /** @hidden */
  51549. export var extractHighlightsPixelShader: {
  51550. name: string;
  51551. shader: string;
  51552. };
  51553. }
  51554. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  51555. import { Nullable } from "babylonjs/types";
  51556. import { Camera } from "babylonjs/Cameras/camera";
  51557. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51558. import { Engine } from "babylonjs/Engines/engine";
  51559. import "babylonjs/Shaders/extractHighlights.fragment";
  51560. /**
  51561. * 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.
  51562. */
  51563. export class ExtractHighlightsPostProcess extends PostProcess {
  51564. /**
  51565. * The luminance threshold, pixels below this value will be set to black.
  51566. */
  51567. threshold: number;
  51568. /** @hidden */
  51569. _exposure: number;
  51570. /**
  51571. * Post process which has the input texture to be used when performing highlight extraction
  51572. * @hidden
  51573. */
  51574. _inputPostProcess: Nullable<PostProcess>;
  51575. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51576. }
  51577. }
  51578. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  51579. /** @hidden */
  51580. export var bloomMergePixelShader: {
  51581. name: string;
  51582. shader: string;
  51583. };
  51584. }
  51585. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  51586. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51587. import { Nullable } from "babylonjs/types";
  51588. import { Engine } from "babylonjs/Engines/engine";
  51589. import { Camera } from "babylonjs/Cameras/camera";
  51590. import "babylonjs/Shaders/bloomMerge.fragment";
  51591. /**
  51592. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51593. */
  51594. export class BloomMergePostProcess extends PostProcess {
  51595. /** Weight of the bloom to be added to the original input. */
  51596. weight: number;
  51597. /**
  51598. * Creates a new instance of @see BloomMergePostProcess
  51599. * @param name The name of the effect.
  51600. * @param originalFromInput Post process which's input will be used for the merge.
  51601. * @param blurred Blurred highlights post process which's output will be used.
  51602. * @param weight Weight of the bloom to be added to the original input.
  51603. * @param options The required width/height ratio to downsize to before computing the render pass.
  51604. * @param camera The camera to apply the render pass to.
  51605. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51606. * @param engine The engine which the post process will be applied. (default: current engine)
  51607. * @param reusable If the post process can be reused on the same frame. (default: false)
  51608. * @param textureType Type of textures used when performing the post process. (default: 0)
  51609. * @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)
  51610. */
  51611. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51612. /** Weight of the bloom to be added to the original input. */
  51613. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51614. }
  51615. }
  51616. declare module "babylonjs/PostProcesses/bloomEffect" {
  51617. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  51618. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51619. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  51620. import { Camera } from "babylonjs/Cameras/camera";
  51621. import { Scene } from "babylonjs/scene";
  51622. /**
  51623. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51624. */
  51625. export class BloomEffect extends PostProcessRenderEffect {
  51626. private bloomScale;
  51627. /**
  51628. * @hidden Internal
  51629. */
  51630. _effects: Array<PostProcess>;
  51631. /**
  51632. * @hidden Internal
  51633. */
  51634. _downscale: ExtractHighlightsPostProcess;
  51635. private _blurX;
  51636. private _blurY;
  51637. private _merge;
  51638. /**
  51639. * The luminance threshold to find bright areas of the image to bloom.
  51640. */
  51641. threshold: number;
  51642. /**
  51643. * The strength of the bloom.
  51644. */
  51645. weight: number;
  51646. /**
  51647. * Specifies the size of the bloom blur kernel, relative to the final output size
  51648. */
  51649. kernel: number;
  51650. /**
  51651. * Creates a new instance of @see BloomEffect
  51652. * @param scene The scene the effect belongs to.
  51653. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51654. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51655. * @param bloomWeight The the strength of bloom.
  51656. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51657. * @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)
  51658. */
  51659. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51660. /**
  51661. * Disposes each of the internal effects for a given camera.
  51662. * @param camera The camera to dispose the effect on.
  51663. */
  51664. disposeEffects(camera: Camera): void;
  51665. /**
  51666. * @hidden Internal
  51667. */
  51668. _updateEffects(): void;
  51669. /**
  51670. * Internal
  51671. * @returns if all the contained post processes are ready.
  51672. * @hidden
  51673. */
  51674. _isReady(): boolean;
  51675. }
  51676. }
  51677. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  51678. /** @hidden */
  51679. export var chromaticAberrationPixelShader: {
  51680. name: string;
  51681. shader: string;
  51682. };
  51683. }
  51684. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  51685. import { Vector2 } from "babylonjs/Maths/math";
  51686. import { Nullable } from "babylonjs/types";
  51687. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51688. import { Camera } from "babylonjs/Cameras/camera";
  51689. import { Engine } from "babylonjs/Engines/engine";
  51690. import "babylonjs/Shaders/chromaticAberration.fragment";
  51691. /**
  51692. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51693. */
  51694. export class ChromaticAberrationPostProcess extends PostProcess {
  51695. /**
  51696. * The amount of seperation of rgb channels (default: 30)
  51697. */
  51698. aberrationAmount: number;
  51699. /**
  51700. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51701. */
  51702. radialIntensity: number;
  51703. /**
  51704. * 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))
  51705. */
  51706. direction: Vector2;
  51707. /**
  51708. * 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))
  51709. */
  51710. centerPosition: Vector2;
  51711. /**
  51712. * Creates a new instance ChromaticAberrationPostProcess
  51713. * @param name The name of the effect.
  51714. * @param screenWidth The width of the screen to apply the effect on.
  51715. * @param screenHeight The height of the screen to apply the effect on.
  51716. * @param options The required width/height ratio to downsize to before computing the render pass.
  51717. * @param camera The camera to apply the render pass to.
  51718. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51719. * @param engine The engine which the post process will be applied. (default: current engine)
  51720. * @param reusable If the post process can be reused on the same frame. (default: false)
  51721. * @param textureType Type of textures used when performing the post process. (default: 0)
  51722. * @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)
  51723. */
  51724. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51725. }
  51726. }
  51727. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  51728. /** @hidden */
  51729. export var circleOfConfusionPixelShader: {
  51730. name: string;
  51731. shader: string;
  51732. };
  51733. }
  51734. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  51735. import { Nullable } from "babylonjs/types";
  51736. import { Engine } from "babylonjs/Engines/engine";
  51737. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51738. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51739. import { Camera } from "babylonjs/Cameras/camera";
  51740. import "babylonjs/Shaders/circleOfConfusion.fragment";
  51741. /**
  51742. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51743. */
  51744. export class CircleOfConfusionPostProcess extends PostProcess {
  51745. /**
  51746. * 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.
  51747. */
  51748. lensSize: number;
  51749. /**
  51750. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51751. */
  51752. fStop: number;
  51753. /**
  51754. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51755. */
  51756. focusDistance: number;
  51757. /**
  51758. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51759. */
  51760. focalLength: number;
  51761. private _depthTexture;
  51762. /**
  51763. * Creates a new instance CircleOfConfusionPostProcess
  51764. * @param name The name of the effect.
  51765. * @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.
  51766. * @param options The required width/height ratio to downsize to before computing the render pass.
  51767. * @param camera The camera to apply the render pass to.
  51768. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51769. * @param engine The engine which the post process will be applied. (default: current engine)
  51770. * @param reusable If the post process can be reused on the same frame. (default: false)
  51771. * @param textureType Type of textures used when performing the post process. (default: 0)
  51772. * @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)
  51773. */
  51774. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51775. /**
  51776. * 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.
  51777. */
  51778. depthTexture: RenderTargetTexture;
  51779. }
  51780. }
  51781. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  51782. /** @hidden */
  51783. export var colorCorrectionPixelShader: {
  51784. name: string;
  51785. shader: string;
  51786. };
  51787. }
  51788. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  51789. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51790. import { Engine } from "babylonjs/Engines/engine";
  51791. import { Camera } from "babylonjs/Cameras/camera";
  51792. import "babylonjs/Shaders/colorCorrection.fragment";
  51793. /**
  51794. *
  51795. * This post-process allows the modification of rendered colors by using
  51796. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51797. *
  51798. * The object needs to be provided an url to a texture containing the color
  51799. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51800. * Use an image editing software to tweak the LUT to match your needs.
  51801. *
  51802. * For an example of a color LUT, see here:
  51803. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51804. * For explanations on color grading, see here:
  51805. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51806. *
  51807. */
  51808. export class ColorCorrectionPostProcess extends PostProcess {
  51809. private _colorTableTexture;
  51810. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51811. }
  51812. }
  51813. declare module "babylonjs/Shaders/convolution.fragment" {
  51814. /** @hidden */
  51815. export var convolutionPixelShader: {
  51816. name: string;
  51817. shader: string;
  51818. };
  51819. }
  51820. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  51821. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51822. import { Nullable } from "babylonjs/types";
  51823. import { Camera } from "babylonjs/Cameras/camera";
  51824. import { Engine } from "babylonjs/Engines/engine";
  51825. import "babylonjs/Shaders/convolution.fragment";
  51826. /**
  51827. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51828. * input texture to perform effects such as edge detection or sharpening
  51829. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51830. */
  51831. export class ConvolutionPostProcess extends PostProcess {
  51832. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51833. kernel: number[];
  51834. /**
  51835. * Creates a new instance ConvolutionPostProcess
  51836. * @param name The name of the effect.
  51837. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51838. * @param options The required width/height ratio to downsize to before computing the render pass.
  51839. * @param camera The camera to apply the render pass to.
  51840. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51841. * @param engine The engine which the post process will be applied. (default: current engine)
  51842. * @param reusable If the post process can be reused on the same frame. (default: false)
  51843. * @param textureType Type of textures used when performing the post process. (default: 0)
  51844. */
  51845. constructor(name: string,
  51846. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51847. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51848. /**
  51849. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51850. */
  51851. static EdgeDetect0Kernel: number[];
  51852. /**
  51853. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51854. */
  51855. static EdgeDetect1Kernel: number[];
  51856. /**
  51857. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51858. */
  51859. static EdgeDetect2Kernel: number[];
  51860. /**
  51861. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51862. */
  51863. static SharpenKernel: number[];
  51864. /**
  51865. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51866. */
  51867. static EmbossKernel: number[];
  51868. /**
  51869. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51870. */
  51871. static GaussianKernel: number[];
  51872. }
  51873. }
  51874. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  51875. import { Nullable } from "babylonjs/types";
  51876. import { Vector2 } from "babylonjs/Maths/math";
  51877. import { Camera } from "babylonjs/Cameras/camera";
  51878. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51879. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  51880. import { Engine } from "babylonjs/Engines/engine";
  51881. import { Scene } from "babylonjs/scene";
  51882. /**
  51883. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51884. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51885. * based on samples that have a large difference in distance than the center pixel.
  51886. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51887. */
  51888. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51889. direction: Vector2;
  51890. /**
  51891. * Creates a new instance CircleOfConfusionPostProcess
  51892. * @param name The name of the effect.
  51893. * @param scene The scene the effect belongs to.
  51894. * @param direction The direction the blur should be applied.
  51895. * @param kernel The size of the kernel used to blur.
  51896. * @param options The required width/height ratio to downsize to before computing the render pass.
  51897. * @param camera The camera to apply the render pass to.
  51898. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51899. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51900. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51901. * @param engine The engine which the post process will be applied. (default: current engine)
  51902. * @param reusable If the post process can be reused on the same frame. (default: false)
  51903. * @param textureType Type of textures used when performing the post process. (default: 0)
  51904. * @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)
  51905. */
  51906. 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);
  51907. }
  51908. }
  51909. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  51910. /** @hidden */
  51911. export var depthOfFieldMergePixelShader: {
  51912. name: string;
  51913. shader: string;
  51914. };
  51915. }
  51916. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  51917. import { Nullable } from "babylonjs/types";
  51918. import { Camera } from "babylonjs/Cameras/camera";
  51919. import { Effect } from "babylonjs/Materials/effect";
  51920. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51921. import { Engine } from "babylonjs/Engines/engine";
  51922. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  51923. /**
  51924. * Options to be set when merging outputs from the default pipeline.
  51925. */
  51926. export class DepthOfFieldMergePostProcessOptions {
  51927. /**
  51928. * The original image to merge on top of
  51929. */
  51930. originalFromInput: PostProcess;
  51931. /**
  51932. * Parameters to perform the merge of the depth of field effect
  51933. */
  51934. depthOfField?: {
  51935. circleOfConfusion: PostProcess;
  51936. blurSteps: Array<PostProcess>;
  51937. };
  51938. /**
  51939. * Parameters to perform the merge of bloom effect
  51940. */
  51941. bloom?: {
  51942. blurred: PostProcess;
  51943. weight: number;
  51944. };
  51945. }
  51946. /**
  51947. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51948. */
  51949. export class DepthOfFieldMergePostProcess extends PostProcess {
  51950. private blurSteps;
  51951. /**
  51952. * Creates a new instance of DepthOfFieldMergePostProcess
  51953. * @param name The name of the effect.
  51954. * @param originalFromInput Post process which's input will be used for the merge.
  51955. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  51956. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  51957. * @param options The required width/height ratio to downsize to before computing the render pass.
  51958. * @param camera The camera to apply the render pass to.
  51959. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51960. * @param engine The engine which the post process will be applied. (default: current engine)
  51961. * @param reusable If the post process can be reused on the same frame. (default: false)
  51962. * @param textureType Type of textures used when performing the post process. (default: 0)
  51963. * @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)
  51964. */
  51965. 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);
  51966. /**
  51967. * Updates the effect with the current post process compile time values and recompiles the shader.
  51968. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  51969. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  51970. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  51971. * @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
  51972. * @param onCompiled Called when the shader has been compiled.
  51973. * @param onError Called if there is an error when compiling a shader.
  51974. */
  51975. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  51976. }
  51977. }
  51978. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  51979. import { Nullable } from "babylonjs/types";
  51980. import { Camera } from "babylonjs/Cameras/camera";
  51981. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51982. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51983. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  51984. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  51985. import { Scene } from "babylonjs/scene";
  51986. /**
  51987. * Specifies the level of max blur that should be applied when using the depth of field effect
  51988. */
  51989. export enum DepthOfFieldEffectBlurLevel {
  51990. /**
  51991. * Subtle blur
  51992. */
  51993. Low = 0,
  51994. /**
  51995. * Medium blur
  51996. */
  51997. Medium = 1,
  51998. /**
  51999. * Large blur
  52000. */
  52001. High = 2
  52002. }
  52003. /**
  52004. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52005. */
  52006. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52007. private _circleOfConfusion;
  52008. /**
  52009. * @hidden Internal, blurs from high to low
  52010. */
  52011. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52012. private _depthOfFieldBlurY;
  52013. private _dofMerge;
  52014. /**
  52015. * @hidden Internal post processes in depth of field effect
  52016. */
  52017. _effects: Array<PostProcess>;
  52018. /**
  52019. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52020. */
  52021. focalLength: number;
  52022. /**
  52023. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52024. */
  52025. fStop: number;
  52026. /**
  52027. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52028. */
  52029. focusDistance: number;
  52030. /**
  52031. * 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.
  52032. */
  52033. lensSize: number;
  52034. /**
  52035. * Creates a new instance DepthOfFieldEffect
  52036. * @param scene The scene the effect belongs to.
  52037. * @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.
  52038. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52039. * @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)
  52040. */
  52041. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52042. /**
  52043. * 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.
  52044. */
  52045. depthTexture: RenderTargetTexture;
  52046. /**
  52047. * Disposes each of the internal effects for a given camera.
  52048. * @param camera The camera to dispose the effect on.
  52049. */
  52050. disposeEffects(camera: Camera): void;
  52051. /**
  52052. * @hidden Internal
  52053. */
  52054. _updateEffects(): void;
  52055. /**
  52056. * Internal
  52057. * @returns if all the contained post processes are ready.
  52058. * @hidden
  52059. */
  52060. _isReady(): boolean;
  52061. }
  52062. }
  52063. declare module "babylonjs/Shaders/displayPass.fragment" {
  52064. /** @hidden */
  52065. export var displayPassPixelShader: {
  52066. name: string;
  52067. shader: string;
  52068. };
  52069. }
  52070. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  52071. import { Nullable } from "babylonjs/types";
  52072. import { Camera } from "babylonjs/Cameras/camera";
  52073. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52074. import { Engine } from "babylonjs/Engines/engine";
  52075. import "babylonjs/Shaders/displayPass.fragment";
  52076. /**
  52077. * DisplayPassPostProcess which produces an output the same as it's input
  52078. */
  52079. export class DisplayPassPostProcess extends PostProcess {
  52080. /**
  52081. * Creates the DisplayPassPostProcess
  52082. * @param name The name of the effect.
  52083. * @param options The required width/height ratio to downsize to before computing the render pass.
  52084. * @param camera The camera to apply the render pass to.
  52085. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52086. * @param engine The engine which the post process will be applied. (default: current engine)
  52087. * @param reusable If the post process can be reused on the same frame. (default: false)
  52088. */
  52089. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52090. }
  52091. }
  52092. declare module "babylonjs/Shaders/filter.fragment" {
  52093. /** @hidden */
  52094. export var filterPixelShader: {
  52095. name: string;
  52096. shader: string;
  52097. };
  52098. }
  52099. declare module "babylonjs/PostProcesses/filterPostProcess" {
  52100. import { Nullable } from "babylonjs/types";
  52101. import { Matrix } from "babylonjs/Maths/math";
  52102. import { Camera } from "babylonjs/Cameras/camera";
  52103. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52104. import { Engine } from "babylonjs/Engines/engine";
  52105. import "babylonjs/Shaders/filter.fragment";
  52106. /**
  52107. * Applies a kernel filter to the image
  52108. */
  52109. export class FilterPostProcess extends PostProcess {
  52110. /** The matrix to be applied to the image */
  52111. kernelMatrix: Matrix;
  52112. /**
  52113. *
  52114. * @param name The name of the effect.
  52115. * @param kernelMatrix The matrix to be applied to the image
  52116. * @param options The required width/height ratio to downsize to before computing the render pass.
  52117. * @param camera The camera to apply the render pass to.
  52118. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52119. * @param engine The engine which the post process will be applied. (default: current engine)
  52120. * @param reusable If the post process can be reused on the same frame. (default: false)
  52121. */
  52122. constructor(name: string,
  52123. /** The matrix to be applied to the image */
  52124. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52125. }
  52126. }
  52127. declare module "babylonjs/Shaders/fxaa.fragment" {
  52128. /** @hidden */
  52129. export var fxaaPixelShader: {
  52130. name: string;
  52131. shader: string;
  52132. };
  52133. }
  52134. declare module "babylonjs/Shaders/fxaa.vertex" {
  52135. /** @hidden */
  52136. export var fxaaVertexShader: {
  52137. name: string;
  52138. shader: string;
  52139. };
  52140. }
  52141. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  52142. import { Nullable } from "babylonjs/types";
  52143. import { Camera } from "babylonjs/Cameras/camera";
  52144. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52145. import { Engine } from "babylonjs/Engines/engine";
  52146. import "babylonjs/Shaders/fxaa.fragment";
  52147. import "babylonjs/Shaders/fxaa.vertex";
  52148. /**
  52149. * Fxaa post process
  52150. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52151. */
  52152. export class FxaaPostProcess extends PostProcess {
  52153. /** @hidden */
  52154. texelWidth: number;
  52155. /** @hidden */
  52156. texelHeight: number;
  52157. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52158. private _getDefines;
  52159. }
  52160. }
  52161. declare module "babylonjs/Shaders/grain.fragment" {
  52162. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52163. /** @hidden */
  52164. export var grainPixelShader: {
  52165. name: string;
  52166. shader: string;
  52167. };
  52168. }
  52169. declare module "babylonjs/PostProcesses/grainPostProcess" {
  52170. import { Nullable } from "babylonjs/types";
  52171. import { Camera } from "babylonjs/Cameras/camera";
  52172. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52173. import { Engine } from "babylonjs/Engines/engine";
  52174. import "babylonjs/Shaders/grain.fragment";
  52175. /**
  52176. * The GrainPostProcess adds noise to the image at mid luminance levels
  52177. */
  52178. export class GrainPostProcess extends PostProcess {
  52179. /**
  52180. * The intensity of the grain added (default: 30)
  52181. */
  52182. intensity: number;
  52183. /**
  52184. * If the grain should be randomized on every frame
  52185. */
  52186. animated: boolean;
  52187. /**
  52188. * Creates a new instance of @see GrainPostProcess
  52189. * @param name The name of the effect.
  52190. * @param options The required width/height ratio to downsize to before computing the render pass.
  52191. * @param camera The camera to apply the render pass to.
  52192. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52193. * @param engine The engine which the post process will be applied. (default: current engine)
  52194. * @param reusable If the post process can be reused on the same frame. (default: false)
  52195. * @param textureType Type of textures used when performing the post process. (default: 0)
  52196. * @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)
  52197. */
  52198. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52199. }
  52200. }
  52201. declare module "babylonjs/Shaders/highlights.fragment" {
  52202. /** @hidden */
  52203. export var highlightsPixelShader: {
  52204. name: string;
  52205. shader: string;
  52206. };
  52207. }
  52208. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  52209. import { Nullable } from "babylonjs/types";
  52210. import { Camera } from "babylonjs/Cameras/camera";
  52211. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52212. import { Engine } from "babylonjs/Engines/engine";
  52213. import "babylonjs/Shaders/highlights.fragment";
  52214. /**
  52215. * Extracts highlights from the image
  52216. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52217. */
  52218. export class HighlightsPostProcess extends PostProcess {
  52219. /**
  52220. * Extracts highlights from the image
  52221. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52222. * @param name The name of the effect.
  52223. * @param options The required width/height ratio to downsize to before computing the render pass.
  52224. * @param camera The camera to apply the render pass to.
  52225. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52226. * @param engine The engine which the post process will be applied. (default: current engine)
  52227. * @param reusable If the post process can be reused on the same frame. (default: false)
  52228. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52229. */
  52230. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52231. }
  52232. }
  52233. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  52234. /** @hidden */
  52235. export var mrtFragmentDeclaration: {
  52236. name: string;
  52237. shader: string;
  52238. };
  52239. }
  52240. declare module "babylonjs/Shaders/geometry.fragment" {
  52241. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  52242. /** @hidden */
  52243. export var geometryPixelShader: {
  52244. name: string;
  52245. shader: string;
  52246. };
  52247. }
  52248. declare module "babylonjs/Shaders/geometry.vertex" {
  52249. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52250. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52251. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52252. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52253. /** @hidden */
  52254. export var geometryVertexShader: {
  52255. name: string;
  52256. shader: string;
  52257. };
  52258. }
  52259. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  52260. import { Matrix } from "babylonjs/Maths/math";
  52261. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52262. import { Mesh } from "babylonjs/Meshes/mesh";
  52263. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  52264. import { Effect } from "babylonjs/Materials/effect";
  52265. import { Scene } from "babylonjs/scene";
  52266. import "babylonjs/Shaders/geometry.fragment";
  52267. import "babylonjs/Shaders/geometry.vertex";
  52268. /**
  52269. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  52270. */
  52271. export class GeometryBufferRenderer {
  52272. /**
  52273. * Constant used to retrieve the position texture index in the G-Buffer textures array
  52274. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  52275. */
  52276. static readonly POSITION_TEXTURE_TYPE: number;
  52277. /**
  52278. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  52279. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  52280. */
  52281. static readonly VELOCITY_TEXTURE_TYPE: number;
  52282. /**
  52283. * Dictionary used to store the previous transformation matrices of each rendered mesh
  52284. * in order to compute objects velocities when enableVelocity is set to "true"
  52285. * @hidden
  52286. */
  52287. _previousTransformationMatrices: {
  52288. [index: number]: Matrix;
  52289. };
  52290. private _scene;
  52291. private _multiRenderTarget;
  52292. private _ratio;
  52293. private _enablePosition;
  52294. private _enableVelocity;
  52295. private _positionIndex;
  52296. private _velocityIndex;
  52297. protected _effect: Effect;
  52298. protected _cachedDefines: string;
  52299. /**
  52300. * Set the render list (meshes to be rendered) used in the G buffer.
  52301. */
  52302. renderList: Mesh[];
  52303. /**
  52304. * Gets wether or not G buffer are supported by the running hardware.
  52305. * This requires draw buffer supports
  52306. */
  52307. readonly isSupported: boolean;
  52308. /**
  52309. * Returns the index of the given texture type in the G-Buffer textures array
  52310. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  52311. * @returns the index of the given texture type in the G-Buffer textures array
  52312. */
  52313. getTextureIndex(textureType: number): number;
  52314. /**
  52315. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  52316. */
  52317. /**
  52318. * Sets whether or not objects positions are enabled for the G buffer.
  52319. */
  52320. enablePosition: boolean;
  52321. /**
  52322. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  52323. */
  52324. /**
  52325. * Sets wether or not objects velocities are enabled for the G buffer.
  52326. */
  52327. enableVelocity: boolean;
  52328. /**
  52329. * Gets the scene associated with the buffer.
  52330. */
  52331. readonly scene: Scene;
  52332. /**
  52333. * Gets the ratio used by the buffer during its creation.
  52334. * How big is the buffer related to the main canvas.
  52335. */
  52336. readonly ratio: number;
  52337. /** @hidden */
  52338. static _SceneComponentInitialization: (scene: Scene) => void;
  52339. /**
  52340. * Creates a new G Buffer for the scene
  52341. * @param scene The scene the buffer belongs to
  52342. * @param ratio How big is the buffer related to the main canvas.
  52343. */
  52344. constructor(scene: Scene, ratio?: number);
  52345. /**
  52346. * Checks wether everything is ready to render a submesh to the G buffer.
  52347. * @param subMesh the submesh to check readiness for
  52348. * @param useInstances is the mesh drawn using instance or not
  52349. * @returns true if ready otherwise false
  52350. */
  52351. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52352. /**
  52353. * Gets the current underlying G Buffer.
  52354. * @returns the buffer
  52355. */
  52356. getGBuffer(): MultiRenderTarget;
  52357. /**
  52358. * Gets the number of samples used to render the buffer (anti aliasing).
  52359. */
  52360. /**
  52361. * Sets the number of samples used to render the buffer (anti aliasing).
  52362. */
  52363. samples: number;
  52364. /**
  52365. * Disposes the renderer and frees up associated resources.
  52366. */
  52367. dispose(): void;
  52368. protected _createRenderTargets(): void;
  52369. }
  52370. }
  52371. declare module "babylonjs/Shaders/motionBlur.fragment" {
  52372. /** @hidden */
  52373. export var motionBlurPixelShader: {
  52374. name: string;
  52375. shader: string;
  52376. };
  52377. }
  52378. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  52379. import { Nullable } from "babylonjs/types";
  52380. import { Camera } from "babylonjs/Cameras/camera";
  52381. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52382. import { Scene } from "babylonjs/scene";
  52383. import "babylonjs/Shaders/motionBlur.fragment";
  52384. import { Engine } from "babylonjs/Engines/engine";
  52385. /**
  52386. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52387. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52388. * As an example, all you have to do is to create the post-process:
  52389. * var mb = new BABYLON.MotionBlurPostProcess(
  52390. * 'mb', // The name of the effect.
  52391. * scene, // The scene containing the objects to blur according to their velocity.
  52392. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52393. * camera // The camera to apply the render pass to.
  52394. * );
  52395. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52396. */
  52397. export class MotionBlurPostProcess extends PostProcess {
  52398. /**
  52399. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52400. */
  52401. motionStrength: number;
  52402. /**
  52403. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52404. */
  52405. /**
  52406. * Sets the number of iterations to be used for motion blur quality
  52407. */
  52408. motionBlurSamples: number;
  52409. private _motionBlurSamples;
  52410. private _geometryBufferRenderer;
  52411. /**
  52412. * Creates a new instance MotionBlurPostProcess
  52413. * @param name The name of the effect.
  52414. * @param scene The scene containing the objects to blur according to their velocity.
  52415. * @param options The required width/height ratio to downsize to before computing the render pass.
  52416. * @param camera The camera to apply the render pass to.
  52417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52418. * @param engine The engine which the post process will be applied. (default: current engine)
  52419. * @param reusable If the post process can be reused on the same frame. (default: false)
  52420. * @param textureType Type of textures used when performing the post process. (default: 0)
  52421. * @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)
  52422. */
  52423. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52424. /**
  52425. * Disposes the post process.
  52426. * @param camera The camera to dispose the post process on.
  52427. */
  52428. dispose(camera?: Camera): void;
  52429. }
  52430. }
  52431. declare module "babylonjs/Shaders/refraction.fragment" {
  52432. /** @hidden */
  52433. export var refractionPixelShader: {
  52434. name: string;
  52435. shader: string;
  52436. };
  52437. }
  52438. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  52439. import { Color3 } from "babylonjs/Maths/math";
  52440. import { Camera } from "babylonjs/Cameras/camera";
  52441. import { Texture } from "babylonjs/Materials/Textures/texture";
  52442. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52443. import { Engine } from "babylonjs/Engines/engine";
  52444. import "babylonjs/Shaders/refraction.fragment";
  52445. /**
  52446. * Post process which applies a refractin texture
  52447. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52448. */
  52449. export class RefractionPostProcess extends PostProcess {
  52450. /** the base color of the refraction (used to taint the rendering) */
  52451. color: Color3;
  52452. /** simulated refraction depth */
  52453. depth: number;
  52454. /** the coefficient of the base color (0 to remove base color tainting) */
  52455. colorLevel: number;
  52456. private _refTexture;
  52457. private _ownRefractionTexture;
  52458. /**
  52459. * Gets or sets the refraction texture
  52460. * Please note that you are responsible for disposing the texture if you set it manually
  52461. */
  52462. refractionTexture: Texture;
  52463. /**
  52464. * Initializes the RefractionPostProcess
  52465. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52466. * @param name The name of the effect.
  52467. * @param refractionTextureUrl Url of the refraction texture to use
  52468. * @param color the base color of the refraction (used to taint the rendering)
  52469. * @param depth simulated refraction depth
  52470. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52471. * @param camera The camera to apply the render pass to.
  52472. * @param options The required width/height ratio to downsize to before computing the render pass.
  52473. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52474. * @param engine The engine which the post process will be applied. (default: current engine)
  52475. * @param reusable If the post process can be reused on the same frame. (default: false)
  52476. */
  52477. constructor(name: string, refractionTextureUrl: string,
  52478. /** the base color of the refraction (used to taint the rendering) */
  52479. color: Color3,
  52480. /** simulated refraction depth */
  52481. depth: number,
  52482. /** the coefficient of the base color (0 to remove base color tainting) */
  52483. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52484. /**
  52485. * Disposes of the post process
  52486. * @param camera Camera to dispose post process on
  52487. */
  52488. dispose(camera: Camera): void;
  52489. }
  52490. }
  52491. declare module "babylonjs/Shaders/sharpen.fragment" {
  52492. /** @hidden */
  52493. export var sharpenPixelShader: {
  52494. name: string;
  52495. shader: string;
  52496. };
  52497. }
  52498. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  52499. import { Nullable } from "babylonjs/types";
  52500. import { Camera } from "babylonjs/Cameras/camera";
  52501. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52502. import "babylonjs/Shaders/sharpen.fragment";
  52503. import { Engine } from "babylonjs/Engines/engine";
  52504. /**
  52505. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52506. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52507. */
  52508. export class SharpenPostProcess extends PostProcess {
  52509. /**
  52510. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52511. */
  52512. colorAmount: number;
  52513. /**
  52514. * How much sharpness should be applied (default: 0.3)
  52515. */
  52516. edgeAmount: number;
  52517. /**
  52518. * Creates a new instance ConvolutionPostProcess
  52519. * @param name The name of the effect.
  52520. * @param options The required width/height ratio to downsize to before computing the render pass.
  52521. * @param camera The camera to apply the render pass to.
  52522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52523. * @param engine The engine which the post process will be applied. (default: current engine)
  52524. * @param reusable If the post process can be reused on the same frame. (default: false)
  52525. * @param textureType Type of textures used when performing the post process. (default: 0)
  52526. * @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)
  52527. */
  52528. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52529. }
  52530. }
  52531. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  52532. import { Nullable } from "babylonjs/types";
  52533. import { Camera } from "babylonjs/Cameras/camera";
  52534. import { Engine } from "babylonjs/Engines/engine";
  52535. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52536. /**
  52537. * PostProcessRenderPipeline
  52538. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52539. */
  52540. export class PostProcessRenderPipeline {
  52541. private engine;
  52542. private _renderEffects;
  52543. private _renderEffectsForIsolatedPass;
  52544. /**
  52545. * @hidden
  52546. */
  52547. protected _cameras: Camera[];
  52548. /** @hidden */
  52549. _name: string;
  52550. /**
  52551. * Initializes a PostProcessRenderPipeline
  52552. * @param engine engine to add the pipeline to
  52553. * @param name name of the pipeline
  52554. */
  52555. constructor(engine: Engine, name: string);
  52556. /**
  52557. * "PostProcessRenderPipeline"
  52558. * @returns "PostProcessRenderPipeline"
  52559. */
  52560. getClassName(): string;
  52561. /**
  52562. * If all the render effects in the pipeline are support
  52563. */
  52564. readonly isSupported: boolean;
  52565. /**
  52566. * Adds an effect to the pipeline
  52567. * @param renderEffect the effect to add
  52568. */
  52569. addEffect(renderEffect: PostProcessRenderEffect): void;
  52570. /** @hidden */
  52571. _rebuild(): void;
  52572. /** @hidden */
  52573. _enableEffect(renderEffectName: string, cameras: Camera): void;
  52574. /** @hidden */
  52575. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52576. /** @hidden */
  52577. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52578. /** @hidden */
  52579. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52580. /** @hidden */
  52581. _attachCameras(cameras: Camera, unique: boolean): void;
  52582. /** @hidden */
  52583. _attachCameras(cameras: Camera[], unique: boolean): void;
  52584. /** @hidden */
  52585. _detachCameras(cameras: Camera): void;
  52586. /** @hidden */
  52587. _detachCameras(cameras: Nullable<Camera[]>): void;
  52588. /** @hidden */
  52589. _update(): void;
  52590. /** @hidden */
  52591. _reset(): void;
  52592. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52593. /**
  52594. * Disposes of the pipeline
  52595. */
  52596. dispose(): void;
  52597. }
  52598. }
  52599. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  52600. import { IAnimatable } from "babylonjs/Misc/tools";
  52601. import { Camera } from "babylonjs/Cameras/camera";
  52602. import { IDisposable } from "babylonjs/scene";
  52603. import { Scene } from "babylonjs/scene";
  52604. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  52605. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  52606. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  52607. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  52608. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  52609. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52610. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  52611. import { Animation } from "babylonjs/Animations/animation";
  52612. /**
  52613. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52614. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52615. */
  52616. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52617. private _scene;
  52618. private _camerasToBeAttached;
  52619. /**
  52620. * ID of the sharpen post process,
  52621. */
  52622. private readonly SharpenPostProcessId;
  52623. /**
  52624. * @ignore
  52625. * ID of the image processing post process;
  52626. */
  52627. readonly ImageProcessingPostProcessId: string;
  52628. /**
  52629. * @ignore
  52630. * ID of the Fast Approximate Anti-Aliasing post process;
  52631. */
  52632. readonly FxaaPostProcessId: string;
  52633. /**
  52634. * ID of the chromatic aberration post process,
  52635. */
  52636. private readonly ChromaticAberrationPostProcessId;
  52637. /**
  52638. * ID of the grain post process
  52639. */
  52640. private readonly GrainPostProcessId;
  52641. /**
  52642. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52643. */
  52644. sharpen: SharpenPostProcess;
  52645. private _sharpenEffect;
  52646. private bloom;
  52647. /**
  52648. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52649. */
  52650. depthOfField: DepthOfFieldEffect;
  52651. /**
  52652. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52653. */
  52654. fxaa: FxaaPostProcess;
  52655. /**
  52656. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52657. */
  52658. imageProcessing: ImageProcessingPostProcess;
  52659. /**
  52660. * Chromatic aberration post process which will shift rgb colors in the image
  52661. */
  52662. chromaticAberration: ChromaticAberrationPostProcess;
  52663. private _chromaticAberrationEffect;
  52664. /**
  52665. * Grain post process which add noise to the image
  52666. */
  52667. grain: GrainPostProcess;
  52668. private _grainEffect;
  52669. /**
  52670. * Glow post process which adds a glow to emmisive areas of the image
  52671. */
  52672. private _glowLayer;
  52673. /**
  52674. * Animations which can be used to tweak settings over a period of time
  52675. */
  52676. animations: Animation[];
  52677. private _imageProcessingConfigurationObserver;
  52678. private _sharpenEnabled;
  52679. private _bloomEnabled;
  52680. private _depthOfFieldEnabled;
  52681. private _depthOfFieldBlurLevel;
  52682. private _fxaaEnabled;
  52683. private _imageProcessingEnabled;
  52684. private _defaultPipelineTextureType;
  52685. private _bloomScale;
  52686. private _chromaticAberrationEnabled;
  52687. private _grainEnabled;
  52688. private _buildAllowed;
  52689. /**
  52690. * Enable or disable the sharpen process from the pipeline
  52691. */
  52692. sharpenEnabled: boolean;
  52693. private _resizeObserver;
  52694. private _hardwareScaleLevel;
  52695. private _bloomKernel;
  52696. /**
  52697. * Specifies the size of the bloom blur kernel, relative to the final output size
  52698. */
  52699. bloomKernel: number;
  52700. /**
  52701. * Specifies the weight of the bloom in the final rendering
  52702. */
  52703. private _bloomWeight;
  52704. /**
  52705. * Specifies the luma threshold for the area that will be blurred by the bloom
  52706. */
  52707. private _bloomThreshold;
  52708. private _hdr;
  52709. /**
  52710. * The strength of the bloom.
  52711. */
  52712. bloomWeight: number;
  52713. /**
  52714. * The strength of the bloom.
  52715. */
  52716. bloomThreshold: number;
  52717. /**
  52718. * The scale of the bloom, lower value will provide better performance.
  52719. */
  52720. bloomScale: number;
  52721. /**
  52722. * Enable or disable the bloom from the pipeline
  52723. */
  52724. bloomEnabled: boolean;
  52725. private _rebuildBloom;
  52726. /**
  52727. * If the depth of field is enabled.
  52728. */
  52729. depthOfFieldEnabled: boolean;
  52730. /**
  52731. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52732. */
  52733. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52734. /**
  52735. * If the anti aliasing is enabled.
  52736. */
  52737. fxaaEnabled: boolean;
  52738. private _samples;
  52739. /**
  52740. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52741. */
  52742. samples: number;
  52743. /**
  52744. * If image processing is enabled.
  52745. */
  52746. imageProcessingEnabled: boolean;
  52747. /**
  52748. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52749. */
  52750. glowLayerEnabled: boolean;
  52751. /**
  52752. * Enable or disable the chromaticAberration process from the pipeline
  52753. */
  52754. chromaticAberrationEnabled: boolean;
  52755. /**
  52756. * Enable or disable the grain process from the pipeline
  52757. */
  52758. grainEnabled: boolean;
  52759. /**
  52760. * @constructor
  52761. * @param name - The rendering pipeline name (default: "")
  52762. * @param hdr - If high dynamic range textures should be used (default: true)
  52763. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52764. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52765. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52766. */
  52767. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52768. /**
  52769. * Force the compilation of the entire pipeline.
  52770. */
  52771. prepare(): void;
  52772. private _hasCleared;
  52773. private _prevPostProcess;
  52774. private _prevPrevPostProcess;
  52775. private _setAutoClearAndTextureSharing;
  52776. private _depthOfFieldSceneObserver;
  52777. private _buildPipeline;
  52778. private _disposePostProcesses;
  52779. /**
  52780. * Adds a camera to the pipeline
  52781. * @param camera the camera to be added
  52782. */
  52783. addCamera(camera: Camera): void;
  52784. /**
  52785. * Removes a camera from the pipeline
  52786. * @param camera the camera to remove
  52787. */
  52788. removeCamera(camera: Camera): void;
  52789. /**
  52790. * Dispose of the pipeline and stop all post processes
  52791. */
  52792. dispose(): void;
  52793. /**
  52794. * Serialize the rendering pipeline (Used when exporting)
  52795. * @returns the serialized object
  52796. */
  52797. serialize(): any;
  52798. /**
  52799. * Parse the serialized pipeline
  52800. * @param source Source pipeline.
  52801. * @param scene The scene to load the pipeline to.
  52802. * @param rootUrl The URL of the serialized pipeline.
  52803. * @returns An instantiated pipeline from the serialized object.
  52804. */
  52805. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52806. }
  52807. }
  52808. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  52809. /** @hidden */
  52810. export var lensHighlightsPixelShader: {
  52811. name: string;
  52812. shader: string;
  52813. };
  52814. }
  52815. declare module "babylonjs/Shaders/depthOfField.fragment" {
  52816. /** @hidden */
  52817. export var depthOfFieldPixelShader: {
  52818. name: string;
  52819. shader: string;
  52820. };
  52821. }
  52822. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  52823. import { Camera } from "babylonjs/Cameras/camera";
  52824. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52825. import { Scene } from "babylonjs/scene";
  52826. import "babylonjs/Shaders/chromaticAberration.fragment";
  52827. import "babylonjs/Shaders/lensHighlights.fragment";
  52828. import "babylonjs/Shaders/depthOfField.fragment";
  52829. /**
  52830. * BABYLON.JS Chromatic Aberration GLSL Shader
  52831. * Author: Olivier Guyot
  52832. * Separates very slightly R, G and B colors on the edges of the screen
  52833. * Inspired by Francois Tarlier & Martins Upitis
  52834. */
  52835. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52836. /**
  52837. * @ignore
  52838. * The chromatic aberration PostProcess id in the pipeline
  52839. */
  52840. LensChromaticAberrationEffect: string;
  52841. /**
  52842. * @ignore
  52843. * The highlights enhancing PostProcess id in the pipeline
  52844. */
  52845. HighlightsEnhancingEffect: string;
  52846. /**
  52847. * @ignore
  52848. * The depth-of-field PostProcess id in the pipeline
  52849. */
  52850. LensDepthOfFieldEffect: string;
  52851. private _scene;
  52852. private _depthTexture;
  52853. private _grainTexture;
  52854. private _chromaticAberrationPostProcess;
  52855. private _highlightsPostProcess;
  52856. private _depthOfFieldPostProcess;
  52857. private _edgeBlur;
  52858. private _grainAmount;
  52859. private _chromaticAberration;
  52860. private _distortion;
  52861. private _highlightsGain;
  52862. private _highlightsThreshold;
  52863. private _dofDistance;
  52864. private _dofAperture;
  52865. private _dofDarken;
  52866. private _dofPentagon;
  52867. private _blurNoise;
  52868. /**
  52869. * @constructor
  52870. *
  52871. * Effect parameters are as follow:
  52872. * {
  52873. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52874. * edge_blur: number; // from 0 to x (1 for realism)
  52875. * distortion: number; // from 0 to x (1 for realism)
  52876. * grain_amount: number; // from 0 to 1
  52877. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52878. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52879. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52880. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52881. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52882. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52883. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52884. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52885. * }
  52886. * Note: if an effect parameter is unset, effect is disabled
  52887. *
  52888. * @param name The rendering pipeline name
  52889. * @param parameters - An object containing all parameters (see above)
  52890. * @param scene The scene linked to this pipeline
  52891. * @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)
  52892. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52893. */
  52894. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52895. /**
  52896. * Sets the amount of blur at the edges
  52897. * @param amount blur amount
  52898. */
  52899. setEdgeBlur(amount: number): void;
  52900. /**
  52901. * Sets edge blur to 0
  52902. */
  52903. disableEdgeBlur(): void;
  52904. /**
  52905. * Sets the amout of grain
  52906. * @param amount Amount of grain
  52907. */
  52908. setGrainAmount(amount: number): void;
  52909. /**
  52910. * Set grain amount to 0
  52911. */
  52912. disableGrain(): void;
  52913. /**
  52914. * Sets the chromatic aberration amount
  52915. * @param amount amount of chromatic aberration
  52916. */
  52917. setChromaticAberration(amount: number): void;
  52918. /**
  52919. * Sets chromatic aberration amount to 0
  52920. */
  52921. disableChromaticAberration(): void;
  52922. /**
  52923. * Sets the EdgeDistortion amount
  52924. * @param amount amount of EdgeDistortion
  52925. */
  52926. setEdgeDistortion(amount: number): void;
  52927. /**
  52928. * Sets edge distortion to 0
  52929. */
  52930. disableEdgeDistortion(): void;
  52931. /**
  52932. * Sets the FocusDistance amount
  52933. * @param amount amount of FocusDistance
  52934. */
  52935. setFocusDistance(amount: number): void;
  52936. /**
  52937. * Disables depth of field
  52938. */
  52939. disableDepthOfField(): void;
  52940. /**
  52941. * Sets the Aperture amount
  52942. * @param amount amount of Aperture
  52943. */
  52944. setAperture(amount: number): void;
  52945. /**
  52946. * Sets the DarkenOutOfFocus amount
  52947. * @param amount amount of DarkenOutOfFocus
  52948. */
  52949. setDarkenOutOfFocus(amount: number): void;
  52950. /**
  52951. * Creates a pentagon bokeh effect
  52952. */
  52953. enablePentagonBokeh(): void;
  52954. /**
  52955. * Disables the pentagon bokeh effect
  52956. */
  52957. disablePentagonBokeh(): void;
  52958. /**
  52959. * Enables noise blur
  52960. */
  52961. enableNoiseBlur(): void;
  52962. /**
  52963. * Disables noise blur
  52964. */
  52965. disableNoiseBlur(): void;
  52966. /**
  52967. * Sets the HighlightsGain amount
  52968. * @param amount amount of HighlightsGain
  52969. */
  52970. setHighlightsGain(amount: number): void;
  52971. /**
  52972. * Sets the HighlightsThreshold amount
  52973. * @param amount amount of HighlightsThreshold
  52974. */
  52975. setHighlightsThreshold(amount: number): void;
  52976. /**
  52977. * Disables highlights
  52978. */
  52979. disableHighlights(): void;
  52980. /**
  52981. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  52982. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  52983. */
  52984. dispose(disableDepthRender?: boolean): void;
  52985. private _createChromaticAberrationPostProcess;
  52986. private _createHighlightsPostProcess;
  52987. private _createDepthOfFieldPostProcess;
  52988. private _createGrainTexture;
  52989. }
  52990. }
  52991. declare module "babylonjs/Shaders/ssao2.fragment" {
  52992. /** @hidden */
  52993. export var ssao2PixelShader: {
  52994. name: string;
  52995. shader: string;
  52996. };
  52997. }
  52998. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  52999. /** @hidden */
  53000. export var ssaoCombinePixelShader: {
  53001. name: string;
  53002. shader: string;
  53003. };
  53004. }
  53005. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  53006. import { Camera } from "babylonjs/Cameras/camera";
  53007. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53008. import { Scene } from "babylonjs/scene";
  53009. import "babylonjs/Shaders/ssao2.fragment";
  53010. import "babylonjs/Shaders/ssaoCombine.fragment";
  53011. /**
  53012. * Render pipeline to produce ssao effect
  53013. */
  53014. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53015. /**
  53016. * @ignore
  53017. * The PassPostProcess id in the pipeline that contains the original scene color
  53018. */
  53019. SSAOOriginalSceneColorEffect: string;
  53020. /**
  53021. * @ignore
  53022. * The SSAO PostProcess id in the pipeline
  53023. */
  53024. SSAORenderEffect: string;
  53025. /**
  53026. * @ignore
  53027. * The horizontal blur PostProcess id in the pipeline
  53028. */
  53029. SSAOBlurHRenderEffect: string;
  53030. /**
  53031. * @ignore
  53032. * The vertical blur PostProcess id in the pipeline
  53033. */
  53034. SSAOBlurVRenderEffect: string;
  53035. /**
  53036. * @ignore
  53037. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53038. */
  53039. SSAOCombineRenderEffect: string;
  53040. /**
  53041. * The output strength of the SSAO post-process. Default value is 1.0.
  53042. */
  53043. totalStrength: number;
  53044. /**
  53045. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53046. */
  53047. maxZ: number;
  53048. /**
  53049. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53050. */
  53051. minZAspect: number;
  53052. private _samples;
  53053. /**
  53054. * Number of samples used for the SSAO calculations. Default value is 8
  53055. */
  53056. samples: number;
  53057. private _textureSamples;
  53058. /**
  53059. * Number of samples to use for antialiasing
  53060. */
  53061. textureSamples: number;
  53062. /**
  53063. * Ratio object used for SSAO ratio and blur ratio
  53064. */
  53065. private _ratio;
  53066. /**
  53067. * Dynamically generated sphere sampler.
  53068. */
  53069. private _sampleSphere;
  53070. /**
  53071. * Blur filter offsets
  53072. */
  53073. private _samplerOffsets;
  53074. private _expensiveBlur;
  53075. /**
  53076. * If bilateral blur should be used
  53077. */
  53078. expensiveBlur: boolean;
  53079. /**
  53080. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  53081. */
  53082. radius: number;
  53083. /**
  53084. * The base color of the SSAO post-process
  53085. * The final result is "base + ssao" between [0, 1]
  53086. */
  53087. base: number;
  53088. /**
  53089. * Support test.
  53090. */
  53091. static readonly IsSupported: boolean;
  53092. private _scene;
  53093. private _depthTexture;
  53094. private _normalTexture;
  53095. private _randomTexture;
  53096. private _originalColorPostProcess;
  53097. private _ssaoPostProcess;
  53098. private _blurHPostProcess;
  53099. private _blurVPostProcess;
  53100. private _ssaoCombinePostProcess;
  53101. private _firstUpdate;
  53102. /**
  53103. * @constructor
  53104. * @param name The rendering pipeline name
  53105. * @param scene The scene linked to this pipeline
  53106. * @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 }
  53107. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53108. */
  53109. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53110. /**
  53111. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53112. */
  53113. dispose(disableGeometryBufferRenderer?: boolean): void;
  53114. private _createBlurPostProcess;
  53115. /** @hidden */
  53116. _rebuild(): void;
  53117. private _bits;
  53118. private _radicalInverse_VdC;
  53119. private _hammersley;
  53120. private _hemisphereSample_uniform;
  53121. private _generateHemisphere;
  53122. private _createSSAOPostProcess;
  53123. private _createSSAOCombinePostProcess;
  53124. private _createRandomTexture;
  53125. /**
  53126. * Serialize the rendering pipeline (Used when exporting)
  53127. * @returns the serialized object
  53128. */
  53129. serialize(): any;
  53130. /**
  53131. * Parse the serialized pipeline
  53132. * @param source Source pipeline.
  53133. * @param scene The scene to load the pipeline to.
  53134. * @param rootUrl The URL of the serialized pipeline.
  53135. * @returns An instantiated pipeline from the serialized object.
  53136. */
  53137. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  53138. }
  53139. }
  53140. declare module "babylonjs/Shaders/ssao.fragment" {
  53141. /** @hidden */
  53142. export var ssaoPixelShader: {
  53143. name: string;
  53144. shader: string;
  53145. };
  53146. }
  53147. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  53148. import { Camera } from "babylonjs/Cameras/camera";
  53149. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53150. import { Scene } from "babylonjs/scene";
  53151. import "babylonjs/Shaders/ssao.fragment";
  53152. import "babylonjs/Shaders/ssaoCombine.fragment";
  53153. /**
  53154. * Render pipeline to produce ssao effect
  53155. */
  53156. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  53157. /**
  53158. * @ignore
  53159. * The PassPostProcess id in the pipeline that contains the original scene color
  53160. */
  53161. SSAOOriginalSceneColorEffect: string;
  53162. /**
  53163. * @ignore
  53164. * The SSAO PostProcess id in the pipeline
  53165. */
  53166. SSAORenderEffect: string;
  53167. /**
  53168. * @ignore
  53169. * The horizontal blur PostProcess id in the pipeline
  53170. */
  53171. SSAOBlurHRenderEffect: string;
  53172. /**
  53173. * @ignore
  53174. * The vertical blur PostProcess id in the pipeline
  53175. */
  53176. SSAOBlurVRenderEffect: string;
  53177. /**
  53178. * @ignore
  53179. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53180. */
  53181. SSAOCombineRenderEffect: string;
  53182. /**
  53183. * The output strength of the SSAO post-process. Default value is 1.0.
  53184. */
  53185. totalStrength: number;
  53186. /**
  53187. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  53188. */
  53189. radius: number;
  53190. /**
  53191. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  53192. * Must not be equal to fallOff and superior to fallOff.
  53193. * Default value is 0.975
  53194. */
  53195. area: number;
  53196. /**
  53197. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  53198. * Must not be equal to area and inferior to area.
  53199. * Default value is 0.0
  53200. */
  53201. fallOff: number;
  53202. /**
  53203. * The base color of the SSAO post-process
  53204. * The final result is "base + ssao" between [0, 1]
  53205. */
  53206. base: number;
  53207. private _scene;
  53208. private _depthTexture;
  53209. private _randomTexture;
  53210. private _originalColorPostProcess;
  53211. private _ssaoPostProcess;
  53212. private _blurHPostProcess;
  53213. private _blurVPostProcess;
  53214. private _ssaoCombinePostProcess;
  53215. private _firstUpdate;
  53216. /**
  53217. * @constructor
  53218. * @param name - The rendering pipeline name
  53219. * @param scene - The scene linked to this pipeline
  53220. * @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 }
  53221. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  53222. */
  53223. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53224. /**
  53225. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53226. */
  53227. dispose(disableDepthRender?: boolean): void;
  53228. private _createBlurPostProcess;
  53229. /** @hidden */
  53230. _rebuild(): void;
  53231. private _createSSAOPostProcess;
  53232. private _createSSAOCombinePostProcess;
  53233. private _createRandomTexture;
  53234. }
  53235. }
  53236. declare module "babylonjs/Shaders/standard.fragment" {
  53237. /** @hidden */
  53238. export var standardPixelShader: {
  53239. name: string;
  53240. shader: string;
  53241. };
  53242. }
  53243. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  53244. import { Nullable } from "babylonjs/types";
  53245. import { IAnimatable } from "babylonjs/Misc/tools";
  53246. import { Camera } from "babylonjs/Cameras/camera";
  53247. import { Texture } from "babylonjs/Materials/Textures/texture";
  53248. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53249. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53250. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53251. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  53252. import { IDisposable } from "babylonjs/scene";
  53253. import { SpotLight } from "babylonjs/Lights/spotLight";
  53254. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  53255. import { Scene } from "babylonjs/scene";
  53256. import { Animation } from "babylonjs/Animations/animation";
  53257. import "babylonjs/Shaders/standard.fragment";
  53258. /**
  53259. * Standard rendering pipeline
  53260. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53261. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53262. */
  53263. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53264. /**
  53265. * Public members
  53266. */
  53267. /**
  53268. * Post-process which contains the original scene color before the pipeline applies all the effects
  53269. */
  53270. originalPostProcess: Nullable<PostProcess>;
  53271. /**
  53272. * Post-process used to down scale an image x4
  53273. */
  53274. downSampleX4PostProcess: Nullable<PostProcess>;
  53275. /**
  53276. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53277. */
  53278. brightPassPostProcess: Nullable<PostProcess>;
  53279. /**
  53280. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53281. */
  53282. blurHPostProcesses: PostProcess[];
  53283. /**
  53284. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53285. */
  53286. blurVPostProcesses: PostProcess[];
  53287. /**
  53288. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53289. */
  53290. textureAdderPostProcess: Nullable<PostProcess>;
  53291. /**
  53292. * Post-process used to create volumetric lighting effect
  53293. */
  53294. volumetricLightPostProcess: Nullable<PostProcess>;
  53295. /**
  53296. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53297. */
  53298. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53299. /**
  53300. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53301. */
  53302. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53303. /**
  53304. * Post-process used to merge the volumetric light effect and the real scene color
  53305. */
  53306. volumetricLightMergePostProces: Nullable<PostProcess>;
  53307. /**
  53308. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53309. */
  53310. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53311. /**
  53312. * Base post-process used to calculate the average luminance of the final image for HDR
  53313. */
  53314. luminancePostProcess: Nullable<PostProcess>;
  53315. /**
  53316. * Post-processes used to create down sample post-processes in order to get
  53317. * the average luminance of the final image for HDR
  53318. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53319. */
  53320. luminanceDownSamplePostProcesses: PostProcess[];
  53321. /**
  53322. * Post-process used to create a HDR effect (light adaptation)
  53323. */
  53324. hdrPostProcess: Nullable<PostProcess>;
  53325. /**
  53326. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53327. */
  53328. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53329. /**
  53330. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53331. */
  53332. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53333. /**
  53334. * Post-process used to merge the final HDR post-process and the real scene color
  53335. */
  53336. hdrFinalPostProcess: Nullable<PostProcess>;
  53337. /**
  53338. * Post-process used to create a lens flare effect
  53339. */
  53340. lensFlarePostProcess: Nullable<PostProcess>;
  53341. /**
  53342. * Post-process that merges the result of the lens flare post-process and the real scene color
  53343. */
  53344. lensFlareComposePostProcess: Nullable<PostProcess>;
  53345. /**
  53346. * Post-process used to create a motion blur effect
  53347. */
  53348. motionBlurPostProcess: Nullable<PostProcess>;
  53349. /**
  53350. * Post-process used to create a depth of field effect
  53351. */
  53352. depthOfFieldPostProcess: Nullable<PostProcess>;
  53353. /**
  53354. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53355. */
  53356. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53357. /**
  53358. * Represents the brightness threshold in order to configure the illuminated surfaces
  53359. */
  53360. brightThreshold: number;
  53361. /**
  53362. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53363. */
  53364. blurWidth: number;
  53365. /**
  53366. * Sets if the blur for highlighted surfaces must be only horizontal
  53367. */
  53368. horizontalBlur: boolean;
  53369. /**
  53370. * Sets the overall exposure used by the pipeline
  53371. */
  53372. exposure: number;
  53373. /**
  53374. * Texture used typically to simulate "dirty" on camera lens
  53375. */
  53376. lensTexture: Nullable<Texture>;
  53377. /**
  53378. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53379. */
  53380. volumetricLightCoefficient: number;
  53381. /**
  53382. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53383. */
  53384. volumetricLightPower: number;
  53385. /**
  53386. * Used the set the blur intensity to smooth the volumetric lights
  53387. */
  53388. volumetricLightBlurScale: number;
  53389. /**
  53390. * Light (spot or directional) used to generate the volumetric lights rays
  53391. * The source light must have a shadow generate so the pipeline can get its
  53392. * depth map
  53393. */
  53394. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53395. /**
  53396. * For eye adaptation, represents the minimum luminance the eye can see
  53397. */
  53398. hdrMinimumLuminance: number;
  53399. /**
  53400. * For eye adaptation, represents the decrease luminance speed
  53401. */
  53402. hdrDecreaseRate: number;
  53403. /**
  53404. * For eye adaptation, represents the increase luminance speed
  53405. */
  53406. hdrIncreaseRate: number;
  53407. /**
  53408. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53409. */
  53410. lensColorTexture: Nullable<Texture>;
  53411. /**
  53412. * The overall strengh for the lens flare effect
  53413. */
  53414. lensFlareStrength: number;
  53415. /**
  53416. * Dispersion coefficient for lens flare ghosts
  53417. */
  53418. lensFlareGhostDispersal: number;
  53419. /**
  53420. * Main lens flare halo width
  53421. */
  53422. lensFlareHaloWidth: number;
  53423. /**
  53424. * Based on the lens distortion effect, defines how much the lens flare result
  53425. * is distorted
  53426. */
  53427. lensFlareDistortionStrength: number;
  53428. /**
  53429. * Lens star texture must be used to simulate rays on the flares and is available
  53430. * in the documentation
  53431. */
  53432. lensStarTexture: Nullable<Texture>;
  53433. /**
  53434. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53435. * flare effect by taking account of the dirt texture
  53436. */
  53437. lensFlareDirtTexture: Nullable<Texture>;
  53438. /**
  53439. * Represents the focal length for the depth of field effect
  53440. */
  53441. depthOfFieldDistance: number;
  53442. /**
  53443. * Represents the blur intensity for the blurred part of the depth of field effect
  53444. */
  53445. depthOfFieldBlurWidth: number;
  53446. /**
  53447. * For motion blur, defines how much the image is blurred by the movement
  53448. */
  53449. motionStrength: number;
  53450. /**
  53451. * List of animations for the pipeline (IAnimatable implementation)
  53452. */
  53453. animations: Animation[];
  53454. /**
  53455. * Private members
  53456. */
  53457. private _scene;
  53458. private _currentDepthOfFieldSource;
  53459. private _basePostProcess;
  53460. private _hdrCurrentLuminance;
  53461. private _floatTextureType;
  53462. private _ratio;
  53463. private _bloomEnabled;
  53464. private _depthOfFieldEnabled;
  53465. private _vlsEnabled;
  53466. private _lensFlareEnabled;
  53467. private _hdrEnabled;
  53468. private _motionBlurEnabled;
  53469. private _fxaaEnabled;
  53470. private _motionBlurSamples;
  53471. private _volumetricLightStepsCount;
  53472. private _samples;
  53473. /**
  53474. * @ignore
  53475. * Specifies if the bloom pipeline is enabled
  53476. */
  53477. BloomEnabled: boolean;
  53478. /**
  53479. * @ignore
  53480. * Specifies if the depth of field pipeline is enabed
  53481. */
  53482. DepthOfFieldEnabled: boolean;
  53483. /**
  53484. * @ignore
  53485. * Specifies if the lens flare pipeline is enabed
  53486. */
  53487. LensFlareEnabled: boolean;
  53488. /**
  53489. * @ignore
  53490. * Specifies if the HDR pipeline is enabled
  53491. */
  53492. HDREnabled: boolean;
  53493. /**
  53494. * @ignore
  53495. * Specifies if the volumetric lights scattering effect is enabled
  53496. */
  53497. VLSEnabled: boolean;
  53498. /**
  53499. * @ignore
  53500. * Specifies if the motion blur effect is enabled
  53501. */
  53502. MotionBlurEnabled: boolean;
  53503. /**
  53504. * Specifies if anti-aliasing is enabled
  53505. */
  53506. fxaaEnabled: boolean;
  53507. /**
  53508. * Specifies the number of steps used to calculate the volumetric lights
  53509. * Typically in interval [50, 200]
  53510. */
  53511. volumetricLightStepsCount: number;
  53512. /**
  53513. * Specifies the number of samples used for the motion blur effect
  53514. * Typically in interval [16, 64]
  53515. */
  53516. motionBlurSamples: number;
  53517. /**
  53518. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53519. */
  53520. samples: number;
  53521. /**
  53522. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53523. * @constructor
  53524. * @param name The rendering pipeline name
  53525. * @param scene The scene linked to this pipeline
  53526. * @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)
  53527. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53528. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53529. */
  53530. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53531. private _buildPipeline;
  53532. private _createDownSampleX4PostProcess;
  53533. private _createBrightPassPostProcess;
  53534. private _createBlurPostProcesses;
  53535. private _createTextureAdderPostProcess;
  53536. private _createVolumetricLightPostProcess;
  53537. private _createLuminancePostProcesses;
  53538. private _createHdrPostProcess;
  53539. private _createLensFlarePostProcess;
  53540. private _createDepthOfFieldPostProcess;
  53541. private _createMotionBlurPostProcess;
  53542. private _getDepthTexture;
  53543. private _disposePostProcesses;
  53544. /**
  53545. * Dispose of the pipeline and stop all post processes
  53546. */
  53547. dispose(): void;
  53548. /**
  53549. * Serialize the rendering pipeline (Used when exporting)
  53550. * @returns the serialized object
  53551. */
  53552. serialize(): any;
  53553. /**
  53554. * Parse the serialized pipeline
  53555. * @param source Source pipeline.
  53556. * @param scene The scene to load the pipeline to.
  53557. * @param rootUrl The URL of the serialized pipeline.
  53558. * @returns An instantiated pipeline from the serialized object.
  53559. */
  53560. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53561. /**
  53562. * Luminance steps
  53563. */
  53564. static LuminanceSteps: number;
  53565. }
  53566. }
  53567. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  53568. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  53569. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  53570. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  53571. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  53572. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  53573. }
  53574. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  53575. import { Camera } from "babylonjs/Cameras/camera";
  53576. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53577. /**
  53578. * PostProcessRenderPipelineManager class
  53579. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53580. */
  53581. export class PostProcessRenderPipelineManager {
  53582. private _renderPipelines;
  53583. /**
  53584. * Initializes a PostProcessRenderPipelineManager
  53585. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53586. */
  53587. constructor();
  53588. /**
  53589. * Adds a pipeline to the manager
  53590. * @param renderPipeline The pipeline to add
  53591. */
  53592. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53593. /**
  53594. * Attaches a camera to the pipeline
  53595. * @param renderPipelineName The name of the pipeline to attach to
  53596. * @param cameras the camera to attach
  53597. * @param unique if the camera can be attached multiple times to the pipeline
  53598. */
  53599. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53600. /**
  53601. * Detaches a camera from the pipeline
  53602. * @param renderPipelineName The name of the pipeline to detach from
  53603. * @param cameras the camera to detach
  53604. */
  53605. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53606. /**
  53607. * Enables an effect by name on a pipeline
  53608. * @param renderPipelineName the name of the pipeline to enable the effect in
  53609. * @param renderEffectName the name of the effect to enable
  53610. * @param cameras the cameras that the effect should be enabled on
  53611. */
  53612. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53613. /**
  53614. * Disables an effect by name on a pipeline
  53615. * @param renderPipelineName the name of the pipeline to disable the effect in
  53616. * @param renderEffectName the name of the effect to disable
  53617. * @param cameras the cameras that the effect should be disabled on
  53618. */
  53619. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53620. /**
  53621. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53622. */
  53623. update(): void;
  53624. /** @hidden */
  53625. _rebuild(): void;
  53626. /**
  53627. * Disposes of the manager and pipelines
  53628. */
  53629. dispose(): void;
  53630. }
  53631. }
  53632. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  53633. import { ISceneComponent } from "babylonjs/sceneComponent";
  53634. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53635. import { Scene } from "babylonjs/scene";
  53636. module "babylonjs/scene" {
  53637. interface Scene {
  53638. /** @hidden (Backing field) */
  53639. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53640. /**
  53641. * Gets the postprocess render pipeline manager
  53642. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53643. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53644. */
  53645. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53646. }
  53647. }
  53648. /**
  53649. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53650. */
  53651. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53652. /**
  53653. * The component name helpfull to identify the component in the list of scene components.
  53654. */
  53655. readonly name: string;
  53656. /**
  53657. * The scene the component belongs to.
  53658. */
  53659. scene: Scene;
  53660. /**
  53661. * Creates a new instance of the component for the given scene
  53662. * @param scene Defines the scene to register the component in
  53663. */
  53664. constructor(scene: Scene);
  53665. /**
  53666. * Registers the component in a given scene
  53667. */
  53668. register(): void;
  53669. /**
  53670. * Rebuilds the elements related to this component in case of
  53671. * context lost for instance.
  53672. */
  53673. rebuild(): void;
  53674. /**
  53675. * Disposes the component and the associated ressources
  53676. */
  53677. dispose(): void;
  53678. private _gatherRenderTargets;
  53679. }
  53680. }
  53681. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  53682. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  53683. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53684. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53685. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53686. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  53687. }
  53688. declare module "babylonjs/Shaders/tonemap.fragment" {
  53689. /** @hidden */
  53690. export var tonemapPixelShader: {
  53691. name: string;
  53692. shader: string;
  53693. };
  53694. }
  53695. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  53696. import { Camera } from "babylonjs/Cameras/camera";
  53697. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53698. import "babylonjs/Shaders/tonemap.fragment";
  53699. import { Engine } from "babylonjs/Engines/engine";
  53700. /** Defines operator used for tonemapping */
  53701. export enum TonemappingOperator {
  53702. /** Hable */
  53703. Hable = 0,
  53704. /** Reinhard */
  53705. Reinhard = 1,
  53706. /** HejiDawson */
  53707. HejiDawson = 2,
  53708. /** Photographic */
  53709. Photographic = 3
  53710. }
  53711. /**
  53712. * Defines a post process to apply tone mapping
  53713. */
  53714. export class TonemapPostProcess extends PostProcess {
  53715. private _operator;
  53716. /** Defines the required exposure adjustement */
  53717. exposureAdjustment: number;
  53718. /**
  53719. * Creates a new TonemapPostProcess
  53720. * @param name defines the name of the postprocess
  53721. * @param _operator defines the operator to use
  53722. * @param exposureAdjustment defines the required exposure adjustement
  53723. * @param camera defines the camera to use (can be null)
  53724. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53725. * @param engine defines the hosting engine (can be ignore if camera is set)
  53726. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53727. */
  53728. constructor(name: string, _operator: TonemappingOperator,
  53729. /** Defines the required exposure adjustement */
  53730. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53731. }
  53732. }
  53733. declare module "babylonjs/Shaders/depth.vertex" {
  53734. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53735. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53736. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53737. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53738. /** @hidden */
  53739. export var depthVertexShader: {
  53740. name: string;
  53741. shader: string;
  53742. };
  53743. }
  53744. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  53745. /** @hidden */
  53746. export var volumetricLightScatteringPixelShader: {
  53747. name: string;
  53748. shader: string;
  53749. };
  53750. }
  53751. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  53752. /** @hidden */
  53753. export var volumetricLightScatteringPassPixelShader: {
  53754. name: string;
  53755. shader: string;
  53756. };
  53757. }
  53758. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  53759. import { Vector3 } from "babylonjs/Maths/math";
  53760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53761. import { Mesh } from "babylonjs/Meshes/mesh";
  53762. import { Camera } from "babylonjs/Cameras/camera";
  53763. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53764. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53765. import { Scene } from "babylonjs/scene";
  53766. import "babylonjs/Meshes/Builders/planeBuilder";
  53767. import "babylonjs/Shaders/depth.vertex";
  53768. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  53769. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  53770. import { Engine } from "babylonjs/Engines/engine";
  53771. /**
  53772. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53773. */
  53774. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53775. private _volumetricLightScatteringPass;
  53776. private _volumetricLightScatteringRTT;
  53777. private _viewPort;
  53778. private _screenCoordinates;
  53779. private _cachedDefines;
  53780. /**
  53781. * If not undefined, the mesh position is computed from the attached node position
  53782. */
  53783. attachedNode: {
  53784. position: Vector3;
  53785. };
  53786. /**
  53787. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53788. */
  53789. customMeshPosition: Vector3;
  53790. /**
  53791. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53792. */
  53793. useCustomMeshPosition: boolean;
  53794. /**
  53795. * If the post-process should inverse the light scattering direction
  53796. */
  53797. invert: boolean;
  53798. /**
  53799. * The internal mesh used by the post-process
  53800. */
  53801. mesh: Mesh;
  53802. /**
  53803. * @hidden
  53804. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53805. */
  53806. useDiffuseColor: boolean;
  53807. /**
  53808. * Array containing the excluded meshes not rendered in the internal pass
  53809. */
  53810. excludedMeshes: AbstractMesh[];
  53811. /**
  53812. * Controls the overall intensity of the post-process
  53813. */
  53814. exposure: number;
  53815. /**
  53816. * Dissipates each sample's contribution in range [0, 1]
  53817. */
  53818. decay: number;
  53819. /**
  53820. * Controls the overall intensity of each sample
  53821. */
  53822. weight: number;
  53823. /**
  53824. * Controls the density of each sample
  53825. */
  53826. density: number;
  53827. /**
  53828. * @constructor
  53829. * @param name The post-process name
  53830. * @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)
  53831. * @param camera The camera that the post-process will be attached to
  53832. * @param mesh The mesh used to create the light scattering
  53833. * @param samples The post-process quality, default 100
  53834. * @param samplingModeThe post-process filtering mode
  53835. * @param engine The babylon engine
  53836. * @param reusable If the post-process is reusable
  53837. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53838. */
  53839. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53840. /**
  53841. * Returns the string "VolumetricLightScatteringPostProcess"
  53842. * @returns "VolumetricLightScatteringPostProcess"
  53843. */
  53844. getClassName(): string;
  53845. private _isReady;
  53846. /**
  53847. * Sets the new light position for light scattering effect
  53848. * @param position The new custom light position
  53849. */
  53850. setCustomMeshPosition(position: Vector3): void;
  53851. /**
  53852. * Returns the light position for light scattering effect
  53853. * @return Vector3 The custom light position
  53854. */
  53855. getCustomMeshPosition(): Vector3;
  53856. /**
  53857. * Disposes the internal assets and detaches the post-process from the camera
  53858. */
  53859. dispose(camera: Camera): void;
  53860. /**
  53861. * Returns the render target texture used by the post-process
  53862. * @return the render target texture used by the post-process
  53863. */
  53864. getPass(): RenderTargetTexture;
  53865. private _meshExcluded;
  53866. private _createPass;
  53867. private _updateMeshScreenCoordinates;
  53868. /**
  53869. * Creates a default mesh for the Volumeric Light Scattering post-process
  53870. * @param name The mesh name
  53871. * @param scene The scene where to create the mesh
  53872. * @return the default mesh
  53873. */
  53874. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53875. }
  53876. }
  53877. declare module "babylonjs/PostProcesses/index" {
  53878. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  53879. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  53880. export * from "babylonjs/PostProcesses/bloomEffect";
  53881. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  53882. export * from "babylonjs/PostProcesses/blurPostProcess";
  53883. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  53884. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  53885. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  53886. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  53887. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53888. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  53889. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  53890. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  53891. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  53892. export * from "babylonjs/PostProcesses/filterPostProcess";
  53893. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  53894. export * from "babylonjs/PostProcesses/grainPostProcess";
  53895. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  53896. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  53897. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  53898. export * from "babylonjs/PostProcesses/passPostProcess";
  53899. export * from "babylonjs/PostProcesses/postProcess";
  53900. export * from "babylonjs/PostProcesses/postProcessManager";
  53901. export * from "babylonjs/PostProcesses/refractionPostProcess";
  53902. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  53903. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  53904. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  53905. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  53906. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  53907. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  53908. }
  53909. declare module "babylonjs/Probes/index" {
  53910. export * from "babylonjs/Probes/reflectionProbe";
  53911. }
  53912. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  53913. import { Scene } from "babylonjs/scene";
  53914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53915. import { Color3 } from "babylonjs/Maths/math";
  53916. import { SmartArray } from "babylonjs/Misc/smartArray";
  53917. import { ISceneComponent } from "babylonjs/sceneComponent";
  53918. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  53919. import "babylonjs/Meshes/Builders/boxBuilder";
  53920. import "babylonjs/Shaders/color.fragment";
  53921. import "babylonjs/Shaders/color.vertex";
  53922. module "babylonjs/scene" {
  53923. interface Scene {
  53924. /** @hidden (Backing field) */
  53925. _boundingBoxRenderer: BoundingBoxRenderer;
  53926. /** @hidden (Backing field) */
  53927. _forceShowBoundingBoxes: boolean;
  53928. /**
  53929. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53930. */
  53931. forceShowBoundingBoxes: boolean;
  53932. /**
  53933. * Gets the bounding box renderer associated with the scene
  53934. * @returns a BoundingBoxRenderer
  53935. */
  53936. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53937. }
  53938. }
  53939. module "babylonjs/Meshes/abstractMesh" {
  53940. interface AbstractMesh {
  53941. /** @hidden (Backing field) */
  53942. _showBoundingBox: boolean;
  53943. /**
  53944. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53945. */
  53946. showBoundingBox: boolean;
  53947. }
  53948. }
  53949. /**
  53950. * Component responsible of rendering the bounding box of the meshes in a scene.
  53951. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  53952. */
  53953. export class BoundingBoxRenderer implements ISceneComponent {
  53954. /**
  53955. * The component name helpfull to identify the component in the list of scene components.
  53956. */
  53957. readonly name: string;
  53958. /**
  53959. * The scene the component belongs to.
  53960. */
  53961. scene: Scene;
  53962. /**
  53963. * Color of the bounding box lines placed in front of an object
  53964. */
  53965. frontColor: Color3;
  53966. /**
  53967. * Color of the bounding box lines placed behind an object
  53968. */
  53969. backColor: Color3;
  53970. /**
  53971. * Defines if the renderer should show the back lines or not
  53972. */
  53973. showBackLines: boolean;
  53974. /**
  53975. * @hidden
  53976. */
  53977. renderList: SmartArray<BoundingBox>;
  53978. private _colorShader;
  53979. private _vertexBuffers;
  53980. private _indexBuffer;
  53981. /**
  53982. * Instantiates a new bounding box renderer in a scene.
  53983. * @param scene the scene the renderer renders in
  53984. */
  53985. constructor(scene: Scene);
  53986. /**
  53987. * Registers the component in a given scene
  53988. */
  53989. register(): void;
  53990. private _evaluateSubMesh;
  53991. private _activeMesh;
  53992. private _prepareRessources;
  53993. private _createIndexBuffer;
  53994. /**
  53995. * Rebuilds the elements related to this component in case of
  53996. * context lost for instance.
  53997. */
  53998. rebuild(): void;
  53999. /**
  54000. * @hidden
  54001. */
  54002. reset(): void;
  54003. /**
  54004. * Render the bounding boxes of a specific rendering group
  54005. * @param renderingGroupId defines the rendering group to render
  54006. */
  54007. render(renderingGroupId: number): void;
  54008. /**
  54009. * In case of occlusion queries, we can render the occlusion bounding box through this method
  54010. * @param mesh Define the mesh to render the occlusion bounding box for
  54011. */
  54012. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  54013. /**
  54014. * Dispose and release the resources attached to this renderer.
  54015. */
  54016. dispose(): void;
  54017. }
  54018. }
  54019. declare module "babylonjs/Shaders/depth.fragment" {
  54020. /** @hidden */
  54021. export var depthPixelShader: {
  54022. name: string;
  54023. shader: string;
  54024. };
  54025. }
  54026. declare module "babylonjs/Rendering/depthRenderer" {
  54027. import { Nullable } from "babylonjs/types";
  54028. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54029. import { Scene } from "babylonjs/scene";
  54030. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54031. import { Camera } from "babylonjs/Cameras/camera";
  54032. import "babylonjs/Shaders/depth.fragment";
  54033. import "babylonjs/Shaders/depth.vertex";
  54034. /**
  54035. * This represents a depth renderer in Babylon.
  54036. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54037. */
  54038. export class DepthRenderer {
  54039. private _scene;
  54040. private _depthMap;
  54041. private _effect;
  54042. private _cachedDefines;
  54043. private _camera;
  54044. /**
  54045. * Specifiess that the depth renderer will only be used within
  54046. * the camera it is created for.
  54047. * This can help forcing its rendering during the camera processing.
  54048. */
  54049. useOnlyInActiveCamera: boolean;
  54050. /** @hidden */
  54051. static _SceneComponentInitialization: (scene: Scene) => void;
  54052. /**
  54053. * Instantiates a depth renderer
  54054. * @param scene The scene the renderer belongs to
  54055. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54056. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54057. */
  54058. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54059. /**
  54060. * Creates the depth rendering effect and checks if the effect is ready.
  54061. * @param subMesh The submesh to be used to render the depth map of
  54062. * @param useInstances If multiple world instances should be used
  54063. * @returns if the depth renderer is ready to render the depth map
  54064. */
  54065. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54066. /**
  54067. * Gets the texture which the depth map will be written to.
  54068. * @returns The depth map texture
  54069. */
  54070. getDepthMap(): RenderTargetTexture;
  54071. /**
  54072. * Disposes of the depth renderer.
  54073. */
  54074. dispose(): void;
  54075. }
  54076. }
  54077. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  54078. import { Nullable } from "babylonjs/types";
  54079. import { Scene } from "babylonjs/scene";
  54080. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  54081. import { Camera } from "babylonjs/Cameras/camera";
  54082. import { ISceneComponent } from "babylonjs/sceneComponent";
  54083. module "babylonjs/scene" {
  54084. interface Scene {
  54085. /** @hidden (Backing field) */
  54086. _depthRenderer: {
  54087. [id: string]: DepthRenderer;
  54088. };
  54089. /**
  54090. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54091. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54092. * @returns the created depth renderer
  54093. */
  54094. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54095. /**
  54096. * Disables a depth renderer for a given camera
  54097. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54098. */
  54099. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54100. }
  54101. }
  54102. /**
  54103. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54104. * in several rendering techniques.
  54105. */
  54106. export class DepthRendererSceneComponent implements ISceneComponent {
  54107. /**
  54108. * The component name helpfull to identify the component in the list of scene components.
  54109. */
  54110. readonly name: string;
  54111. /**
  54112. * The scene the component belongs to.
  54113. */
  54114. scene: Scene;
  54115. /**
  54116. * Creates a new instance of the component for the given scene
  54117. * @param scene Defines the scene to register the component in
  54118. */
  54119. constructor(scene: Scene);
  54120. /**
  54121. * Registers the component in a given scene
  54122. */
  54123. register(): void;
  54124. /**
  54125. * Rebuilds the elements related to this component in case of
  54126. * context lost for instance.
  54127. */
  54128. rebuild(): void;
  54129. /**
  54130. * Disposes the component and the associated ressources
  54131. */
  54132. dispose(): void;
  54133. private _gatherRenderTargets;
  54134. private _gatherActiveCameraRenderTargets;
  54135. }
  54136. }
  54137. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  54138. import { Nullable } from "babylonjs/types";
  54139. import { Scene } from "babylonjs/scene";
  54140. import { ISceneComponent } from "babylonjs/sceneComponent";
  54141. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  54142. module "babylonjs/scene" {
  54143. interface Scene {
  54144. /** @hidden (Backing field) */
  54145. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54146. /**
  54147. * Gets or Sets the current geometry buffer associated to the scene.
  54148. */
  54149. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54150. /**
  54151. * Enables a GeometryBufferRender and associates it with the scene
  54152. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54153. * @returns the GeometryBufferRenderer
  54154. */
  54155. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54156. /**
  54157. * Disables the GeometryBufferRender associated with the scene
  54158. */
  54159. disableGeometryBufferRenderer(): void;
  54160. }
  54161. }
  54162. /**
  54163. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54164. * in several rendering techniques.
  54165. */
  54166. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54167. /**
  54168. * The component name helpful to identify the component in the list of scene components.
  54169. */
  54170. readonly name: string;
  54171. /**
  54172. * The scene the component belongs to.
  54173. */
  54174. scene: Scene;
  54175. /**
  54176. * Creates a new instance of the component for the given scene
  54177. * @param scene Defines the scene to register the component in
  54178. */
  54179. constructor(scene: Scene);
  54180. /**
  54181. * Registers the component in a given scene
  54182. */
  54183. register(): void;
  54184. /**
  54185. * Rebuilds the elements related to this component in case of
  54186. * context lost for instance.
  54187. */
  54188. rebuild(): void;
  54189. /**
  54190. * Disposes the component and the associated ressources
  54191. */
  54192. dispose(): void;
  54193. private _gatherRenderTargets;
  54194. }
  54195. }
  54196. declare module "babylonjs/Shaders/outline.fragment" {
  54197. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  54198. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  54199. /** @hidden */
  54200. export var outlinePixelShader: {
  54201. name: string;
  54202. shader: string;
  54203. };
  54204. }
  54205. declare module "babylonjs/Shaders/outline.vertex" {
  54206. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54207. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54208. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  54209. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54210. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54211. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  54212. /** @hidden */
  54213. export var outlineVertexShader: {
  54214. name: string;
  54215. shader: string;
  54216. };
  54217. }
  54218. declare module "babylonjs/Rendering/outlineRenderer" {
  54219. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54220. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  54221. import { Scene } from "babylonjs/scene";
  54222. import { ISceneComponent } from "babylonjs/sceneComponent";
  54223. import "babylonjs/Shaders/outline.fragment";
  54224. import "babylonjs/Shaders/outline.vertex";
  54225. module "babylonjs/scene" {
  54226. interface Scene {
  54227. /** @hidden */
  54228. _outlineRenderer: OutlineRenderer;
  54229. /**
  54230. * Gets the outline renderer associated with the scene
  54231. * @returns a OutlineRenderer
  54232. */
  54233. getOutlineRenderer(): OutlineRenderer;
  54234. }
  54235. }
  54236. module "babylonjs/Meshes/abstractMesh" {
  54237. interface AbstractMesh {
  54238. /** @hidden (Backing field) */
  54239. _renderOutline: boolean;
  54240. /**
  54241. * Gets or sets a boolean indicating if the outline must be rendered as well
  54242. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54243. */
  54244. renderOutline: boolean;
  54245. /** @hidden (Backing field) */
  54246. _renderOverlay: boolean;
  54247. /**
  54248. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54249. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54250. */
  54251. renderOverlay: boolean;
  54252. }
  54253. }
  54254. /**
  54255. * This class is responsible to draw bothe outline/overlay of meshes.
  54256. * It should not be used directly but through the available method on mesh.
  54257. */
  54258. export class OutlineRenderer implements ISceneComponent {
  54259. /**
  54260. * The name of the component. Each component must have a unique name.
  54261. */
  54262. name: string;
  54263. /**
  54264. * The scene the component belongs to.
  54265. */
  54266. scene: Scene;
  54267. /**
  54268. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54269. */
  54270. zOffset: number;
  54271. private _engine;
  54272. private _effect;
  54273. private _cachedDefines;
  54274. private _savedDepthWrite;
  54275. /**
  54276. * Instantiates a new outline renderer. (There could be only one per scene).
  54277. * @param scene Defines the scene it belongs to
  54278. */
  54279. constructor(scene: Scene);
  54280. /**
  54281. * Register the component to one instance of a scene.
  54282. */
  54283. register(): void;
  54284. /**
  54285. * Rebuilds the elements related to this component in case of
  54286. * context lost for instance.
  54287. */
  54288. rebuild(): void;
  54289. /**
  54290. * Disposes the component and the associated ressources.
  54291. */
  54292. dispose(): void;
  54293. /**
  54294. * Renders the outline in the canvas.
  54295. * @param subMesh Defines the sumesh to render
  54296. * @param batch Defines the batch of meshes in case of instances
  54297. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54298. */
  54299. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54300. /**
  54301. * Returns whether or not the outline renderer is ready for a given submesh.
  54302. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54303. * @param subMesh Defines the submesh to check readyness for
  54304. * @param useInstances Defines wheter wee are trying to render instances or not
  54305. * @returns true if ready otherwise false
  54306. */
  54307. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54308. private _beforeRenderingMesh;
  54309. private _afterRenderingMesh;
  54310. }
  54311. }
  54312. declare module "babylonjs/Rendering/index" {
  54313. export * from "babylonjs/Rendering/boundingBoxRenderer";
  54314. export * from "babylonjs/Rendering/depthRenderer";
  54315. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  54316. export * from "babylonjs/Rendering/edgesRenderer";
  54317. export * from "babylonjs/Rendering/geometryBufferRenderer";
  54318. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  54319. export * from "babylonjs/Rendering/outlineRenderer";
  54320. export * from "babylonjs/Rendering/renderingGroup";
  54321. export * from "babylonjs/Rendering/renderingManager";
  54322. export * from "babylonjs/Rendering/utilityLayerRenderer";
  54323. }
  54324. declare module "babylonjs/Sprites/index" {
  54325. export * from "babylonjs/Sprites/sprite";
  54326. export * from "babylonjs/Sprites/spriteManager";
  54327. export * from "babylonjs/Sprites/spriteSceneComponent";
  54328. }
  54329. declare module "babylonjs/Misc/assetsManager" {
  54330. import { Scene } from "babylonjs/scene";
  54331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54332. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54333. import { Skeleton } from "babylonjs/Bones/skeleton";
  54334. import { Observable } from "babylonjs/Misc/observable";
  54335. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54336. import { Texture } from "babylonjs/Materials/Textures/texture";
  54337. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54338. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  54339. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  54340. /**
  54341. * Defines the list of states available for a task inside a AssetsManager
  54342. */
  54343. export enum AssetTaskState {
  54344. /**
  54345. * Initialization
  54346. */
  54347. INIT = 0,
  54348. /**
  54349. * Running
  54350. */
  54351. RUNNING = 1,
  54352. /**
  54353. * Done
  54354. */
  54355. DONE = 2,
  54356. /**
  54357. * Error
  54358. */
  54359. ERROR = 3
  54360. }
  54361. /**
  54362. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  54363. */
  54364. export abstract class AbstractAssetTask {
  54365. /**
  54366. * Task name
  54367. */ name: string;
  54368. /**
  54369. * Callback called when the task is successful
  54370. */
  54371. onSuccess: (task: any) => void;
  54372. /**
  54373. * Callback called when the task is not successful
  54374. */
  54375. onError: (task: any, message?: string, exception?: any) => void;
  54376. /**
  54377. * Creates a new AssetsManager
  54378. * @param name defines the name of the task
  54379. */
  54380. constructor(
  54381. /**
  54382. * Task name
  54383. */ name: string);
  54384. private _isCompleted;
  54385. private _taskState;
  54386. private _errorObject;
  54387. /**
  54388. * Get if the task is completed
  54389. */
  54390. readonly isCompleted: boolean;
  54391. /**
  54392. * Gets the current state of the task
  54393. */
  54394. readonly taskState: AssetTaskState;
  54395. /**
  54396. * Gets the current error object (if task is in error)
  54397. */
  54398. readonly errorObject: {
  54399. message?: string;
  54400. exception?: any;
  54401. };
  54402. /**
  54403. * Internal only
  54404. * @hidden
  54405. */
  54406. _setErrorObject(message?: string, exception?: any): void;
  54407. /**
  54408. * Execute the current task
  54409. * @param scene defines the scene where you want your assets to be loaded
  54410. * @param onSuccess is a callback called when the task is successfully executed
  54411. * @param onError is a callback called if an error occurs
  54412. */
  54413. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54414. /**
  54415. * Execute the current task
  54416. * @param scene defines the scene where you want your assets to be loaded
  54417. * @param onSuccess is a callback called when the task is successfully executed
  54418. * @param onError is a callback called if an error occurs
  54419. */
  54420. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54421. /**
  54422. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  54423. * This can be used with failed tasks that have the reason for failure fixed.
  54424. */
  54425. reset(): void;
  54426. private onErrorCallback;
  54427. private onDoneCallback;
  54428. }
  54429. /**
  54430. * Define the interface used by progress events raised during assets loading
  54431. */
  54432. export interface IAssetsProgressEvent {
  54433. /**
  54434. * Defines the number of remaining tasks to process
  54435. */
  54436. remainingCount: number;
  54437. /**
  54438. * Defines the total number of tasks
  54439. */
  54440. totalCount: number;
  54441. /**
  54442. * Defines the task that was just processed
  54443. */
  54444. task: AbstractAssetTask;
  54445. }
  54446. /**
  54447. * Class used to share progress information about assets loading
  54448. */
  54449. export class AssetsProgressEvent implements IAssetsProgressEvent {
  54450. /**
  54451. * Defines the number of remaining tasks to process
  54452. */
  54453. remainingCount: number;
  54454. /**
  54455. * Defines the total number of tasks
  54456. */
  54457. totalCount: number;
  54458. /**
  54459. * Defines the task that was just processed
  54460. */
  54461. task: AbstractAssetTask;
  54462. /**
  54463. * Creates a AssetsProgressEvent
  54464. * @param remainingCount defines the number of remaining tasks to process
  54465. * @param totalCount defines the total number of tasks
  54466. * @param task defines the task that was just processed
  54467. */
  54468. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54469. }
  54470. /**
  54471. * Define a task used by AssetsManager to load meshes
  54472. */
  54473. export class MeshAssetTask extends AbstractAssetTask {
  54474. /**
  54475. * Defines the name of the task
  54476. */
  54477. name: string;
  54478. /**
  54479. * Defines the list of mesh's names you want to load
  54480. */
  54481. meshesNames: any;
  54482. /**
  54483. * Defines the root url to use as a base to load your meshes and associated resources
  54484. */
  54485. rootUrl: string;
  54486. /**
  54487. * Defines the filename of the scene to load from
  54488. */
  54489. sceneFilename: string;
  54490. /**
  54491. * Gets the list of loaded meshes
  54492. */
  54493. loadedMeshes: Array<AbstractMesh>;
  54494. /**
  54495. * Gets the list of loaded particle systems
  54496. */
  54497. loadedParticleSystems: Array<IParticleSystem>;
  54498. /**
  54499. * Gets the list of loaded skeletons
  54500. */
  54501. loadedSkeletons: Array<Skeleton>;
  54502. /**
  54503. * Gets the list of loaded animation groups
  54504. */
  54505. loadedAnimationGroups: Array<AnimationGroup>;
  54506. /**
  54507. * Callback called when the task is successful
  54508. */
  54509. onSuccess: (task: MeshAssetTask) => void;
  54510. /**
  54511. * Callback called when the task is successful
  54512. */
  54513. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  54514. /**
  54515. * Creates a new MeshAssetTask
  54516. * @param name defines the name of the task
  54517. * @param meshesNames defines the list of mesh's names you want to load
  54518. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  54519. * @param sceneFilename defines the filename of the scene to load from
  54520. */
  54521. constructor(
  54522. /**
  54523. * Defines the name of the task
  54524. */
  54525. name: string,
  54526. /**
  54527. * Defines the list of mesh's names you want to load
  54528. */
  54529. meshesNames: any,
  54530. /**
  54531. * Defines the root url to use as a base to load your meshes and associated resources
  54532. */
  54533. rootUrl: string,
  54534. /**
  54535. * Defines the filename of the scene to load from
  54536. */
  54537. sceneFilename: string);
  54538. /**
  54539. * Execute the current task
  54540. * @param scene defines the scene where you want your assets to be loaded
  54541. * @param onSuccess is a callback called when the task is successfully executed
  54542. * @param onError is a callback called if an error occurs
  54543. */
  54544. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54545. }
  54546. /**
  54547. * Define a task used by AssetsManager to load text content
  54548. */
  54549. export class TextFileAssetTask extends AbstractAssetTask {
  54550. /**
  54551. * Defines the name of the task
  54552. */
  54553. name: string;
  54554. /**
  54555. * Defines the location of the file to load
  54556. */
  54557. url: string;
  54558. /**
  54559. * Gets the loaded text string
  54560. */
  54561. text: string;
  54562. /**
  54563. * Callback called when the task is successful
  54564. */
  54565. onSuccess: (task: TextFileAssetTask) => void;
  54566. /**
  54567. * Callback called when the task is successful
  54568. */
  54569. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54570. /**
  54571. * Creates a new TextFileAssetTask object
  54572. * @param name defines the name of the task
  54573. * @param url defines the location of the file to load
  54574. */
  54575. constructor(
  54576. /**
  54577. * Defines the name of the task
  54578. */
  54579. name: string,
  54580. /**
  54581. * Defines the location of the file to load
  54582. */
  54583. url: string);
  54584. /**
  54585. * Execute the current task
  54586. * @param scene defines the scene where you want your assets to be loaded
  54587. * @param onSuccess is a callback called when the task is successfully executed
  54588. * @param onError is a callback called if an error occurs
  54589. */
  54590. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54591. }
  54592. /**
  54593. * Define a task used by AssetsManager to load binary data
  54594. */
  54595. export class BinaryFileAssetTask extends AbstractAssetTask {
  54596. /**
  54597. * Defines the name of the task
  54598. */
  54599. name: string;
  54600. /**
  54601. * Defines the location of the file to load
  54602. */
  54603. url: string;
  54604. /**
  54605. * Gets the lodaded data (as an array buffer)
  54606. */
  54607. data: ArrayBuffer;
  54608. /**
  54609. * Callback called when the task is successful
  54610. */
  54611. onSuccess: (task: BinaryFileAssetTask) => void;
  54612. /**
  54613. * Callback called when the task is successful
  54614. */
  54615. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54616. /**
  54617. * Creates a new BinaryFileAssetTask object
  54618. * @param name defines the name of the new task
  54619. * @param url defines the location of the file to load
  54620. */
  54621. constructor(
  54622. /**
  54623. * Defines the name of the task
  54624. */
  54625. name: string,
  54626. /**
  54627. * Defines the location of the file to load
  54628. */
  54629. url: string);
  54630. /**
  54631. * Execute the current task
  54632. * @param scene defines the scene where you want your assets to be loaded
  54633. * @param onSuccess is a callback called when the task is successfully executed
  54634. * @param onError is a callback called if an error occurs
  54635. */
  54636. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54637. }
  54638. /**
  54639. * Define a task used by AssetsManager to load images
  54640. */
  54641. export class ImageAssetTask extends AbstractAssetTask {
  54642. /**
  54643. * Defines the name of the task
  54644. */
  54645. name: string;
  54646. /**
  54647. * Defines the location of the image to load
  54648. */
  54649. url: string;
  54650. /**
  54651. * Gets the loaded images
  54652. */
  54653. image: HTMLImageElement;
  54654. /**
  54655. * Callback called when the task is successful
  54656. */
  54657. onSuccess: (task: ImageAssetTask) => void;
  54658. /**
  54659. * Callback called when the task is successful
  54660. */
  54661. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54662. /**
  54663. * Creates a new ImageAssetTask
  54664. * @param name defines the name of the task
  54665. * @param url defines the location of the image to load
  54666. */
  54667. constructor(
  54668. /**
  54669. * Defines the name of the task
  54670. */
  54671. name: string,
  54672. /**
  54673. * Defines the location of the image to load
  54674. */
  54675. url: string);
  54676. /**
  54677. * Execute the current task
  54678. * @param scene defines the scene where you want your assets to be loaded
  54679. * @param onSuccess is a callback called when the task is successfully executed
  54680. * @param onError is a callback called if an error occurs
  54681. */
  54682. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54683. }
  54684. /**
  54685. * Defines the interface used by texture loading tasks
  54686. */
  54687. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54688. /**
  54689. * Gets the loaded texture
  54690. */
  54691. texture: TEX;
  54692. }
  54693. /**
  54694. * Define a task used by AssetsManager to load 2D textures
  54695. */
  54696. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54697. /**
  54698. * Defines the name of the task
  54699. */
  54700. name: string;
  54701. /**
  54702. * Defines the location of the file to load
  54703. */
  54704. url: string;
  54705. /**
  54706. * Defines if mipmap should not be generated (default is false)
  54707. */
  54708. noMipmap?: boolean | undefined;
  54709. /**
  54710. * Defines if texture must be inverted on Y axis (default is false)
  54711. */
  54712. invertY?: boolean | undefined;
  54713. /**
  54714. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54715. */
  54716. samplingMode: number;
  54717. /**
  54718. * Gets the loaded texture
  54719. */
  54720. texture: Texture;
  54721. /**
  54722. * Callback called when the task is successful
  54723. */
  54724. onSuccess: (task: TextureAssetTask) => void;
  54725. /**
  54726. * Callback called when the task is successful
  54727. */
  54728. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54729. /**
  54730. * Creates a new TextureAssetTask object
  54731. * @param name defines the name of the task
  54732. * @param url defines the location of the file to load
  54733. * @param noMipmap defines if mipmap should not be generated (default is false)
  54734. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54735. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54736. */
  54737. constructor(
  54738. /**
  54739. * Defines the name of the task
  54740. */
  54741. name: string,
  54742. /**
  54743. * Defines the location of the file to load
  54744. */
  54745. url: string,
  54746. /**
  54747. * Defines if mipmap should not be generated (default is false)
  54748. */
  54749. noMipmap?: boolean | undefined,
  54750. /**
  54751. * Defines if texture must be inverted on Y axis (default is false)
  54752. */
  54753. invertY?: boolean | undefined,
  54754. /**
  54755. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54756. */
  54757. samplingMode?: number);
  54758. /**
  54759. * Execute the current task
  54760. * @param scene defines the scene where you want your assets to be loaded
  54761. * @param onSuccess is a callback called when the task is successfully executed
  54762. * @param onError is a callback called if an error occurs
  54763. */
  54764. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54765. }
  54766. /**
  54767. * Define a task used by AssetsManager to load cube textures
  54768. */
  54769. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54770. /**
  54771. * Defines the name of the task
  54772. */
  54773. name: string;
  54774. /**
  54775. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54776. */
  54777. url: string;
  54778. /**
  54779. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54780. */
  54781. extensions?: string[] | undefined;
  54782. /**
  54783. * Defines if mipmaps should not be generated (default is false)
  54784. */
  54785. noMipmap?: boolean | undefined;
  54786. /**
  54787. * Defines the explicit list of files (undefined by default)
  54788. */
  54789. files?: string[] | undefined;
  54790. /**
  54791. * Gets the loaded texture
  54792. */
  54793. texture: CubeTexture;
  54794. /**
  54795. * Callback called when the task is successful
  54796. */
  54797. onSuccess: (task: CubeTextureAssetTask) => void;
  54798. /**
  54799. * Callback called when the task is successful
  54800. */
  54801. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54802. /**
  54803. * Creates a new CubeTextureAssetTask
  54804. * @param name defines the name of the task
  54805. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54806. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54807. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54808. * @param files defines the explicit list of files (undefined by default)
  54809. */
  54810. constructor(
  54811. /**
  54812. * Defines the name of the task
  54813. */
  54814. name: string,
  54815. /**
  54816. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54817. */
  54818. url: string,
  54819. /**
  54820. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54821. */
  54822. extensions?: string[] | undefined,
  54823. /**
  54824. * Defines if mipmaps should not be generated (default is false)
  54825. */
  54826. noMipmap?: boolean | undefined,
  54827. /**
  54828. * Defines the explicit list of files (undefined by default)
  54829. */
  54830. files?: string[] | undefined);
  54831. /**
  54832. * Execute the current task
  54833. * @param scene defines the scene where you want your assets to be loaded
  54834. * @param onSuccess is a callback called when the task is successfully executed
  54835. * @param onError is a callback called if an error occurs
  54836. */
  54837. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54838. }
  54839. /**
  54840. * Define a task used by AssetsManager to load HDR cube textures
  54841. */
  54842. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54843. /**
  54844. * Defines the name of the task
  54845. */
  54846. name: string;
  54847. /**
  54848. * Defines the location of the file to load
  54849. */
  54850. url: string;
  54851. /**
  54852. * Defines the desired size (the more it increases the longer the generation will be)
  54853. */
  54854. size: number;
  54855. /**
  54856. * Defines if mipmaps should not be generated (default is false)
  54857. */
  54858. noMipmap: boolean;
  54859. /**
  54860. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54861. */
  54862. generateHarmonics: boolean;
  54863. /**
  54864. * 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)
  54865. */
  54866. gammaSpace: boolean;
  54867. /**
  54868. * Internal Use Only
  54869. */
  54870. reserved: boolean;
  54871. /**
  54872. * Gets the loaded texture
  54873. */
  54874. texture: HDRCubeTexture;
  54875. /**
  54876. * Callback called when the task is successful
  54877. */
  54878. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54879. /**
  54880. * Callback called when the task is successful
  54881. */
  54882. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54883. /**
  54884. * Creates a new HDRCubeTextureAssetTask object
  54885. * @param name defines the name of the task
  54886. * @param url defines the location of the file to load
  54887. * @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.
  54888. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54889. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54890. * @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)
  54891. * @param reserved Internal use only
  54892. */
  54893. constructor(
  54894. /**
  54895. * Defines the name of the task
  54896. */
  54897. name: string,
  54898. /**
  54899. * Defines the location of the file to load
  54900. */
  54901. url: string,
  54902. /**
  54903. * Defines the desired size (the more it increases the longer the generation will be)
  54904. */
  54905. size: number,
  54906. /**
  54907. * Defines if mipmaps should not be generated (default is false)
  54908. */
  54909. noMipmap?: boolean,
  54910. /**
  54911. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54912. */
  54913. generateHarmonics?: boolean,
  54914. /**
  54915. * 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)
  54916. */
  54917. gammaSpace?: boolean,
  54918. /**
  54919. * Internal Use Only
  54920. */
  54921. reserved?: boolean);
  54922. /**
  54923. * Execute the current task
  54924. * @param scene defines the scene where you want your assets to be loaded
  54925. * @param onSuccess is a callback called when the task is successfully executed
  54926. * @param onError is a callback called if an error occurs
  54927. */
  54928. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54929. }
  54930. /**
  54931. * This class can be used to easily import assets into a scene
  54932. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54933. */
  54934. export class AssetsManager {
  54935. private _scene;
  54936. private _isLoading;
  54937. protected _tasks: AbstractAssetTask[];
  54938. protected _waitingTasksCount: number;
  54939. protected _totalTasksCount: number;
  54940. /**
  54941. * Callback called when all tasks are processed
  54942. */
  54943. onFinish: (tasks: AbstractAssetTask[]) => void;
  54944. /**
  54945. * Callback called when a task is successful
  54946. */
  54947. onTaskSuccess: (task: AbstractAssetTask) => void;
  54948. /**
  54949. * Callback called when a task had an error
  54950. */
  54951. onTaskError: (task: AbstractAssetTask) => void;
  54952. /**
  54953. * Callback called when a task is done (whatever the result is)
  54954. */
  54955. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  54956. /**
  54957. * Observable called when all tasks are processed
  54958. */
  54959. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  54960. /**
  54961. * Observable called when a task had an error
  54962. */
  54963. onTaskErrorObservable: Observable<AbstractAssetTask>;
  54964. /**
  54965. * Observable called when a task is successful
  54966. */
  54967. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  54968. /**
  54969. * Observable called when a task is done (whatever the result is)
  54970. */
  54971. onProgressObservable: Observable<IAssetsProgressEvent>;
  54972. /**
  54973. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  54974. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  54975. */
  54976. useDefaultLoadingScreen: boolean;
  54977. /**
  54978. * Creates a new AssetsManager
  54979. * @param scene defines the scene to work on
  54980. */
  54981. constructor(scene: Scene);
  54982. /**
  54983. * Add a MeshAssetTask to the list of active tasks
  54984. * @param taskName defines the name of the new task
  54985. * @param meshesNames defines the name of meshes to load
  54986. * @param rootUrl defines the root url to use to locate files
  54987. * @param sceneFilename defines the filename of the scene file
  54988. * @returns a new MeshAssetTask object
  54989. */
  54990. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  54991. /**
  54992. * Add a TextFileAssetTask to the list of active tasks
  54993. * @param taskName defines the name of the new task
  54994. * @param url defines the url of the file to load
  54995. * @returns a new TextFileAssetTask object
  54996. */
  54997. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  54998. /**
  54999. * Add a BinaryFileAssetTask to the list of active tasks
  55000. * @param taskName defines the name of the new task
  55001. * @param url defines the url of the file to load
  55002. * @returns a new BinaryFileAssetTask object
  55003. */
  55004. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  55005. /**
  55006. * Add a ImageAssetTask to the list of active tasks
  55007. * @param taskName defines the name of the new task
  55008. * @param url defines the url of the file to load
  55009. * @returns a new ImageAssetTask object
  55010. */
  55011. addImageTask(taskName: string, url: string): ImageAssetTask;
  55012. /**
  55013. * Add a TextureAssetTask to the list of active tasks
  55014. * @param taskName defines the name of the new task
  55015. * @param url defines the url of the file to load
  55016. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55017. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  55018. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55019. * @returns a new TextureAssetTask object
  55020. */
  55021. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  55022. /**
  55023. * Add a CubeTextureAssetTask to the list of active tasks
  55024. * @param taskName defines the name of the new task
  55025. * @param url defines the url of the file to load
  55026. * @param extensions defines the extension to use to load the cube map (can be null)
  55027. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55028. * @param files defines the list of files to load (can be null)
  55029. * @returns a new CubeTextureAssetTask object
  55030. */
  55031. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  55032. /**
  55033. *
  55034. * Add a HDRCubeTextureAssetTask to the list of active tasks
  55035. * @param taskName defines the name of the new task
  55036. * @param url defines the url of the file to load
  55037. * @param size defines the size you want for the cubemap (can be null)
  55038. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55039. * @param generateHarmonics defines if you want to automatically generate (true by default)
  55040. * @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)
  55041. * @param reserved Internal use only
  55042. * @returns a new HDRCubeTextureAssetTask object
  55043. */
  55044. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  55045. /**
  55046. * Remove a task from the assets manager.
  55047. * @param task the task to remove
  55048. */
  55049. removeTask(task: AbstractAssetTask): void;
  55050. private _decreaseWaitingTasksCount;
  55051. private _runTask;
  55052. /**
  55053. * Reset the AssetsManager and remove all tasks
  55054. * @return the current instance of the AssetsManager
  55055. */
  55056. reset(): AssetsManager;
  55057. /**
  55058. * Start the loading process
  55059. * @return the current instance of the AssetsManager
  55060. */
  55061. load(): AssetsManager;
  55062. }
  55063. }
  55064. declare module "babylonjs/Misc/deferred" {
  55065. /**
  55066. * Wrapper class for promise with external resolve and reject.
  55067. */
  55068. export class Deferred<T> {
  55069. /**
  55070. * The promise associated with this deferred object.
  55071. */
  55072. readonly promise: Promise<T>;
  55073. private _resolve;
  55074. private _reject;
  55075. /**
  55076. * The resolve method of the promise associated with this deferred object.
  55077. */
  55078. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55079. /**
  55080. * The reject method of the promise associated with this deferred object.
  55081. */
  55082. readonly reject: (reason?: any) => void;
  55083. /**
  55084. * Constructor for this deferred object.
  55085. */
  55086. constructor();
  55087. }
  55088. }
  55089. declare module "babylonjs/Misc/filesInput" {
  55090. import { Engine } from "babylonjs/Engines/engine";
  55091. import { Scene } from "babylonjs/scene";
  55092. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  55093. /**
  55094. * Class used to help managing file picking and drag'n'drop
  55095. */
  55096. export class FilesInput {
  55097. /**
  55098. * List of files ready to be loaded
  55099. */
  55100. static readonly FilesToLoad: {
  55101. [key: string]: File;
  55102. };
  55103. /**
  55104. * Callback called when a file is processed
  55105. */
  55106. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55107. private _engine;
  55108. private _currentScene;
  55109. private _sceneLoadedCallback;
  55110. private _progressCallback;
  55111. private _additionalRenderLoopLogicCallback;
  55112. private _textureLoadingCallback;
  55113. private _startingProcessingFilesCallback;
  55114. private _onReloadCallback;
  55115. private _errorCallback;
  55116. private _elementToMonitor;
  55117. private _sceneFileToLoad;
  55118. private _filesToLoad;
  55119. /**
  55120. * Creates a new FilesInput
  55121. * @param engine defines the rendering engine
  55122. * @param scene defines the hosting scene
  55123. * @param sceneLoadedCallback callback called when scene is loaded
  55124. * @param progressCallback callback called to track progress
  55125. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55126. * @param textureLoadingCallback callback called when a texture is loading
  55127. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55128. * @param onReloadCallback callback called when a reload is requested
  55129. * @param errorCallback callback call if an error occurs
  55130. */
  55131. 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);
  55132. private _dragEnterHandler;
  55133. private _dragOverHandler;
  55134. private _dropHandler;
  55135. /**
  55136. * Calls this function to listen to drag'n'drop events on a specific DOM element
  55137. * @param elementToMonitor defines the DOM element to track
  55138. */
  55139. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  55140. /**
  55141. * Release all associated resources
  55142. */
  55143. dispose(): void;
  55144. private renderFunction;
  55145. private drag;
  55146. private drop;
  55147. private _traverseFolder;
  55148. private _processFiles;
  55149. /**
  55150. * Load files from a drop event
  55151. * @param event defines the drop event to use as source
  55152. */
  55153. loadFiles(event: any): void;
  55154. private _processReload;
  55155. /**
  55156. * Reload the current scene from the loaded files
  55157. */
  55158. reload(): void;
  55159. }
  55160. }
  55161. declare module "babylonjs/Misc/HighDynamicRange/index" {
  55162. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  55163. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  55164. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  55165. }
  55166. declare module "babylonjs/Misc/sceneOptimizer" {
  55167. import { Scene, IDisposable } from "babylonjs/scene";
  55168. import { Observable } from "babylonjs/Misc/observable";
  55169. /**
  55170. * Defines the root class used to create scene optimization to use with SceneOptimizer
  55171. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55172. */
  55173. export class SceneOptimization {
  55174. /**
  55175. * Defines the priority of this optimization (0 by default which means first in the list)
  55176. */
  55177. priority: number;
  55178. /**
  55179. * Gets a string describing the action executed by the current optimization
  55180. * @returns description string
  55181. */
  55182. getDescription(): string;
  55183. /**
  55184. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55185. * @param scene defines the current scene where to apply this optimization
  55186. * @param optimizer defines the current optimizer
  55187. * @returns true if everything that can be done was applied
  55188. */
  55189. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55190. /**
  55191. * Creates the SceneOptimization object
  55192. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55193. * @param desc defines the description associated with the optimization
  55194. */
  55195. constructor(
  55196. /**
  55197. * Defines the priority of this optimization (0 by default which means first in the list)
  55198. */
  55199. priority?: number);
  55200. }
  55201. /**
  55202. * Defines an optimization used to reduce the size of render target textures
  55203. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55204. */
  55205. export class TextureOptimization extends SceneOptimization {
  55206. /**
  55207. * Defines the priority of this optimization (0 by default which means first in the list)
  55208. */
  55209. priority: number;
  55210. /**
  55211. * 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
  55212. */
  55213. maximumSize: number;
  55214. /**
  55215. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55216. */
  55217. step: number;
  55218. /**
  55219. * Gets a string describing the action executed by the current optimization
  55220. * @returns description string
  55221. */
  55222. getDescription(): string;
  55223. /**
  55224. * Creates the TextureOptimization object
  55225. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55226. * @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
  55227. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55228. */
  55229. constructor(
  55230. /**
  55231. * Defines the priority of this optimization (0 by default which means first in the list)
  55232. */
  55233. priority?: number,
  55234. /**
  55235. * 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
  55236. */
  55237. maximumSize?: number,
  55238. /**
  55239. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55240. */
  55241. step?: number);
  55242. /**
  55243. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55244. * @param scene defines the current scene where to apply this optimization
  55245. * @param optimizer defines the current optimizer
  55246. * @returns true if everything that can be done was applied
  55247. */
  55248. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55249. }
  55250. /**
  55251. * Defines an optimization used to increase or decrease the rendering resolution
  55252. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55253. */
  55254. export class HardwareScalingOptimization extends SceneOptimization {
  55255. /**
  55256. * Defines the priority of this optimization (0 by default which means first in the list)
  55257. */
  55258. priority: number;
  55259. /**
  55260. * Defines the maximum scale to use (2 by default)
  55261. */
  55262. maximumScale: number;
  55263. /**
  55264. * Defines the step to use between two passes (0.5 by default)
  55265. */
  55266. step: number;
  55267. private _currentScale;
  55268. private _directionOffset;
  55269. /**
  55270. * Gets a string describing the action executed by the current optimization
  55271. * @return description string
  55272. */
  55273. getDescription(): string;
  55274. /**
  55275. * Creates the HardwareScalingOptimization object
  55276. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55277. * @param maximumScale defines the maximum scale to use (2 by default)
  55278. * @param step defines the step to use between two passes (0.5 by default)
  55279. */
  55280. constructor(
  55281. /**
  55282. * Defines the priority of this optimization (0 by default which means first in the list)
  55283. */
  55284. priority?: number,
  55285. /**
  55286. * Defines the maximum scale to use (2 by default)
  55287. */
  55288. maximumScale?: number,
  55289. /**
  55290. * Defines the step to use between two passes (0.5 by default)
  55291. */
  55292. step?: number);
  55293. /**
  55294. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55295. * @param scene defines the current scene where to apply this optimization
  55296. * @param optimizer defines the current optimizer
  55297. * @returns true if everything that can be done was applied
  55298. */
  55299. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55300. }
  55301. /**
  55302. * Defines an optimization used to remove shadows
  55303. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55304. */
  55305. export class ShadowsOptimization extends SceneOptimization {
  55306. /**
  55307. * Gets a string describing the action executed by the current optimization
  55308. * @return description string
  55309. */
  55310. getDescription(): string;
  55311. /**
  55312. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55313. * @param scene defines the current scene where to apply this optimization
  55314. * @param optimizer defines the current optimizer
  55315. * @returns true if everything that can be done was applied
  55316. */
  55317. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55318. }
  55319. /**
  55320. * Defines an optimization used to turn post-processes off
  55321. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55322. */
  55323. export class PostProcessesOptimization extends SceneOptimization {
  55324. /**
  55325. * Gets a string describing the action executed by the current optimization
  55326. * @return description string
  55327. */
  55328. getDescription(): string;
  55329. /**
  55330. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55331. * @param scene defines the current scene where to apply this optimization
  55332. * @param optimizer defines the current optimizer
  55333. * @returns true if everything that can be done was applied
  55334. */
  55335. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55336. }
  55337. /**
  55338. * Defines an optimization used to turn lens flares off
  55339. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55340. */
  55341. export class LensFlaresOptimization extends SceneOptimization {
  55342. /**
  55343. * Gets a string describing the action executed by the current optimization
  55344. * @return description string
  55345. */
  55346. getDescription(): string;
  55347. /**
  55348. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55349. * @param scene defines the current scene where to apply this optimization
  55350. * @param optimizer defines the current optimizer
  55351. * @returns true if everything that can be done was applied
  55352. */
  55353. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55354. }
  55355. /**
  55356. * Defines an optimization based on user defined callback.
  55357. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55358. */
  55359. export class CustomOptimization extends SceneOptimization {
  55360. /**
  55361. * Callback called to apply the custom optimization.
  55362. */
  55363. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  55364. /**
  55365. * Callback called to get custom description
  55366. */
  55367. onGetDescription: () => string;
  55368. /**
  55369. * Gets a string describing the action executed by the current optimization
  55370. * @returns description string
  55371. */
  55372. getDescription(): string;
  55373. /**
  55374. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55375. * @param scene defines the current scene where to apply this optimization
  55376. * @param optimizer defines the current optimizer
  55377. * @returns true if everything that can be done was applied
  55378. */
  55379. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55380. }
  55381. /**
  55382. * Defines an optimization used to turn particles off
  55383. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55384. */
  55385. export class ParticlesOptimization extends SceneOptimization {
  55386. /**
  55387. * Gets a string describing the action executed by the current optimization
  55388. * @return description string
  55389. */
  55390. getDescription(): string;
  55391. /**
  55392. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55393. * @param scene defines the current scene where to apply this optimization
  55394. * @param optimizer defines the current optimizer
  55395. * @returns true if everything that can be done was applied
  55396. */
  55397. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55398. }
  55399. /**
  55400. * Defines an optimization used to turn render targets off
  55401. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55402. */
  55403. export class RenderTargetsOptimization extends SceneOptimization {
  55404. /**
  55405. * Gets a string describing the action executed by the current optimization
  55406. * @return description string
  55407. */
  55408. getDescription(): string;
  55409. /**
  55410. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55411. * @param scene defines the current scene where to apply this optimization
  55412. * @param optimizer defines the current optimizer
  55413. * @returns true if everything that can be done was applied
  55414. */
  55415. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55416. }
  55417. /**
  55418. * Defines an optimization used to merge meshes with compatible materials
  55419. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55420. */
  55421. export class MergeMeshesOptimization extends SceneOptimization {
  55422. private static _UpdateSelectionTree;
  55423. /**
  55424. * Gets or sets a boolean which defines if optimization octree has to be updated
  55425. */
  55426. /**
  55427. * Gets or sets a boolean which defines if optimization octree has to be updated
  55428. */
  55429. static UpdateSelectionTree: boolean;
  55430. /**
  55431. * Gets a string describing the action executed by the current optimization
  55432. * @return description string
  55433. */
  55434. getDescription(): string;
  55435. private _canBeMerged;
  55436. /**
  55437. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55438. * @param scene defines the current scene where to apply this optimization
  55439. * @param optimizer defines the current optimizer
  55440. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55441. * @returns true if everything that can be done was applied
  55442. */
  55443. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55444. }
  55445. /**
  55446. * Defines a list of options used by SceneOptimizer
  55447. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55448. */
  55449. export class SceneOptimizerOptions {
  55450. /**
  55451. * Defines the target frame rate to reach (60 by default)
  55452. */
  55453. targetFrameRate: number;
  55454. /**
  55455. * Defines the interval between two checkes (2000ms by default)
  55456. */
  55457. trackerDuration: number;
  55458. /**
  55459. * Gets the list of optimizations to apply
  55460. */
  55461. optimizations: SceneOptimization[];
  55462. /**
  55463. * Creates a new list of options used by SceneOptimizer
  55464. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55465. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55466. */
  55467. constructor(
  55468. /**
  55469. * Defines the target frame rate to reach (60 by default)
  55470. */
  55471. targetFrameRate?: number,
  55472. /**
  55473. * Defines the interval between two checkes (2000ms by default)
  55474. */
  55475. trackerDuration?: number);
  55476. /**
  55477. * Add a new optimization
  55478. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55479. * @returns the current SceneOptimizerOptions
  55480. */
  55481. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55482. /**
  55483. * Add a new custom optimization
  55484. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55485. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55486. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55487. * @returns the current SceneOptimizerOptions
  55488. */
  55489. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55490. /**
  55491. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55492. * @param targetFrameRate defines the target frame rate (60 by default)
  55493. * @returns a SceneOptimizerOptions object
  55494. */
  55495. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55496. /**
  55497. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55498. * @param targetFrameRate defines the target frame rate (60 by default)
  55499. * @returns a SceneOptimizerOptions object
  55500. */
  55501. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55502. /**
  55503. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55504. * @param targetFrameRate defines the target frame rate (60 by default)
  55505. * @returns a SceneOptimizerOptions object
  55506. */
  55507. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55508. }
  55509. /**
  55510. * Class used to run optimizations in order to reach a target frame rate
  55511. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55512. */
  55513. export class SceneOptimizer implements IDisposable {
  55514. private _isRunning;
  55515. private _options;
  55516. private _scene;
  55517. private _currentPriorityLevel;
  55518. private _targetFrameRate;
  55519. private _trackerDuration;
  55520. private _currentFrameRate;
  55521. private _sceneDisposeObserver;
  55522. private _improvementMode;
  55523. /**
  55524. * Defines an observable called when the optimizer reaches the target frame rate
  55525. */
  55526. onSuccessObservable: Observable<SceneOptimizer>;
  55527. /**
  55528. * Defines an observable called when the optimizer enables an optimization
  55529. */
  55530. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55531. /**
  55532. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55533. */
  55534. onFailureObservable: Observable<SceneOptimizer>;
  55535. /**
  55536. * Gets a boolean indicating if the optimizer is in improvement mode
  55537. */
  55538. readonly isInImprovementMode: boolean;
  55539. /**
  55540. * Gets the current priority level (0 at start)
  55541. */
  55542. readonly currentPriorityLevel: number;
  55543. /**
  55544. * Gets the current frame rate checked by the SceneOptimizer
  55545. */
  55546. readonly currentFrameRate: number;
  55547. /**
  55548. * Gets or sets the current target frame rate (60 by default)
  55549. */
  55550. /**
  55551. * Gets or sets the current target frame rate (60 by default)
  55552. */
  55553. targetFrameRate: number;
  55554. /**
  55555. * Gets or sets the current interval between two checks (every 2000ms by default)
  55556. */
  55557. /**
  55558. * Gets or sets the current interval between two checks (every 2000ms by default)
  55559. */
  55560. trackerDuration: number;
  55561. /**
  55562. * Gets the list of active optimizations
  55563. */
  55564. readonly optimizations: SceneOptimization[];
  55565. /**
  55566. * Creates a new SceneOptimizer
  55567. * @param scene defines the scene to work on
  55568. * @param options defines the options to use with the SceneOptimizer
  55569. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55570. * @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)
  55571. */
  55572. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55573. /**
  55574. * Stops the current optimizer
  55575. */
  55576. stop(): void;
  55577. /**
  55578. * Reset the optimizer to initial step (current priority level = 0)
  55579. */
  55580. reset(): void;
  55581. /**
  55582. * Start the optimizer. By default it will try to reach a specific framerate
  55583. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55584. */
  55585. start(): void;
  55586. private _checkCurrentState;
  55587. /**
  55588. * Release all resources
  55589. */
  55590. dispose(): void;
  55591. /**
  55592. * Helper function to create a SceneOptimizer with one single line of code
  55593. * @param scene defines the scene to work on
  55594. * @param options defines the options to use with the SceneOptimizer
  55595. * @param onSuccess defines a callback to call on success
  55596. * @param onFailure defines a callback to call on failure
  55597. * @returns the new SceneOptimizer object
  55598. */
  55599. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55600. }
  55601. }
  55602. declare module "babylonjs/Misc/sceneSerializer" {
  55603. import { Scene } from "babylonjs/scene";
  55604. /**
  55605. * Class used to serialize a scene into a string
  55606. */
  55607. export class SceneSerializer {
  55608. /**
  55609. * Clear cache used by a previous serialization
  55610. */
  55611. static ClearCache(): void;
  55612. /**
  55613. * Serialize a scene into a JSON compatible object
  55614. * @param scene defines the scene to serialize
  55615. * @returns a JSON compatible object
  55616. */
  55617. static Serialize(scene: Scene): any;
  55618. /**
  55619. * Serialize a mesh into a JSON compatible object
  55620. * @param toSerialize defines the mesh to serialize
  55621. * @param withParents defines if parents must be serialized as well
  55622. * @param withChildren defines if children must be serialized as well
  55623. * @returns a JSON compatible object
  55624. */
  55625. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55626. }
  55627. }
  55628. declare module "babylonjs/Misc/videoRecorder" {
  55629. import { Nullable } from "babylonjs/types";
  55630. import { Engine } from "babylonjs/Engines/engine";
  55631. /**
  55632. * This represents the different options avilable for the video capture.
  55633. */
  55634. export interface VideoRecorderOptions {
  55635. /** Defines the mime type of the video */
  55636. mimeType: string;
  55637. /** Defines the video the video should be recorded at */
  55638. fps: number;
  55639. /** Defines the chunk size for the recording data */
  55640. recordChunckSize: number;
  55641. }
  55642. /**
  55643. * This can helps recording videos from BabylonJS.
  55644. * This is based on the available WebRTC functionalities of the browser.
  55645. *
  55646. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55647. */
  55648. export class VideoRecorder {
  55649. private static readonly _defaultOptions;
  55650. /**
  55651. * Returns wehther or not the VideoRecorder is available in your browser.
  55652. * @param engine Defines the Babylon Engine to check the support for
  55653. * @returns true if supported otherwise false
  55654. */
  55655. static IsSupported(engine: Engine): boolean;
  55656. private readonly _options;
  55657. private _canvas;
  55658. private _mediaRecorder;
  55659. private _recordedChunks;
  55660. private _fileName;
  55661. private _resolve;
  55662. private _reject;
  55663. /**
  55664. * True wether a recording is already in progress.
  55665. */
  55666. readonly isRecording: boolean;
  55667. /**
  55668. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55669. * a video file.
  55670. * @param engine Defines the BabylonJS Engine you wish to record
  55671. * @param options Defines options that can be used to customized the capture
  55672. */
  55673. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55674. /**
  55675. * Stops the current recording before the default capture timeout passed in the startRecording
  55676. * functions.
  55677. */
  55678. stopRecording(): void;
  55679. /**
  55680. * Starts recording the canvas for a max duration specified in parameters.
  55681. * @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.
  55682. * @param maxDuration Defines the maximum recording time in seconds.
  55683. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55684. * @return a promise callback at the end of the recording with the video data in Blob.
  55685. */
  55686. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55687. /**
  55688. * Releases internal resources used during the recording.
  55689. */
  55690. dispose(): void;
  55691. private _handleDataAvailable;
  55692. private _handleError;
  55693. private _handleStop;
  55694. }
  55695. }
  55696. declare module "babylonjs/Misc/workerPool" {
  55697. import { IDisposable } from "babylonjs/scene";
  55698. /**
  55699. * Helper class to push actions to a pool of workers.
  55700. */
  55701. export class WorkerPool implements IDisposable {
  55702. private _workerInfos;
  55703. private _pendingActions;
  55704. /**
  55705. * Constructor
  55706. * @param workers Array of workers to use for actions
  55707. */
  55708. constructor(workers: Array<Worker>);
  55709. /**
  55710. * Terminates all workers and clears any pending actions.
  55711. */
  55712. dispose(): void;
  55713. /**
  55714. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55715. * pended until a worker has completed its action.
  55716. * @param action The action to perform. Call onComplete when the action is complete.
  55717. */
  55718. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55719. private _execute;
  55720. }
  55721. }
  55722. declare module "babylonjs/Misc/screenshotTools" {
  55723. import { Camera } from "babylonjs/Cameras/camera";
  55724. import { Engine } from "babylonjs/Engines/engine";
  55725. /**
  55726. * Class containing a set of static utilities functions for screenshots
  55727. */
  55728. export class ScreenshotTools {
  55729. /**
  55730. * Captures a screenshot of the current rendering
  55731. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55732. * @param engine defines the rendering engine
  55733. * @param camera defines the source camera
  55734. * @param size This parameter can be set to a single number or to an object with the
  55735. * following (optional) properties: precision, width, height. If a single number is passed,
  55736. * it will be used for both width and height. If an object is passed, the screenshot size
  55737. * will be derived from the parameters. The precision property is a multiplier allowing
  55738. * rendering at a higher or lower resolution
  55739. * @param successCallback defines the callback receives a single parameter which contains the
  55740. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55741. * src parameter of an <img> to display it
  55742. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55743. * Check your browser for supported MIME types
  55744. */
  55745. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55746. /**
  55747. * Generates an image screenshot from the specified camera.
  55748. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55749. * @param engine The engine to use for rendering
  55750. * @param camera The camera to use for rendering
  55751. * @param size This parameter can be set to a single number or to an object with the
  55752. * following (optional) properties: precision, width, height. If a single number is passed,
  55753. * it will be used for both width and height. If an object is passed, the screenshot size
  55754. * will be derived from the parameters. The precision property is a multiplier allowing
  55755. * rendering at a higher or lower resolution
  55756. * @param successCallback The callback receives a single parameter which contains the
  55757. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55758. * src parameter of an <img> to display it
  55759. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55760. * Check your browser for supported MIME types
  55761. * @param samples Texture samples (default: 1)
  55762. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55763. * @param fileName A name for for the downloaded file.
  55764. */
  55765. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55766. }
  55767. }
  55768. declare module "babylonjs/Misc/index" {
  55769. export * from "babylonjs/Misc/andOrNotEvaluator";
  55770. export * from "babylonjs/Misc/assetsManager";
  55771. export * from "babylonjs/Misc/dds";
  55772. export * from "babylonjs/Misc/decorators";
  55773. export * from "babylonjs/Misc/deferred";
  55774. export * from "babylonjs/Misc/environmentTextureTools";
  55775. export * from "babylonjs/Misc/filesInput";
  55776. export * from "babylonjs/Misc/HighDynamicRange/index";
  55777. export * from "babylonjs/Misc/khronosTextureContainer";
  55778. export * from "babylonjs/Misc/observable";
  55779. export * from "babylonjs/Misc/performanceMonitor";
  55780. export * from "babylonjs/Misc/promise";
  55781. export * from "babylonjs/Misc/sceneOptimizer";
  55782. export * from "babylonjs/Misc/sceneSerializer";
  55783. export * from "babylonjs/Misc/smartArray";
  55784. export * from "babylonjs/Misc/stringDictionary";
  55785. export * from "babylonjs/Misc/tags";
  55786. export * from "babylonjs/Misc/textureTools";
  55787. export * from "babylonjs/Misc/tga";
  55788. export * from "babylonjs/Misc/tools";
  55789. export * from "babylonjs/Misc/videoRecorder";
  55790. export * from "babylonjs/Misc/virtualJoystick";
  55791. export * from "babylonjs/Misc/workerPool";
  55792. export * from "babylonjs/Misc/logger";
  55793. export * from "babylonjs/Misc/typeStore";
  55794. export * from "babylonjs/Misc/filesInputStore";
  55795. export * from "babylonjs/Misc/deepCopier";
  55796. export * from "babylonjs/Misc/pivotTools";
  55797. export * from "babylonjs/Misc/precisionDate";
  55798. export * from "babylonjs/Misc/screenshotTools";
  55799. export * from "babylonjs/Misc/typeStore";
  55800. }
  55801. declare module "babylonjs/index" {
  55802. export * from "babylonjs/abstractScene";
  55803. export * from "babylonjs/Actions/index";
  55804. export * from "babylonjs/Animations/index";
  55805. export * from "babylonjs/assetContainer";
  55806. export * from "babylonjs/Audio/index";
  55807. export * from "babylonjs/Behaviors/index";
  55808. export * from "babylonjs/Bones/index";
  55809. export * from "babylonjs/Cameras/index";
  55810. export * from "babylonjs/Collisions/index";
  55811. export * from "babylonjs/Culling/index";
  55812. export * from "babylonjs/Debug/index";
  55813. export * from "babylonjs/Engines/index";
  55814. export * from "babylonjs/Events/index";
  55815. export * from "babylonjs/Gamepads/index";
  55816. export * from "babylonjs/Gizmos/index";
  55817. export * from "babylonjs/Helpers/index";
  55818. export * from "babylonjs/Instrumentation/index";
  55819. export * from "babylonjs/Layers/index";
  55820. export * from "babylonjs/LensFlares/index";
  55821. export * from "babylonjs/Lights/index";
  55822. export * from "babylonjs/Loading/index";
  55823. export * from "babylonjs/Materials/index";
  55824. export * from "babylonjs/Maths/index";
  55825. export * from "babylonjs/Meshes/index";
  55826. export * from "babylonjs/Morph/index";
  55827. export * from "babylonjs/node";
  55828. export * from "babylonjs/Offline/index";
  55829. export * from "babylonjs/Particles/index";
  55830. export * from "babylonjs/Physics/index";
  55831. export * from "babylonjs/PostProcesses/index";
  55832. export * from "babylonjs/Probes/index";
  55833. export * from "babylonjs/Rendering/index";
  55834. export * from "babylonjs/scene";
  55835. export * from "babylonjs/sceneComponent";
  55836. export * from "babylonjs/Sprites/index";
  55837. export * from "babylonjs/States/index";
  55838. export * from "babylonjs/Misc/index";
  55839. export * from "babylonjs/types";
  55840. }
  55841. declare module "babylonjs/Animations/pathCursor" {
  55842. import { Path2, Vector3 } from "babylonjs/Maths/math";
  55843. /**
  55844. * A cursor which tracks a point on a path
  55845. */
  55846. export class PathCursor {
  55847. private path;
  55848. /**
  55849. * Stores path cursor callbacks for when an onchange event is triggered
  55850. */
  55851. private _onchange;
  55852. /**
  55853. * The value of the path cursor
  55854. */
  55855. value: number;
  55856. /**
  55857. * The animation array of the path cursor
  55858. */
  55859. animations: Animation[];
  55860. /**
  55861. * Initializes the path cursor
  55862. * @param path The path to track
  55863. */
  55864. constructor(path: Path2);
  55865. /**
  55866. * Gets the cursor point on the path
  55867. * @returns A point on the path cursor at the cursor location
  55868. */
  55869. getPoint(): Vector3;
  55870. /**
  55871. * Moves the cursor ahead by the step amount
  55872. * @param step The amount to move the cursor forward
  55873. * @returns This path cursor
  55874. */
  55875. moveAhead(step?: number): PathCursor;
  55876. /**
  55877. * Moves the cursor behind by the step amount
  55878. * @param step The amount to move the cursor back
  55879. * @returns This path cursor
  55880. */
  55881. moveBack(step?: number): PathCursor;
  55882. /**
  55883. * Moves the cursor by the step amount
  55884. * If the step amount is greater than one, an exception is thrown
  55885. * @param step The amount to move the cursor
  55886. * @returns This path cursor
  55887. */
  55888. move(step: number): PathCursor;
  55889. /**
  55890. * Ensures that the value is limited between zero and one
  55891. * @returns This path cursor
  55892. */
  55893. private ensureLimits;
  55894. /**
  55895. * Runs onchange callbacks on change (used by the animation engine)
  55896. * @returns This path cursor
  55897. */
  55898. private raiseOnChange;
  55899. /**
  55900. * Executes a function on change
  55901. * @param f A path cursor onchange callback
  55902. * @returns This path cursor
  55903. */
  55904. onchange(f: (cursor: PathCursor) => void): PathCursor;
  55905. }
  55906. }
  55907. declare module "babylonjs/Legacy/legacy" {
  55908. export * from "babylonjs/index";
  55909. }
  55910. declare module "babylonjs/Shaders/blur.fragment" {
  55911. /** @hidden */
  55912. export var blurPixelShader: {
  55913. name: string;
  55914. shader: string;
  55915. };
  55916. }
  55917. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  55918. /** @hidden */
  55919. export var bones300Declaration: {
  55920. name: string;
  55921. shader: string;
  55922. };
  55923. }
  55924. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  55925. /** @hidden */
  55926. export var instances300Declaration: {
  55927. name: string;
  55928. shader: string;
  55929. };
  55930. }
  55931. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  55932. /** @hidden */
  55933. export var pointCloudVertexDeclaration: {
  55934. name: string;
  55935. shader: string;
  55936. };
  55937. }
  55938. // Mixins
  55939. interface Window {
  55940. mozIndexedDB: IDBFactory;
  55941. webkitIndexedDB: IDBFactory;
  55942. msIndexedDB: IDBFactory;
  55943. webkitURL: typeof URL;
  55944. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55945. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55946. WebGLRenderingContext: WebGLRenderingContext;
  55947. MSGesture: MSGesture;
  55948. CANNON: any;
  55949. AudioContext: AudioContext;
  55950. webkitAudioContext: AudioContext;
  55951. PointerEvent: any;
  55952. Math: Math;
  55953. Uint8Array: Uint8ArrayConstructor;
  55954. Float32Array: Float32ArrayConstructor;
  55955. mozURL: typeof URL;
  55956. msURL: typeof URL;
  55957. VRFrameData: any; // WebVR, from specs 1.1
  55958. DracoDecoderModule: any;
  55959. setImmediate(handler: (...args: any[]) => void): number;
  55960. }
  55961. interface Document {
  55962. mozCancelFullScreen(): void;
  55963. msCancelFullScreen(): void;
  55964. webkitCancelFullScreen(): void;
  55965. requestPointerLock(): void;
  55966. exitPointerLock(): void;
  55967. mozFullScreen: boolean;
  55968. msIsFullScreen: boolean;
  55969. readonly webkitIsFullScreen: boolean;
  55970. readonly pointerLockElement: Element;
  55971. mozPointerLockElement: HTMLElement;
  55972. msPointerLockElement: HTMLElement;
  55973. webkitPointerLockElement: HTMLElement;
  55974. }
  55975. interface HTMLCanvasElement {
  55976. requestPointerLock(): void;
  55977. msRequestPointerLock?(): void;
  55978. mozRequestPointerLock?(): void;
  55979. webkitRequestPointerLock?(): void;
  55980. /** Track wether a record is in progress */
  55981. isRecording: boolean;
  55982. /** Capture Stream method defined by some browsers */
  55983. captureStream(fps?: number): MediaStream;
  55984. }
  55985. interface CanvasRenderingContext2D {
  55986. msImageSmoothingEnabled: boolean;
  55987. }
  55988. interface MouseEvent {
  55989. mozMovementX: number;
  55990. mozMovementY: number;
  55991. webkitMovementX: number;
  55992. webkitMovementY: number;
  55993. msMovementX: number;
  55994. msMovementY: number;
  55995. }
  55996. interface Navigator {
  55997. mozGetVRDevices: (any: any) => any;
  55998. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55999. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56000. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56001. webkitGetGamepads(): Gamepad[];
  56002. msGetGamepads(): Gamepad[];
  56003. webkitGamepads(): Gamepad[];
  56004. }
  56005. interface HTMLVideoElement {
  56006. mozSrcObject: any;
  56007. }
  56008. interface Math {
  56009. fround(x: number): number;
  56010. imul(a: number, b: number): number;
  56011. }
  56012. interface WebGLProgram {
  56013. context?: WebGLRenderingContext;
  56014. vertexShader?: WebGLShader;
  56015. fragmentShader?: WebGLShader;
  56016. isParallelCompiled: boolean;
  56017. onCompiled?: () => void;
  56018. }
  56019. interface WebGLRenderingContext {
  56020. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  56021. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  56022. vertexAttribDivisor(index: number, divisor: number): void;
  56023. createVertexArray(): any;
  56024. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  56025. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  56026. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  56027. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  56028. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  56029. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  56030. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  56031. // Queries
  56032. createQuery(): WebGLQuery;
  56033. deleteQuery(query: WebGLQuery): void;
  56034. beginQuery(target: number, query: WebGLQuery): void;
  56035. endQuery(target: number): void;
  56036. getQueryParameter(query: WebGLQuery, pname: number): any;
  56037. getQuery(target: number, pname: number): any;
  56038. MAX_SAMPLES: number;
  56039. RGBA8: number;
  56040. READ_FRAMEBUFFER: number;
  56041. DRAW_FRAMEBUFFER: number;
  56042. UNIFORM_BUFFER: number;
  56043. HALF_FLOAT_OES: number;
  56044. RGBA16F: number;
  56045. RGBA32F: number;
  56046. R32F: number;
  56047. RG32F: number;
  56048. RGB32F: number;
  56049. R16F: number;
  56050. RG16F: number;
  56051. RGB16F: number;
  56052. RED: number;
  56053. RG: number;
  56054. R8: number;
  56055. RG8: number;
  56056. UNSIGNED_INT_24_8: number;
  56057. DEPTH24_STENCIL8: number;
  56058. /* Multiple Render Targets */
  56059. drawBuffers(buffers: number[]): void;
  56060. readBuffer(src: number): void;
  56061. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  56062. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  56063. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  56064. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  56065. // Occlusion Query
  56066. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  56067. ANY_SAMPLES_PASSED: number;
  56068. QUERY_RESULT_AVAILABLE: number;
  56069. QUERY_RESULT: number;
  56070. }
  56071. interface WebGLBuffer {
  56072. references: number;
  56073. capacity: number;
  56074. is32Bits: boolean;
  56075. }
  56076. interface WebGLProgram {
  56077. transformFeedback?: WebGLTransformFeedback | null;
  56078. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  56079. }
  56080. interface EXT_disjoint_timer_query {
  56081. QUERY_COUNTER_BITS_EXT: number;
  56082. TIME_ELAPSED_EXT: number;
  56083. TIMESTAMP_EXT: number;
  56084. GPU_DISJOINT_EXT: number;
  56085. QUERY_RESULT_EXT: number;
  56086. QUERY_RESULT_AVAILABLE_EXT: number;
  56087. queryCounterEXT(query: WebGLQuery, target: number): void;
  56088. createQueryEXT(): WebGLQuery;
  56089. beginQueryEXT(target: number, query: WebGLQuery): void;
  56090. endQueryEXT(target: number): void;
  56091. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  56092. deleteQueryEXT(query: WebGLQuery): void;
  56093. }
  56094. interface WebGLUniformLocation {
  56095. _currentState: any;
  56096. }
  56097. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  56098. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  56099. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  56100. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56101. interface WebGLRenderingContext {
  56102. readonly RASTERIZER_DISCARD: number;
  56103. readonly DEPTH_COMPONENT24: number;
  56104. readonly TEXTURE_3D: number;
  56105. readonly TEXTURE_2D_ARRAY: number;
  56106. readonly TEXTURE_COMPARE_FUNC: number;
  56107. readonly TEXTURE_COMPARE_MODE: number;
  56108. readonly COMPARE_REF_TO_TEXTURE: number;
  56109. readonly TEXTURE_WRAP_R: number;
  56110. readonly HALF_FLOAT: number;
  56111. readonly RGB8: number;
  56112. readonly RED_INTEGER: number;
  56113. readonly RG_INTEGER: number;
  56114. readonly RGB_INTEGER: number;
  56115. readonly RGBA_INTEGER: number;
  56116. readonly R8_SNORM: number;
  56117. readonly RG8_SNORM: number;
  56118. readonly RGB8_SNORM: number;
  56119. readonly RGBA8_SNORM: number;
  56120. readonly R8I: number;
  56121. readonly RG8I: number;
  56122. readonly RGB8I: number;
  56123. readonly RGBA8I: number;
  56124. readonly R8UI: number;
  56125. readonly RG8UI: number;
  56126. readonly RGB8UI: number;
  56127. readonly RGBA8UI: number;
  56128. readonly R16I: number;
  56129. readonly RG16I: number;
  56130. readonly RGB16I: number;
  56131. readonly RGBA16I: number;
  56132. readonly R16UI: number;
  56133. readonly RG16UI: number;
  56134. readonly RGB16UI: number;
  56135. readonly RGBA16UI: number;
  56136. readonly R32I: number;
  56137. readonly RG32I: number;
  56138. readonly RGB32I: number;
  56139. readonly RGBA32I: number;
  56140. readonly R32UI: number;
  56141. readonly RG32UI: number;
  56142. readonly RGB32UI: number;
  56143. readonly RGBA32UI: number;
  56144. readonly RGB10_A2UI: number;
  56145. readonly R11F_G11F_B10F: number;
  56146. readonly RGB9_E5: number;
  56147. readonly RGB10_A2: number;
  56148. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  56149. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  56150. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  56151. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  56152. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  56153. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  56154. 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;
  56155. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  56156. readonly TRANSFORM_FEEDBACK: number;
  56157. readonly INTERLEAVED_ATTRIBS: number;
  56158. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  56159. createTransformFeedback(): WebGLTransformFeedback;
  56160. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  56161. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  56162. beginTransformFeedback(primitiveMode: number): void;
  56163. endTransformFeedback(): void;
  56164. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  56165. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56166. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56167. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56168. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  56169. }
  56170. interface ImageBitmap {
  56171. readonly width: number;
  56172. readonly height: number;
  56173. close(): void;
  56174. }
  56175. interface WebGLQuery extends WebGLObject {
  56176. }
  56177. declare var WebGLQuery: {
  56178. prototype: WebGLQuery;
  56179. new(): WebGLQuery;
  56180. };
  56181. interface WebGLSampler extends WebGLObject {
  56182. }
  56183. declare var WebGLSampler: {
  56184. prototype: WebGLSampler;
  56185. new(): WebGLSampler;
  56186. };
  56187. interface WebGLSync extends WebGLObject {
  56188. }
  56189. declare var WebGLSync: {
  56190. prototype: WebGLSync;
  56191. new(): WebGLSync;
  56192. };
  56193. interface WebGLTransformFeedback extends WebGLObject {
  56194. }
  56195. declare var WebGLTransformFeedback: {
  56196. prototype: WebGLTransformFeedback;
  56197. new(): WebGLTransformFeedback;
  56198. };
  56199. interface WebGLVertexArrayObject extends WebGLObject {
  56200. }
  56201. declare var WebGLVertexArrayObject: {
  56202. prototype: WebGLVertexArrayObject;
  56203. new(): WebGLVertexArrayObject;
  56204. };
  56205. // Type definitions for WebVR API
  56206. // Project: https://w3c.github.io/webvr/
  56207. // Definitions by: six a <https://github.com/lostfictions>
  56208. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56209. interface VRDisplay extends EventTarget {
  56210. /**
  56211. * Dictionary of capabilities describing the VRDisplay.
  56212. */
  56213. readonly capabilities: VRDisplayCapabilities;
  56214. /**
  56215. * z-depth defining the far plane of the eye view frustum
  56216. * enables mapping of values in the render target depth
  56217. * attachment to scene coordinates. Initially set to 10000.0.
  56218. */
  56219. depthFar: number;
  56220. /**
  56221. * z-depth defining the near plane of the eye view frustum
  56222. * enables mapping of values in the render target depth
  56223. * attachment to scene coordinates. Initially set to 0.01.
  56224. */
  56225. depthNear: number;
  56226. /**
  56227. * An identifier for this distinct VRDisplay. Used as an
  56228. * association point in the Gamepad API.
  56229. */
  56230. readonly displayId: number;
  56231. /**
  56232. * A display name, a user-readable name identifying it.
  56233. */
  56234. readonly displayName: string;
  56235. readonly isConnected: boolean;
  56236. readonly isPresenting: boolean;
  56237. /**
  56238. * If this VRDisplay supports room-scale experiences, the optional
  56239. * stage attribute contains details on the room-scale parameters.
  56240. */
  56241. readonly stageParameters: VRStageParameters | null;
  56242. /**
  56243. * Passing the value returned by `requestAnimationFrame` to
  56244. * `cancelAnimationFrame` will unregister the callback.
  56245. * @param handle Define the hanle of the request to cancel
  56246. */
  56247. cancelAnimationFrame(handle: number): void;
  56248. /**
  56249. * Stops presenting to the VRDisplay.
  56250. * @returns a promise to know when it stopped
  56251. */
  56252. exitPresent(): Promise<void>;
  56253. /**
  56254. * Return the current VREyeParameters for the given eye.
  56255. * @param whichEye Define the eye we want the parameter for
  56256. * @returns the eye parameters
  56257. */
  56258. getEyeParameters(whichEye: string): VREyeParameters;
  56259. /**
  56260. * Populates the passed VRFrameData with the information required to render
  56261. * the current frame.
  56262. * @param frameData Define the data structure to populate
  56263. * @returns true if ok otherwise false
  56264. */
  56265. getFrameData(frameData: VRFrameData): boolean;
  56266. /**
  56267. * Get the layers currently being presented.
  56268. * @returns the list of VR layers
  56269. */
  56270. getLayers(): VRLayer[];
  56271. /**
  56272. * Return a VRPose containing the future predicted pose of the VRDisplay
  56273. * when the current frame will be presented. The value returned will not
  56274. * change until JavaScript has returned control to the browser.
  56275. *
  56276. * The VRPose will contain the position, orientation, velocity,
  56277. * and acceleration of each of these properties.
  56278. * @returns the pose object
  56279. */
  56280. getPose(): VRPose;
  56281. /**
  56282. * Return the current instantaneous pose of the VRDisplay, with no
  56283. * prediction applied.
  56284. * @returns the current instantaneous pose
  56285. */
  56286. getImmediatePose(): VRPose;
  56287. /**
  56288. * The callback passed to `requestAnimationFrame` will be called
  56289. * any time a new frame should be rendered. When the VRDisplay is
  56290. * presenting the callback will be called at the native refresh
  56291. * rate of the HMD. When not presenting this function acts
  56292. * identically to how window.requestAnimationFrame acts. Content should
  56293. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56294. * asynchronously from other displays and at differing refresh rates.
  56295. * @param callback Define the eaction to run next frame
  56296. * @returns the request handle it
  56297. */
  56298. requestAnimationFrame(callback: FrameRequestCallback): number;
  56299. /**
  56300. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56301. * Repeat calls while already presenting will update the VRLayers being displayed.
  56302. * @param layers Define the list of layer to present
  56303. * @returns a promise to know when the request has been fulfilled
  56304. */
  56305. requestPresent(layers: VRLayer[]): Promise<void>;
  56306. /**
  56307. * Reset the pose for this display, treating its current position and
  56308. * orientation as the "origin/zero" values. VRPose.position,
  56309. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56310. * updated when calling resetPose(). This should be called in only
  56311. * sitting-space experiences.
  56312. */
  56313. resetPose(): void;
  56314. /**
  56315. * The VRLayer provided to the VRDisplay will be captured and presented
  56316. * in the HMD. Calling this function has the same effect on the source
  56317. * canvas as any other operation that uses its source image, and canvases
  56318. * created without preserveDrawingBuffer set to true will be cleared.
  56319. * @param pose Define the pose to submit
  56320. */
  56321. submitFrame(pose?: VRPose): void;
  56322. }
  56323. declare var VRDisplay: {
  56324. prototype: VRDisplay;
  56325. new(): VRDisplay;
  56326. };
  56327. interface VRLayer {
  56328. leftBounds?: number[] | Float32Array | null;
  56329. rightBounds?: number[] | Float32Array | null;
  56330. source?: HTMLCanvasElement | null;
  56331. }
  56332. interface VRDisplayCapabilities {
  56333. readonly canPresent: boolean;
  56334. readonly hasExternalDisplay: boolean;
  56335. readonly hasOrientation: boolean;
  56336. readonly hasPosition: boolean;
  56337. readonly maxLayers: number;
  56338. }
  56339. interface VREyeParameters {
  56340. /** @deprecated */
  56341. readonly fieldOfView: VRFieldOfView;
  56342. readonly offset: Float32Array;
  56343. readonly renderHeight: number;
  56344. readonly renderWidth: number;
  56345. }
  56346. interface VRFieldOfView {
  56347. readonly downDegrees: number;
  56348. readonly leftDegrees: number;
  56349. readonly rightDegrees: number;
  56350. readonly upDegrees: number;
  56351. }
  56352. interface VRFrameData {
  56353. readonly leftProjectionMatrix: Float32Array;
  56354. readonly leftViewMatrix: Float32Array;
  56355. readonly pose: VRPose;
  56356. readonly rightProjectionMatrix: Float32Array;
  56357. readonly rightViewMatrix: Float32Array;
  56358. readonly timestamp: number;
  56359. }
  56360. interface VRPose {
  56361. readonly angularAcceleration: Float32Array | null;
  56362. readonly angularVelocity: Float32Array | null;
  56363. readonly linearAcceleration: Float32Array | null;
  56364. readonly linearVelocity: Float32Array | null;
  56365. readonly orientation: Float32Array | null;
  56366. readonly position: Float32Array | null;
  56367. readonly timestamp: number;
  56368. }
  56369. interface VRStageParameters {
  56370. sittingToStandingTransform?: Float32Array;
  56371. sizeX?: number;
  56372. sizeY?: number;
  56373. }
  56374. interface Navigator {
  56375. getVRDisplays(): Promise<VRDisplay[]>;
  56376. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  56377. }
  56378. interface Window {
  56379. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  56380. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  56381. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  56382. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56383. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56384. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  56385. }
  56386. interface Gamepad {
  56387. readonly displayId: number;
  56388. }
  56389. interface XRDevice {
  56390. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  56391. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  56392. }
  56393. interface XRSession {
  56394. getInputSources(): Array<any>;
  56395. baseLayer: XRWebGLLayer;
  56396. requestFrameOfReference(type: string): Promise<void>;
  56397. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  56398. end(): Promise<void>;
  56399. requestAnimationFrame: Function;
  56400. addEventListener: Function;
  56401. }
  56402. interface XRSessionCreationOptions {
  56403. outputContext?: WebGLRenderingContext | null;
  56404. immersive?: boolean;
  56405. environmentIntegration?: boolean;
  56406. }
  56407. interface XRLayer {
  56408. getViewport: Function;
  56409. framebufferWidth: number;
  56410. framebufferHeight: number;
  56411. }
  56412. interface XRView {
  56413. projectionMatrix: Float32Array;
  56414. }
  56415. interface XRFrame {
  56416. getDevicePose: Function;
  56417. getInputPose: Function;
  56418. views: Array<XRView>;
  56419. baseLayer: XRLayer;
  56420. }
  56421. interface XRFrameOfReference {
  56422. }
  56423. interface XRWebGLLayer extends XRLayer {
  56424. framebuffer: WebGLFramebuffer;
  56425. }
  56426. declare var XRWebGLLayer: {
  56427. prototype: XRWebGLLayer;
  56428. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  56429. };
  56430. declare module "babylonjs" {
  56431. export * from "babylonjs/Legacy/legacy";
  56432. }
  56433. declare module BABYLON {
  56434. /** Alias type for value that can be null */
  56435. export type Nullable<T> = T | null;
  56436. /**
  56437. * Alias type for number that are floats
  56438. * @ignorenaming
  56439. */
  56440. export type float = number;
  56441. /**
  56442. * Alias type for number that are doubles.
  56443. * @ignorenaming
  56444. */
  56445. export type double = number;
  56446. /**
  56447. * Alias type for number that are integer
  56448. * @ignorenaming
  56449. */
  56450. export type int = number;
  56451. /** Alias type for number array or Float32Array */
  56452. export type FloatArray = number[] | Float32Array;
  56453. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  56454. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  56455. /**
  56456. * Alias for types that can be used by a Buffer or VertexBuffer.
  56457. */
  56458. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  56459. /**
  56460. * Alias type for primitive types
  56461. * @ignorenaming
  56462. */
  56463. type Primitive = undefined | null | boolean | string | number | Function;
  56464. /**
  56465. * Type modifier to make all the properties of an object Readonly
  56466. */
  56467. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  56468. /**
  56469. * Type modifier to make all the properties of an object Readonly recursively
  56470. */
  56471. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  56472. /** @hidden */
  56473. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  56474. }
  56475. /** @hidden */
  56476. /** @hidden */
  56477. type DeepImmutableObject<T> = {
  56478. readonly [K in keyof T]: DeepImmutable<T[K]>;
  56479. };
  56480. }
  56481. declare module BABYLON {
  56482. /**
  56483. * Class containing a set of static utilities functions for arrays.
  56484. */
  56485. export class ArrayTools {
  56486. /**
  56487. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56488. * @param size the number of element to construct and put in the array
  56489. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  56490. * @returns a new array filled with new objects
  56491. */
  56492. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  56493. }
  56494. }
  56495. declare module BABYLON {
  56496. /**
  56497. * Scalar computation library
  56498. */
  56499. export class Scalar {
  56500. /**
  56501. * Two pi constants convenient for computation.
  56502. */
  56503. static TwoPi: number;
  56504. /**
  56505. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  56506. * @param a number
  56507. * @param b number
  56508. * @param epsilon (default = 1.401298E-45)
  56509. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  56510. */
  56511. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  56512. /**
  56513. * Returns a string : the upper case translation of the number i to hexadecimal.
  56514. * @param i number
  56515. * @returns the upper case translation of the number i to hexadecimal.
  56516. */
  56517. static ToHex(i: number): string;
  56518. /**
  56519. * Returns -1 if value is negative and +1 is value is positive.
  56520. * @param value the value
  56521. * @returns the value itself if it's equal to zero.
  56522. */
  56523. static Sign(value: number): number;
  56524. /**
  56525. * Returns the value itself if it's between min and max.
  56526. * Returns min if the value is lower than min.
  56527. * Returns max if the value is greater than max.
  56528. * @param value the value to clmap
  56529. * @param min the min value to clamp to (default: 0)
  56530. * @param max the max value to clamp to (default: 1)
  56531. * @returns the clamped value
  56532. */
  56533. static Clamp(value: number, min?: number, max?: number): number;
  56534. /**
  56535. * the log2 of value.
  56536. * @param value the value to compute log2 of
  56537. * @returns the log2 of value.
  56538. */
  56539. static Log2(value: number): number;
  56540. /**
  56541. * Loops the value, so that it is never larger than length and never smaller than 0.
  56542. *
  56543. * This is similar to the modulo operator but it works with floating point numbers.
  56544. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  56545. * With t = 5 and length = 2.5, the result would be 0.0.
  56546. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  56547. * @param value the value
  56548. * @param length the length
  56549. * @returns the looped value
  56550. */
  56551. static Repeat(value: number, length: number): number;
  56552. /**
  56553. * Normalize the value between 0.0 and 1.0 using min and max values
  56554. * @param value value to normalize
  56555. * @param min max to normalize between
  56556. * @param max min to normalize between
  56557. * @returns the normalized value
  56558. */
  56559. static Normalize(value: number, min: number, max: number): number;
  56560. /**
  56561. * Denormalize the value from 0.0 and 1.0 using min and max values
  56562. * @param normalized value to denormalize
  56563. * @param min max to denormalize between
  56564. * @param max min to denormalize between
  56565. * @returns the denormalized value
  56566. */
  56567. static Denormalize(normalized: number, min: number, max: number): number;
  56568. /**
  56569. * Calculates the shortest difference between two given angles given in degrees.
  56570. * @param current current angle in degrees
  56571. * @param target target angle in degrees
  56572. * @returns the delta
  56573. */
  56574. static DeltaAngle(current: number, target: number): number;
  56575. /**
  56576. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  56577. * @param tx value
  56578. * @param length length
  56579. * @returns The returned value will move back and forth between 0 and length
  56580. */
  56581. static PingPong(tx: number, length: number): number;
  56582. /**
  56583. * Interpolates between min and max with smoothing at the limits.
  56584. *
  56585. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  56586. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  56587. * @param from from
  56588. * @param to to
  56589. * @param tx value
  56590. * @returns the smooth stepped value
  56591. */
  56592. static SmoothStep(from: number, to: number, tx: number): number;
  56593. /**
  56594. * Moves a value current towards target.
  56595. *
  56596. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  56597. * Negative values of maxDelta pushes the value away from target.
  56598. * @param current current value
  56599. * @param target target value
  56600. * @param maxDelta max distance to move
  56601. * @returns resulting value
  56602. */
  56603. static MoveTowards(current: number, target: number, maxDelta: number): number;
  56604. /**
  56605. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  56606. *
  56607. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  56608. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  56609. * @param current current value
  56610. * @param target target value
  56611. * @param maxDelta max distance to move
  56612. * @returns resulting angle
  56613. */
  56614. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  56615. /**
  56616. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  56617. * @param start start value
  56618. * @param end target value
  56619. * @param amount amount to lerp between
  56620. * @returns the lerped value
  56621. */
  56622. static Lerp(start: number, end: number, amount: number): number;
  56623. /**
  56624. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  56625. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  56626. * @param start start value
  56627. * @param end target value
  56628. * @param amount amount to lerp between
  56629. * @returns the lerped value
  56630. */
  56631. static LerpAngle(start: number, end: number, amount: number): number;
  56632. /**
  56633. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  56634. * @param a start value
  56635. * @param b target value
  56636. * @param value value between a and b
  56637. * @returns the inverseLerp value
  56638. */
  56639. static InverseLerp(a: number, b: number, value: number): number;
  56640. /**
  56641. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  56642. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  56643. * @param value1 spline value
  56644. * @param tangent1 spline value
  56645. * @param value2 spline value
  56646. * @param tangent2 spline value
  56647. * @param amount input value
  56648. * @returns hermite result
  56649. */
  56650. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  56651. /**
  56652. * Returns a random float number between and min and max values
  56653. * @param min min value of random
  56654. * @param max max value of random
  56655. * @returns random value
  56656. */
  56657. static RandomRange(min: number, max: number): number;
  56658. /**
  56659. * This function returns percentage of a number in a given range.
  56660. *
  56661. * RangeToPercent(40,20,60) will return 0.5 (50%)
  56662. * RangeToPercent(34,0,100) will return 0.34 (34%)
  56663. * @param number to convert to percentage
  56664. * @param min min range
  56665. * @param max max range
  56666. * @returns the percentage
  56667. */
  56668. static RangeToPercent(number: number, min: number, max: number): number;
  56669. /**
  56670. * This function returns number that corresponds to the percentage in a given range.
  56671. *
  56672. * PercentToRange(0.34,0,100) will return 34.
  56673. * @param percent to convert to number
  56674. * @param min min range
  56675. * @param max max range
  56676. * @returns the number
  56677. */
  56678. static PercentToRange(percent: number, min: number, max: number): number;
  56679. /**
  56680. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  56681. * @param angle The angle to normalize in radian.
  56682. * @return The converted angle.
  56683. */
  56684. static NormalizeRadians(angle: number): number;
  56685. }
  56686. }
  56687. declare module BABYLON {
  56688. /**
  56689. * Constant used to convert a value to gamma space
  56690. * @ignorenaming
  56691. */
  56692. export const ToGammaSpace: number;
  56693. /**
  56694. * Constant used to convert a value to linear space
  56695. * @ignorenaming
  56696. */
  56697. export const ToLinearSpace = 2.2;
  56698. /**
  56699. * Constant used to define the minimal number value in Babylon.js
  56700. * @ignorenaming
  56701. */
  56702. export const Epsilon = 0.001;
  56703. /**
  56704. * Class used to hold a RBG color
  56705. */
  56706. export class Color3 {
  56707. /**
  56708. * Defines the red component (between 0 and 1, default is 0)
  56709. */
  56710. r: number;
  56711. /**
  56712. * Defines the green component (between 0 and 1, default is 0)
  56713. */
  56714. g: number;
  56715. /**
  56716. * Defines the blue component (between 0 and 1, default is 0)
  56717. */
  56718. b: number;
  56719. /**
  56720. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  56721. * @param r defines the red component (between 0 and 1, default is 0)
  56722. * @param g defines the green component (between 0 and 1, default is 0)
  56723. * @param b defines the blue component (between 0 and 1, default is 0)
  56724. */
  56725. constructor(
  56726. /**
  56727. * Defines the red component (between 0 and 1, default is 0)
  56728. */
  56729. r?: number,
  56730. /**
  56731. * Defines the green component (between 0 and 1, default is 0)
  56732. */
  56733. g?: number,
  56734. /**
  56735. * Defines the blue component (between 0 and 1, default is 0)
  56736. */
  56737. b?: number);
  56738. /**
  56739. * Creates a string with the Color3 current values
  56740. * @returns the string representation of the Color3 object
  56741. */
  56742. toString(): string;
  56743. /**
  56744. * Returns the string "Color3"
  56745. * @returns "Color3"
  56746. */
  56747. getClassName(): string;
  56748. /**
  56749. * Compute the Color3 hash code
  56750. * @returns an unique number that can be used to hash Color3 objects
  56751. */
  56752. getHashCode(): number;
  56753. /**
  56754. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  56755. * @param array defines the array where to store the r,g,b components
  56756. * @param index defines an optional index in the target array to define where to start storing values
  56757. * @returns the current Color3 object
  56758. */
  56759. toArray(array: FloatArray, index?: number): Color3;
  56760. /**
  56761. * Returns a new Color4 object from the current Color3 and the given alpha
  56762. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  56763. * @returns a new Color4 object
  56764. */
  56765. toColor4(alpha?: number): Color4;
  56766. /**
  56767. * Returns a new array populated with 3 numeric elements : red, green and blue values
  56768. * @returns the new array
  56769. */
  56770. asArray(): number[];
  56771. /**
  56772. * Returns the luminance value
  56773. * @returns a float value
  56774. */
  56775. toLuminance(): number;
  56776. /**
  56777. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  56778. * @param otherColor defines the second operand
  56779. * @returns the new Color3 object
  56780. */
  56781. multiply(otherColor: DeepImmutable<Color3>): Color3;
  56782. /**
  56783. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  56784. * @param otherColor defines the second operand
  56785. * @param result defines the Color3 object where to store the result
  56786. * @returns the current Color3
  56787. */
  56788. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  56789. /**
  56790. * Determines equality between Color3 objects
  56791. * @param otherColor defines the second operand
  56792. * @returns true if the rgb values are equal to the given ones
  56793. */
  56794. equals(otherColor: DeepImmutable<Color3>): boolean;
  56795. /**
  56796. * Determines equality between the current Color3 object and a set of r,b,g values
  56797. * @param r defines the red component to check
  56798. * @param g defines the green component to check
  56799. * @param b defines the blue component to check
  56800. * @returns true if the rgb values are equal to the given ones
  56801. */
  56802. equalsFloats(r: number, g: number, b: number): boolean;
  56803. /**
  56804. * Multiplies in place each rgb value by scale
  56805. * @param scale defines the scaling factor
  56806. * @returns the updated Color3
  56807. */
  56808. scale(scale: number): Color3;
  56809. /**
  56810. * Multiplies the rgb values by scale and stores the result into "result"
  56811. * @param scale defines the scaling factor
  56812. * @param result defines the Color3 object where to store the result
  56813. * @returns the unmodified current Color3
  56814. */
  56815. scaleToRef(scale: number, result: Color3): Color3;
  56816. /**
  56817. * Scale the current Color3 values by a factor and add the result to a given Color3
  56818. * @param scale defines the scale factor
  56819. * @param result defines color to store the result into
  56820. * @returns the unmodified current Color3
  56821. */
  56822. scaleAndAddToRef(scale: number, result: Color3): Color3;
  56823. /**
  56824. * Clamps the rgb values by the min and max values and stores the result into "result"
  56825. * @param min defines minimum clamping value (default is 0)
  56826. * @param max defines maximum clamping value (default is 1)
  56827. * @param result defines color to store the result into
  56828. * @returns the original Color3
  56829. */
  56830. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  56831. /**
  56832. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  56833. * @param otherColor defines the second operand
  56834. * @returns the new Color3
  56835. */
  56836. add(otherColor: DeepImmutable<Color3>): Color3;
  56837. /**
  56838. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  56839. * @param otherColor defines the second operand
  56840. * @param result defines Color3 object to store the result into
  56841. * @returns the unmodified current Color3
  56842. */
  56843. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  56844. /**
  56845. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  56846. * @param otherColor defines the second operand
  56847. * @returns the new Color3
  56848. */
  56849. subtract(otherColor: DeepImmutable<Color3>): Color3;
  56850. /**
  56851. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  56852. * @param otherColor defines the second operand
  56853. * @param result defines Color3 object to store the result into
  56854. * @returns the unmodified current Color3
  56855. */
  56856. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  56857. /**
  56858. * Copy the current object
  56859. * @returns a new Color3 copied the current one
  56860. */
  56861. clone(): Color3;
  56862. /**
  56863. * Copies the rgb values from the source in the current Color3
  56864. * @param source defines the source Color3 object
  56865. * @returns the updated Color3 object
  56866. */
  56867. copyFrom(source: DeepImmutable<Color3>): Color3;
  56868. /**
  56869. * Updates the Color3 rgb values from the given floats
  56870. * @param r defines the red component to read from
  56871. * @param g defines the green component to read from
  56872. * @param b defines the blue component to read from
  56873. * @returns the current Color3 object
  56874. */
  56875. copyFromFloats(r: number, g: number, b: number): Color3;
  56876. /**
  56877. * Updates the Color3 rgb values from the given floats
  56878. * @param r defines the red component to read from
  56879. * @param g defines the green component to read from
  56880. * @param b defines the blue component to read from
  56881. * @returns the current Color3 object
  56882. */
  56883. set(r: number, g: number, b: number): Color3;
  56884. /**
  56885. * Compute the Color3 hexadecimal code as a string
  56886. * @returns a string containing the hexadecimal representation of the Color3 object
  56887. */
  56888. toHexString(): string;
  56889. /**
  56890. * Computes a new Color3 converted from the current one to linear space
  56891. * @returns a new Color3 object
  56892. */
  56893. toLinearSpace(): Color3;
  56894. /**
  56895. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  56896. * @param convertedColor defines the Color3 object where to store the linear space version
  56897. * @returns the unmodified Color3
  56898. */
  56899. toLinearSpaceToRef(convertedColor: Color3): Color3;
  56900. /**
  56901. * Computes a new Color3 converted from the current one to gamma space
  56902. * @returns a new Color3 object
  56903. */
  56904. toGammaSpace(): Color3;
  56905. /**
  56906. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  56907. * @param convertedColor defines the Color3 object where to store the gamma space version
  56908. * @returns the unmodified Color3
  56909. */
  56910. toGammaSpaceToRef(convertedColor: Color3): Color3;
  56911. private static _BlackReadOnly;
  56912. /**
  56913. * Creates a new Color3 from the string containing valid hexadecimal values
  56914. * @param hex defines a string containing valid hexadecimal values
  56915. * @returns a new Color3 object
  56916. */
  56917. static FromHexString(hex: string): Color3;
  56918. /**
  56919. * Creates a new Vector3 from the starting index of the given array
  56920. * @param array defines the source array
  56921. * @param offset defines an offset in the source array
  56922. * @returns a new Color3 object
  56923. */
  56924. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  56925. /**
  56926. * Creates a new Color3 from integer values (< 256)
  56927. * @param r defines the red component to read from (value between 0 and 255)
  56928. * @param g defines the green component to read from (value between 0 and 255)
  56929. * @param b defines the blue component to read from (value between 0 and 255)
  56930. * @returns a new Color3 object
  56931. */
  56932. static FromInts(r: number, g: number, b: number): Color3;
  56933. /**
  56934. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  56935. * @param start defines the start Color3 value
  56936. * @param end defines the end Color3 value
  56937. * @param amount defines the gradient value between start and end
  56938. * @returns a new Color3 object
  56939. */
  56940. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  56941. /**
  56942. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  56943. * @param left defines the start value
  56944. * @param right defines the end value
  56945. * @param amount defines the gradient factor
  56946. * @param result defines the Color3 object where to store the result
  56947. */
  56948. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  56949. /**
  56950. * Returns a Color3 value containing a red color
  56951. * @returns a new Color3 object
  56952. */
  56953. static Red(): Color3;
  56954. /**
  56955. * Returns a Color3 value containing a green color
  56956. * @returns a new Color3 object
  56957. */
  56958. static Green(): Color3;
  56959. /**
  56960. * Returns a Color3 value containing a blue color
  56961. * @returns a new Color3 object
  56962. */
  56963. static Blue(): Color3;
  56964. /**
  56965. * Returns a Color3 value containing a black color
  56966. * @returns a new Color3 object
  56967. */
  56968. static Black(): Color3;
  56969. /**
  56970. * Gets a Color3 value containing a black color that must not be updated
  56971. */
  56972. static readonly BlackReadOnly: DeepImmutable<Color3>;
  56973. /**
  56974. * Returns a Color3 value containing a white color
  56975. * @returns a new Color3 object
  56976. */
  56977. static White(): Color3;
  56978. /**
  56979. * Returns a Color3 value containing a purple color
  56980. * @returns a new Color3 object
  56981. */
  56982. static Purple(): Color3;
  56983. /**
  56984. * Returns a Color3 value containing a magenta color
  56985. * @returns a new Color3 object
  56986. */
  56987. static Magenta(): Color3;
  56988. /**
  56989. * Returns a Color3 value containing a yellow color
  56990. * @returns a new Color3 object
  56991. */
  56992. static Yellow(): Color3;
  56993. /**
  56994. * Returns a Color3 value containing a gray color
  56995. * @returns a new Color3 object
  56996. */
  56997. static Gray(): Color3;
  56998. /**
  56999. * Returns a Color3 value containing a teal color
  57000. * @returns a new Color3 object
  57001. */
  57002. static Teal(): Color3;
  57003. /**
  57004. * Returns a Color3 value containing a random color
  57005. * @returns a new Color3 object
  57006. */
  57007. static Random(): Color3;
  57008. }
  57009. /**
  57010. * Class used to hold a RBGA color
  57011. */
  57012. export class Color4 {
  57013. /**
  57014. * Defines the red component (between 0 and 1, default is 0)
  57015. */
  57016. r: number;
  57017. /**
  57018. * Defines the green component (between 0 and 1, default is 0)
  57019. */
  57020. g: number;
  57021. /**
  57022. * Defines the blue component (between 0 and 1, default is 0)
  57023. */
  57024. b: number;
  57025. /**
  57026. * Defines the alpha component (between 0 and 1, default is 1)
  57027. */
  57028. a: number;
  57029. /**
  57030. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  57031. * @param r defines the red component (between 0 and 1, default is 0)
  57032. * @param g defines the green component (between 0 and 1, default is 0)
  57033. * @param b defines the blue component (between 0 and 1, default is 0)
  57034. * @param a defines the alpha component (between 0 and 1, default is 1)
  57035. */
  57036. constructor(
  57037. /**
  57038. * Defines the red component (between 0 and 1, default is 0)
  57039. */
  57040. r?: number,
  57041. /**
  57042. * Defines the green component (between 0 and 1, default is 0)
  57043. */
  57044. g?: number,
  57045. /**
  57046. * Defines the blue component (between 0 and 1, default is 0)
  57047. */
  57048. b?: number,
  57049. /**
  57050. * Defines the alpha component (between 0 and 1, default is 1)
  57051. */
  57052. a?: number);
  57053. /**
  57054. * Adds in place the given Color4 values to the current Color4 object
  57055. * @param right defines the second operand
  57056. * @returns the current updated Color4 object
  57057. */
  57058. addInPlace(right: DeepImmutable<Color4>): Color4;
  57059. /**
  57060. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  57061. * @returns the new array
  57062. */
  57063. asArray(): number[];
  57064. /**
  57065. * Stores from the starting index in the given array the Color4 successive values
  57066. * @param array defines the array where to store the r,g,b components
  57067. * @param index defines an optional index in the target array to define where to start storing values
  57068. * @returns the current Color4 object
  57069. */
  57070. toArray(array: number[], index?: number): Color4;
  57071. /**
  57072. * Determines equality between Color4 objects
  57073. * @param otherColor defines the second operand
  57074. * @returns true if the rgba values are equal to the given ones
  57075. */
  57076. equals(otherColor: DeepImmutable<Color4>): boolean;
  57077. /**
  57078. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  57079. * @param right defines the second operand
  57080. * @returns a new Color4 object
  57081. */
  57082. add(right: DeepImmutable<Color4>): Color4;
  57083. /**
  57084. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  57085. * @param right defines the second operand
  57086. * @returns a new Color4 object
  57087. */
  57088. subtract(right: DeepImmutable<Color4>): Color4;
  57089. /**
  57090. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  57091. * @param right defines the second operand
  57092. * @param result defines the Color4 object where to store the result
  57093. * @returns the current Color4 object
  57094. */
  57095. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  57096. /**
  57097. * Creates a new Color4 with the current Color4 values multiplied by scale
  57098. * @param scale defines the scaling factor to apply
  57099. * @returns a new Color4 object
  57100. */
  57101. scale(scale: number): Color4;
  57102. /**
  57103. * Multiplies the current Color4 values by scale and stores the result in "result"
  57104. * @param scale defines the scaling factor to apply
  57105. * @param result defines the Color4 object where to store the result
  57106. * @returns the current unmodified Color4
  57107. */
  57108. scaleToRef(scale: number, result: Color4): Color4;
  57109. /**
  57110. * Scale the current Color4 values by a factor and add the result to a given Color4
  57111. * @param scale defines the scale factor
  57112. * @param result defines the Color4 object where to store the result
  57113. * @returns the unmodified current Color4
  57114. */
  57115. scaleAndAddToRef(scale: number, result: Color4): Color4;
  57116. /**
  57117. * Clamps the rgb values by the min and max values and stores the result into "result"
  57118. * @param min defines minimum clamping value (default is 0)
  57119. * @param max defines maximum clamping value (default is 1)
  57120. * @param result defines color to store the result into.
  57121. * @returns the cuurent Color4
  57122. */
  57123. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  57124. /**
  57125. * Multipy an Color4 value by another and return a new Color4 object
  57126. * @param color defines the Color4 value to multiply by
  57127. * @returns a new Color4 object
  57128. */
  57129. multiply(color: Color4): Color4;
  57130. /**
  57131. * Multipy a Color4 value by another and push the result in a reference value
  57132. * @param color defines the Color4 value to multiply by
  57133. * @param result defines the Color4 to fill the result in
  57134. * @returns the result Color4
  57135. */
  57136. multiplyToRef(color: Color4, result: Color4): Color4;
  57137. /**
  57138. * Creates a string with the Color4 current values
  57139. * @returns the string representation of the Color4 object
  57140. */
  57141. toString(): string;
  57142. /**
  57143. * Returns the string "Color4"
  57144. * @returns "Color4"
  57145. */
  57146. getClassName(): string;
  57147. /**
  57148. * Compute the Color4 hash code
  57149. * @returns an unique number that can be used to hash Color4 objects
  57150. */
  57151. getHashCode(): number;
  57152. /**
  57153. * Creates a new Color4 copied from the current one
  57154. * @returns a new Color4 object
  57155. */
  57156. clone(): Color4;
  57157. /**
  57158. * Copies the given Color4 values into the current one
  57159. * @param source defines the source Color4 object
  57160. * @returns the current updated Color4 object
  57161. */
  57162. copyFrom(source: Color4): Color4;
  57163. /**
  57164. * Copies the given float values into the current one
  57165. * @param r defines the red component to read from
  57166. * @param g defines the green component to read from
  57167. * @param b defines the blue component to read from
  57168. * @param a defines the alpha component to read from
  57169. * @returns the current updated Color4 object
  57170. */
  57171. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  57172. /**
  57173. * Copies the given float values into the current one
  57174. * @param r defines the red component to read from
  57175. * @param g defines the green component to read from
  57176. * @param b defines the blue component to read from
  57177. * @param a defines the alpha component to read from
  57178. * @returns the current updated Color4 object
  57179. */
  57180. set(r: number, g: number, b: number, a: number): Color4;
  57181. /**
  57182. * Compute the Color4 hexadecimal code as a string
  57183. * @returns a string containing the hexadecimal representation of the Color4 object
  57184. */
  57185. toHexString(): string;
  57186. /**
  57187. * Computes a new Color4 converted from the current one to linear space
  57188. * @returns a new Color4 object
  57189. */
  57190. toLinearSpace(): Color4;
  57191. /**
  57192. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  57193. * @param convertedColor defines the Color4 object where to store the linear space version
  57194. * @returns the unmodified Color4
  57195. */
  57196. toLinearSpaceToRef(convertedColor: Color4): Color4;
  57197. /**
  57198. * Computes a new Color4 converted from the current one to gamma space
  57199. * @returns a new Color4 object
  57200. */
  57201. toGammaSpace(): Color4;
  57202. /**
  57203. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  57204. * @param convertedColor defines the Color4 object where to store the gamma space version
  57205. * @returns the unmodified Color4
  57206. */
  57207. toGammaSpaceToRef(convertedColor: Color4): Color4;
  57208. /**
  57209. * Creates a new Color4 from the string containing valid hexadecimal values
  57210. * @param hex defines a string containing valid hexadecimal values
  57211. * @returns a new Color4 object
  57212. */
  57213. static FromHexString(hex: string): Color4;
  57214. /**
  57215. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  57216. * @param left defines the start value
  57217. * @param right defines the end value
  57218. * @param amount defines the gradient factor
  57219. * @returns a new Color4 object
  57220. */
  57221. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  57222. /**
  57223. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  57224. * @param left defines the start value
  57225. * @param right defines the end value
  57226. * @param amount defines the gradient factor
  57227. * @param result defines the Color4 object where to store data
  57228. */
  57229. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  57230. /**
  57231. * Creates a new Color4 from a Color3 and an alpha value
  57232. * @param color3 defines the source Color3 to read from
  57233. * @param alpha defines the alpha component (1.0 by default)
  57234. * @returns a new Color4 object
  57235. */
  57236. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  57237. /**
  57238. * Creates a new Color4 from the starting index element of the given array
  57239. * @param array defines the source array to read from
  57240. * @param offset defines the offset in the source array
  57241. * @returns a new Color4 object
  57242. */
  57243. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  57244. /**
  57245. * Creates a new Color3 from integer values (< 256)
  57246. * @param r defines the red component to read from (value between 0 and 255)
  57247. * @param g defines the green component to read from (value between 0 and 255)
  57248. * @param b defines the blue component to read from (value between 0 and 255)
  57249. * @param a defines the alpha component to read from (value between 0 and 255)
  57250. * @returns a new Color3 object
  57251. */
  57252. static FromInts(r: number, g: number, b: number, a: number): Color4;
  57253. /**
  57254. * Check the content of a given array and convert it to an array containing RGBA data
  57255. * If the original array was already containing count * 4 values then it is returned directly
  57256. * @param colors defines the array to check
  57257. * @param count defines the number of RGBA data to expect
  57258. * @returns an array containing count * 4 values (RGBA)
  57259. */
  57260. static CheckColors4(colors: number[], count: number): number[];
  57261. }
  57262. /**
  57263. * Class representing a vector containing 2 coordinates
  57264. */
  57265. export class Vector2 {
  57266. /** defines the first coordinate */
  57267. x: number;
  57268. /** defines the second coordinate */
  57269. y: number;
  57270. /**
  57271. * Creates a new Vector2 from the given x and y coordinates
  57272. * @param x defines the first coordinate
  57273. * @param y defines the second coordinate
  57274. */
  57275. constructor(
  57276. /** defines the first coordinate */
  57277. x?: number,
  57278. /** defines the second coordinate */
  57279. y?: number);
  57280. /**
  57281. * Gets a string with the Vector2 coordinates
  57282. * @returns a string with the Vector2 coordinates
  57283. */
  57284. toString(): string;
  57285. /**
  57286. * Gets class name
  57287. * @returns the string "Vector2"
  57288. */
  57289. getClassName(): string;
  57290. /**
  57291. * Gets current vector hash code
  57292. * @returns the Vector2 hash code as a number
  57293. */
  57294. getHashCode(): number;
  57295. /**
  57296. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  57297. * @param array defines the source array
  57298. * @param index defines the offset in source array
  57299. * @returns the current Vector2
  57300. */
  57301. toArray(array: FloatArray, index?: number): Vector2;
  57302. /**
  57303. * Copy the current vector to an array
  57304. * @returns a new array with 2 elements: the Vector2 coordinates.
  57305. */
  57306. asArray(): number[];
  57307. /**
  57308. * Sets the Vector2 coordinates with the given Vector2 coordinates
  57309. * @param source defines the source Vector2
  57310. * @returns the current updated Vector2
  57311. */
  57312. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  57313. /**
  57314. * Sets the Vector2 coordinates with the given floats
  57315. * @param x defines the first coordinate
  57316. * @param y defines the second coordinate
  57317. * @returns the current updated Vector2
  57318. */
  57319. copyFromFloats(x: number, y: number): Vector2;
  57320. /**
  57321. * Sets the Vector2 coordinates with the given floats
  57322. * @param x defines the first coordinate
  57323. * @param y defines the second coordinate
  57324. * @returns the current updated Vector2
  57325. */
  57326. set(x: number, y: number): Vector2;
  57327. /**
  57328. * Add another vector with the current one
  57329. * @param otherVector defines the other vector
  57330. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  57331. */
  57332. add(otherVector: DeepImmutable<Vector2>): Vector2;
  57333. /**
  57334. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  57335. * @param otherVector defines the other vector
  57336. * @param result defines the target vector
  57337. * @returns the unmodified current Vector2
  57338. */
  57339. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57340. /**
  57341. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  57342. * @param otherVector defines the other vector
  57343. * @returns the current updated Vector2
  57344. */
  57345. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57346. /**
  57347. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  57348. * @param otherVector defines the other vector
  57349. * @returns a new Vector2
  57350. */
  57351. addVector3(otherVector: Vector3): Vector2;
  57352. /**
  57353. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  57354. * @param otherVector defines the other vector
  57355. * @returns a new Vector2
  57356. */
  57357. subtract(otherVector: Vector2): Vector2;
  57358. /**
  57359. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  57360. * @param otherVector defines the other vector
  57361. * @param result defines the target vector
  57362. * @returns the unmodified current Vector2
  57363. */
  57364. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57365. /**
  57366. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  57367. * @param otherVector defines the other vector
  57368. * @returns the current updated Vector2
  57369. */
  57370. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57371. /**
  57372. * Multiplies in place the current Vector2 coordinates by the given ones
  57373. * @param otherVector defines the other vector
  57374. * @returns the current updated Vector2
  57375. */
  57376. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57377. /**
  57378. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  57379. * @param otherVector defines the other vector
  57380. * @returns a new Vector2
  57381. */
  57382. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  57383. /**
  57384. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  57385. * @param otherVector defines the other vector
  57386. * @param result defines the target vector
  57387. * @returns the unmodified current Vector2
  57388. */
  57389. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57390. /**
  57391. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  57392. * @param x defines the first coordinate
  57393. * @param y defines the second coordinate
  57394. * @returns a new Vector2
  57395. */
  57396. multiplyByFloats(x: number, y: number): Vector2;
  57397. /**
  57398. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  57399. * @param otherVector defines the other vector
  57400. * @returns a new Vector2
  57401. */
  57402. divide(otherVector: Vector2): Vector2;
  57403. /**
  57404. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  57405. * @param otherVector defines the other vector
  57406. * @param result defines the target vector
  57407. * @returns the unmodified current Vector2
  57408. */
  57409. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57410. /**
  57411. * Divides the current Vector2 coordinates by the given ones
  57412. * @param otherVector defines the other vector
  57413. * @returns the current updated Vector2
  57414. */
  57415. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57416. /**
  57417. * Gets a new Vector2 with current Vector2 negated coordinates
  57418. * @returns a new Vector2
  57419. */
  57420. negate(): Vector2;
  57421. /**
  57422. * Multiply the Vector2 coordinates by scale
  57423. * @param scale defines the scaling factor
  57424. * @returns the current updated Vector2
  57425. */
  57426. scaleInPlace(scale: number): Vector2;
  57427. /**
  57428. * Returns a new Vector2 scaled by "scale" from the current Vector2
  57429. * @param scale defines the scaling factor
  57430. * @returns a new Vector2
  57431. */
  57432. scale(scale: number): Vector2;
  57433. /**
  57434. * Scale the current Vector2 values by a factor to a given Vector2
  57435. * @param scale defines the scale factor
  57436. * @param result defines the Vector2 object where to store the result
  57437. * @returns the unmodified current Vector2
  57438. */
  57439. scaleToRef(scale: number, result: Vector2): Vector2;
  57440. /**
  57441. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  57442. * @param scale defines the scale factor
  57443. * @param result defines the Vector2 object where to store the result
  57444. * @returns the unmodified current Vector2
  57445. */
  57446. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  57447. /**
  57448. * Gets a boolean if two vectors are equals
  57449. * @param otherVector defines the other vector
  57450. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  57451. */
  57452. equals(otherVector: DeepImmutable<Vector2>): boolean;
  57453. /**
  57454. * Gets a boolean if two vectors are equals (using an epsilon value)
  57455. * @param otherVector defines the other vector
  57456. * @param epsilon defines the minimal distance to consider equality
  57457. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  57458. */
  57459. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  57460. /**
  57461. * Gets a new Vector2 from current Vector2 floored values
  57462. * @returns a new Vector2
  57463. */
  57464. floor(): Vector2;
  57465. /**
  57466. * Gets a new Vector2 from current Vector2 floored values
  57467. * @returns a new Vector2
  57468. */
  57469. fract(): Vector2;
  57470. /**
  57471. * Gets the length of the vector
  57472. * @returns the vector length (float)
  57473. */
  57474. length(): number;
  57475. /**
  57476. * Gets the vector squared length
  57477. * @returns the vector squared length (float)
  57478. */
  57479. lengthSquared(): number;
  57480. /**
  57481. * Normalize the vector
  57482. * @returns the current updated Vector2
  57483. */
  57484. normalize(): Vector2;
  57485. /**
  57486. * Gets a new Vector2 copied from the Vector2
  57487. * @returns a new Vector2
  57488. */
  57489. clone(): Vector2;
  57490. /**
  57491. * Gets a new Vector2(0, 0)
  57492. * @returns a new Vector2
  57493. */
  57494. static Zero(): Vector2;
  57495. /**
  57496. * Gets a new Vector2(1, 1)
  57497. * @returns a new Vector2
  57498. */
  57499. static One(): Vector2;
  57500. /**
  57501. * Gets a new Vector2 set from the given index element of the given array
  57502. * @param array defines the data source
  57503. * @param offset defines the offset in the data source
  57504. * @returns a new Vector2
  57505. */
  57506. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  57507. /**
  57508. * Sets "result" from the given index element of the given array
  57509. * @param array defines the data source
  57510. * @param offset defines the offset in the data source
  57511. * @param result defines the target vector
  57512. */
  57513. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  57514. /**
  57515. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  57516. * @param value1 defines 1st point of control
  57517. * @param value2 defines 2nd point of control
  57518. * @param value3 defines 3rd point of control
  57519. * @param value4 defines 4th point of control
  57520. * @param amount defines the interpolation factor
  57521. * @returns a new Vector2
  57522. */
  57523. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  57524. /**
  57525. * 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".
  57526. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  57527. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  57528. * @param value defines the value to clamp
  57529. * @param min defines the lower limit
  57530. * @param max defines the upper limit
  57531. * @returns a new Vector2
  57532. */
  57533. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  57534. /**
  57535. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  57536. * @param value1 defines the 1st control point
  57537. * @param tangent1 defines the outgoing tangent
  57538. * @param value2 defines the 2nd control point
  57539. * @param tangent2 defines the incoming tangent
  57540. * @param amount defines the interpolation factor
  57541. * @returns a new Vector2
  57542. */
  57543. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  57544. /**
  57545. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  57546. * @param start defines the start vector
  57547. * @param end defines the end vector
  57548. * @param amount defines the interpolation factor
  57549. * @returns a new Vector2
  57550. */
  57551. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  57552. /**
  57553. * Gets the dot product of the vector "left" and the vector "right"
  57554. * @param left defines first vector
  57555. * @param right defines second vector
  57556. * @returns the dot product (float)
  57557. */
  57558. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  57559. /**
  57560. * Returns a new Vector2 equal to the normalized given vector
  57561. * @param vector defines the vector to normalize
  57562. * @returns a new Vector2
  57563. */
  57564. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  57565. /**
  57566. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  57567. * @param left defines 1st vector
  57568. * @param right defines 2nd vector
  57569. * @returns a new Vector2
  57570. */
  57571. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  57572. /**
  57573. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  57574. * @param left defines 1st vector
  57575. * @param right defines 2nd vector
  57576. * @returns a new Vector2
  57577. */
  57578. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  57579. /**
  57580. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  57581. * @param vector defines the vector to transform
  57582. * @param transformation defines the matrix to apply
  57583. * @returns a new Vector2
  57584. */
  57585. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  57586. /**
  57587. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  57588. * @param vector defines the vector to transform
  57589. * @param transformation defines the matrix to apply
  57590. * @param result defines the target vector
  57591. */
  57592. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  57593. /**
  57594. * Determines if a given vector is included in a triangle
  57595. * @param p defines the vector to test
  57596. * @param p0 defines 1st triangle point
  57597. * @param p1 defines 2nd triangle point
  57598. * @param p2 defines 3rd triangle point
  57599. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  57600. */
  57601. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  57602. /**
  57603. * Gets the distance between the vectors "value1" and "value2"
  57604. * @param value1 defines first vector
  57605. * @param value2 defines second vector
  57606. * @returns the distance between vectors
  57607. */
  57608. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  57609. /**
  57610. * Returns the squared distance between the vectors "value1" and "value2"
  57611. * @param value1 defines first vector
  57612. * @param value2 defines second vector
  57613. * @returns the squared distance between vectors
  57614. */
  57615. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  57616. /**
  57617. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  57618. * @param value1 defines first vector
  57619. * @param value2 defines second vector
  57620. * @returns a new Vector2
  57621. */
  57622. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  57623. /**
  57624. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  57625. * @param p defines the middle point
  57626. * @param segA defines one point of the segment
  57627. * @param segB defines the other point of the segment
  57628. * @returns the shortest distance
  57629. */
  57630. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  57631. }
  57632. /**
  57633. * Classed used to store (x,y,z) vector representation
  57634. * A Vector3 is the main object used in 3D geometry
  57635. * It can represent etiher the coordinates of a point the space, either a direction
  57636. * Reminder: js uses a left handed forward facing system
  57637. */
  57638. export class Vector3 {
  57639. /**
  57640. * Defines the first coordinates (on X axis)
  57641. */
  57642. x: number;
  57643. /**
  57644. * Defines the second coordinates (on Y axis)
  57645. */
  57646. y: number;
  57647. /**
  57648. * Defines the third coordinates (on Z axis)
  57649. */
  57650. z: number;
  57651. private static _UpReadOnly;
  57652. /**
  57653. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  57654. * @param x defines the first coordinates (on X axis)
  57655. * @param y defines the second coordinates (on Y axis)
  57656. * @param z defines the third coordinates (on Z axis)
  57657. */
  57658. constructor(
  57659. /**
  57660. * Defines the first coordinates (on X axis)
  57661. */
  57662. x?: number,
  57663. /**
  57664. * Defines the second coordinates (on Y axis)
  57665. */
  57666. y?: number,
  57667. /**
  57668. * Defines the third coordinates (on Z axis)
  57669. */
  57670. z?: number);
  57671. /**
  57672. * Creates a string representation of the Vector3
  57673. * @returns a string with the Vector3 coordinates.
  57674. */
  57675. toString(): string;
  57676. /**
  57677. * Gets the class name
  57678. * @returns the string "Vector3"
  57679. */
  57680. getClassName(): string;
  57681. /**
  57682. * Creates the Vector3 hash code
  57683. * @returns a number which tends to be unique between Vector3 instances
  57684. */
  57685. getHashCode(): number;
  57686. /**
  57687. * Creates an array containing three elements : the coordinates of the Vector3
  57688. * @returns a new array of numbers
  57689. */
  57690. asArray(): number[];
  57691. /**
  57692. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  57693. * @param array defines the destination array
  57694. * @param index defines the offset in the destination array
  57695. * @returns the current Vector3
  57696. */
  57697. toArray(array: FloatArray, index?: number): Vector3;
  57698. /**
  57699. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  57700. * @returns a new Quaternion object, computed from the Vector3 coordinates
  57701. */
  57702. toQuaternion(): Quaternion;
  57703. /**
  57704. * Adds the given vector to the current Vector3
  57705. * @param otherVector defines the second operand
  57706. * @returns the current updated Vector3
  57707. */
  57708. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  57709. /**
  57710. * Adds the given coordinates to the current Vector3
  57711. * @param x defines the x coordinate of the operand
  57712. * @param y defines the y coordinate of the operand
  57713. * @param z defines the z coordinate of the operand
  57714. * @returns the current updated Vector3
  57715. */
  57716. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  57717. /**
  57718. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  57719. * @param otherVector defines the second operand
  57720. * @returns the resulting Vector3
  57721. */
  57722. add(otherVector: DeepImmutable<Vector3>): Vector3;
  57723. /**
  57724. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  57725. * @param otherVector defines the second operand
  57726. * @param result defines the Vector3 object where to store the result
  57727. * @returns the current Vector3
  57728. */
  57729. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57730. /**
  57731. * Subtract the given vector from the current Vector3
  57732. * @param otherVector defines the second operand
  57733. * @returns the current updated Vector3
  57734. */
  57735. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  57736. /**
  57737. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  57738. * @param otherVector defines the second operand
  57739. * @returns the resulting Vector3
  57740. */
  57741. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  57742. /**
  57743. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  57744. * @param otherVector defines the second operand
  57745. * @param result defines the Vector3 object where to store the result
  57746. * @returns the current Vector3
  57747. */
  57748. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57749. /**
  57750. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  57751. * @param x defines the x coordinate of the operand
  57752. * @param y defines the y coordinate of the operand
  57753. * @param z defines the z coordinate of the operand
  57754. * @returns the resulting Vector3
  57755. */
  57756. subtractFromFloats(x: number, y: number, z: number): Vector3;
  57757. /**
  57758. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  57759. * @param x defines the x coordinate of the operand
  57760. * @param y defines the y coordinate of the operand
  57761. * @param z defines the z coordinate of the operand
  57762. * @param result defines the Vector3 object where to store the result
  57763. * @returns the current Vector3
  57764. */
  57765. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  57766. /**
  57767. * Gets a new Vector3 set with the current Vector3 negated coordinates
  57768. * @returns a new Vector3
  57769. */
  57770. negate(): Vector3;
  57771. /**
  57772. * Multiplies the Vector3 coordinates by the float "scale"
  57773. * @param scale defines the multiplier factor
  57774. * @returns the current updated Vector3
  57775. */
  57776. scaleInPlace(scale: number): Vector3;
  57777. /**
  57778. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  57779. * @param scale defines the multiplier factor
  57780. * @returns a new Vector3
  57781. */
  57782. scale(scale: number): Vector3;
  57783. /**
  57784. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  57785. * @param scale defines the multiplier factor
  57786. * @param result defines the Vector3 object where to store the result
  57787. * @returns the current Vector3
  57788. */
  57789. scaleToRef(scale: number, result: Vector3): Vector3;
  57790. /**
  57791. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  57792. * @param scale defines the scale factor
  57793. * @param result defines the Vector3 object where to store the result
  57794. * @returns the unmodified current Vector3
  57795. */
  57796. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  57797. /**
  57798. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  57799. * @param otherVector defines the second operand
  57800. * @returns true if both vectors are equals
  57801. */
  57802. equals(otherVector: DeepImmutable<Vector3>): boolean;
  57803. /**
  57804. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  57805. * @param otherVector defines the second operand
  57806. * @param epsilon defines the minimal distance to define values as equals
  57807. * @returns true if both vectors are distant less than epsilon
  57808. */
  57809. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  57810. /**
  57811. * Returns true if the current Vector3 coordinates equals the given floats
  57812. * @param x defines the x coordinate of the operand
  57813. * @param y defines the y coordinate of the operand
  57814. * @param z defines the z coordinate of the operand
  57815. * @returns true if both vectors are equals
  57816. */
  57817. equalsToFloats(x: number, y: number, z: number): boolean;
  57818. /**
  57819. * Multiplies the current Vector3 coordinates by the given ones
  57820. * @param otherVector defines the second operand
  57821. * @returns the current updated Vector3
  57822. */
  57823. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  57824. /**
  57825. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  57826. * @param otherVector defines the second operand
  57827. * @returns the new Vector3
  57828. */
  57829. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  57830. /**
  57831. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  57832. * @param otherVector defines the second operand
  57833. * @param result defines the Vector3 object where to store the result
  57834. * @returns the current Vector3
  57835. */
  57836. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57837. /**
  57838. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  57839. * @param x defines the x coordinate of the operand
  57840. * @param y defines the y coordinate of the operand
  57841. * @param z defines the z coordinate of the operand
  57842. * @returns the new Vector3
  57843. */
  57844. multiplyByFloats(x: number, y: number, z: number): Vector3;
  57845. /**
  57846. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  57847. * @param otherVector defines the second operand
  57848. * @returns the new Vector3
  57849. */
  57850. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  57851. /**
  57852. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  57853. * @param otherVector defines the second operand
  57854. * @param result defines the Vector3 object where to store the result
  57855. * @returns the current Vector3
  57856. */
  57857. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57858. /**
  57859. * Divides the current Vector3 coordinates by the given ones.
  57860. * @param otherVector defines the second operand
  57861. * @returns the current updated Vector3
  57862. */
  57863. divideInPlace(otherVector: Vector3): Vector3;
  57864. /**
  57865. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  57866. * @param other defines the second operand
  57867. * @returns the current updated Vector3
  57868. */
  57869. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  57870. /**
  57871. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  57872. * @param other defines the second operand
  57873. * @returns the current updated Vector3
  57874. */
  57875. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  57876. /**
  57877. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  57878. * @param x defines the x coordinate of the operand
  57879. * @param y defines the y coordinate of the operand
  57880. * @param z defines the z coordinate of the operand
  57881. * @returns the current updated Vector3
  57882. */
  57883. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  57884. /**
  57885. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  57886. * @param x defines the x coordinate of the operand
  57887. * @param y defines the y coordinate of the operand
  57888. * @param z defines the z coordinate of the operand
  57889. * @returns the current updated Vector3
  57890. */
  57891. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  57892. /**
  57893. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  57894. * Check if is non uniform within a certain amount of decimal places to account for this
  57895. * @param epsilon the amount the values can differ
  57896. * @returns if the the vector is non uniform to a certain number of decimal places
  57897. */
  57898. isNonUniformWithinEpsilon(epsilon: number): boolean;
  57899. /**
  57900. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  57901. */
  57902. readonly isNonUniform: boolean;
  57903. /**
  57904. * Gets a new Vector3 from current Vector3 floored values
  57905. * @returns a new Vector3
  57906. */
  57907. floor(): Vector3;
  57908. /**
  57909. * Gets a new Vector3 from current Vector3 floored values
  57910. * @returns a new Vector3
  57911. */
  57912. fract(): Vector3;
  57913. /**
  57914. * Gets the length of the Vector3
  57915. * @returns the length of the Vecto3
  57916. */
  57917. length(): number;
  57918. /**
  57919. * Gets the squared length of the Vector3
  57920. * @returns squared length of the Vector3
  57921. */
  57922. lengthSquared(): number;
  57923. /**
  57924. * Normalize the current Vector3.
  57925. * Please note that this is an in place operation.
  57926. * @returns the current updated Vector3
  57927. */
  57928. normalize(): Vector3;
  57929. /**
  57930. * Reorders the x y z properties of the vector in place
  57931. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  57932. * @returns the current updated vector
  57933. */
  57934. reorderInPlace(order: string): this;
  57935. /**
  57936. * Rotates the vector around 0,0,0 by a quaternion
  57937. * @param quaternion the rotation quaternion
  57938. * @param result vector to store the result
  57939. * @returns the resulting vector
  57940. */
  57941. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  57942. /**
  57943. * Rotates a vector around a given point
  57944. * @param quaternion the rotation quaternion
  57945. * @param point the point to rotate around
  57946. * @param result vector to store the result
  57947. * @returns the resulting vector
  57948. */
  57949. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  57950. /**
  57951. * Normalize the current Vector3 with the given input length.
  57952. * Please note that this is an in place operation.
  57953. * @param len the length of the vector
  57954. * @returns the current updated Vector3
  57955. */
  57956. normalizeFromLength(len: number): Vector3;
  57957. /**
  57958. * Normalize the current Vector3 to a new vector
  57959. * @returns the new Vector3
  57960. */
  57961. normalizeToNew(): Vector3;
  57962. /**
  57963. * Normalize the current Vector3 to the reference
  57964. * @param reference define the Vector3 to update
  57965. * @returns the updated Vector3
  57966. */
  57967. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  57968. /**
  57969. * Creates a new Vector3 copied from the current Vector3
  57970. * @returns the new Vector3
  57971. */
  57972. clone(): Vector3;
  57973. /**
  57974. * Copies the given vector coordinates to the current Vector3 ones
  57975. * @param source defines the source Vector3
  57976. * @returns the current updated Vector3
  57977. */
  57978. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  57979. /**
  57980. * Copies the given floats to the current Vector3 coordinates
  57981. * @param x defines the x coordinate of the operand
  57982. * @param y defines the y coordinate of the operand
  57983. * @param z defines the z coordinate of the operand
  57984. * @returns the current updated Vector3
  57985. */
  57986. copyFromFloats(x: number, y: number, z: number): Vector3;
  57987. /**
  57988. * Copies the given floats to the current Vector3 coordinates
  57989. * @param x defines the x coordinate of the operand
  57990. * @param y defines the y coordinate of the operand
  57991. * @param z defines the z coordinate of the operand
  57992. * @returns the current updated Vector3
  57993. */
  57994. set(x: number, y: number, z: number): Vector3;
  57995. /**
  57996. * Copies the given float to the current Vector3 coordinates
  57997. * @param v defines the x, y and z coordinates of the operand
  57998. * @returns the current updated Vector3
  57999. */
  58000. setAll(v: number): Vector3;
  58001. /**
  58002. * Get the clip factor between two vectors
  58003. * @param vector0 defines the first operand
  58004. * @param vector1 defines the second operand
  58005. * @param axis defines the axis to use
  58006. * @param size defines the size along the axis
  58007. * @returns the clip factor
  58008. */
  58009. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  58010. /**
  58011. * Get angle between two vectors
  58012. * @param vector0 angle between vector0 and vector1
  58013. * @param vector1 angle between vector0 and vector1
  58014. * @param normal direction of the normal
  58015. * @return the angle between vector0 and vector1
  58016. */
  58017. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  58018. /**
  58019. * Returns a new Vector3 set from the index "offset" of the given array
  58020. * @param array defines the source array
  58021. * @param offset defines the offset in the source array
  58022. * @returns the new Vector3
  58023. */
  58024. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  58025. /**
  58026. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  58027. * This function is deprecated. Use FromArray instead
  58028. * @param array defines the source array
  58029. * @param offset defines the offset in the source array
  58030. * @returns the new Vector3
  58031. */
  58032. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  58033. /**
  58034. * Sets the given vector "result" with the element values from the index "offset" of the given array
  58035. * @param array defines the source array
  58036. * @param offset defines the offset in the source array
  58037. * @param result defines the Vector3 where to store the result
  58038. */
  58039. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  58040. /**
  58041. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  58042. * This function is deprecated. Use FromArrayToRef instead.
  58043. * @param array defines the source array
  58044. * @param offset defines the offset in the source array
  58045. * @param result defines the Vector3 where to store the result
  58046. */
  58047. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  58048. /**
  58049. * Sets the given vector "result" with the given floats.
  58050. * @param x defines the x coordinate of the source
  58051. * @param y defines the y coordinate of the source
  58052. * @param z defines the z coordinate of the source
  58053. * @param result defines the Vector3 where to store the result
  58054. */
  58055. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  58056. /**
  58057. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  58058. * @returns a new empty Vector3
  58059. */
  58060. static Zero(): Vector3;
  58061. /**
  58062. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  58063. * @returns a new unit Vector3
  58064. */
  58065. static One(): Vector3;
  58066. /**
  58067. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  58068. * @returns a new up Vector3
  58069. */
  58070. static Up(): Vector3;
  58071. /**
  58072. * Gets a up Vector3 that must not be updated
  58073. */
  58074. static readonly UpReadOnly: DeepImmutable<Vector3>;
  58075. /**
  58076. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  58077. * @returns a new down Vector3
  58078. */
  58079. static Down(): Vector3;
  58080. /**
  58081. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  58082. * @returns a new forward Vector3
  58083. */
  58084. static Forward(): Vector3;
  58085. /**
  58086. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  58087. * @returns a new forward Vector3
  58088. */
  58089. static Backward(): Vector3;
  58090. /**
  58091. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  58092. * @returns a new right Vector3
  58093. */
  58094. static Right(): Vector3;
  58095. /**
  58096. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  58097. * @returns a new left Vector3
  58098. */
  58099. static Left(): Vector3;
  58100. /**
  58101. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  58102. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  58103. * @param vector defines the Vector3 to transform
  58104. * @param transformation defines the transformation matrix
  58105. * @returns the transformed Vector3
  58106. */
  58107. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  58108. /**
  58109. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  58110. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  58111. * @param vector defines the Vector3 to transform
  58112. * @param transformation defines the transformation matrix
  58113. * @param result defines the Vector3 where to store the result
  58114. */
  58115. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58116. /**
  58117. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  58118. * This method computes tranformed coordinates only, not transformed direction vectors
  58119. * @param x define the x coordinate of the source vector
  58120. * @param y define the y coordinate of the source vector
  58121. * @param z define the z coordinate of the source vector
  58122. * @param transformation defines the transformation matrix
  58123. * @param result defines the Vector3 where to store the result
  58124. */
  58125. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58126. /**
  58127. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  58128. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58129. * @param vector defines the Vector3 to transform
  58130. * @param transformation defines the transformation matrix
  58131. * @returns the new Vector3
  58132. */
  58133. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  58134. /**
  58135. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  58136. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58137. * @param vector defines the Vector3 to transform
  58138. * @param transformation defines the transformation matrix
  58139. * @param result defines the Vector3 where to store the result
  58140. */
  58141. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58142. /**
  58143. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  58144. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58145. * @param x define the x coordinate of the source vector
  58146. * @param y define the y coordinate of the source vector
  58147. * @param z define the z coordinate of the source vector
  58148. * @param transformation defines the transformation matrix
  58149. * @param result defines the Vector3 where to store the result
  58150. */
  58151. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58152. /**
  58153. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  58154. * @param value1 defines the first control point
  58155. * @param value2 defines the second control point
  58156. * @param value3 defines the third control point
  58157. * @param value4 defines the fourth control point
  58158. * @param amount defines the amount on the spline to use
  58159. * @returns the new Vector3
  58160. */
  58161. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  58162. /**
  58163. * 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"
  58164. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  58165. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  58166. * @param value defines the current value
  58167. * @param min defines the lower range value
  58168. * @param max defines the upper range value
  58169. * @returns the new Vector3
  58170. */
  58171. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  58172. /**
  58173. * 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"
  58174. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  58175. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  58176. * @param value defines the current value
  58177. * @param min defines the lower range value
  58178. * @param max defines the upper range value
  58179. * @param result defines the Vector3 where to store the result
  58180. */
  58181. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  58182. /**
  58183. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  58184. * @param value1 defines the first control point
  58185. * @param tangent1 defines the first tangent vector
  58186. * @param value2 defines the second control point
  58187. * @param tangent2 defines the second tangent vector
  58188. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  58189. * @returns the new Vector3
  58190. */
  58191. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  58192. /**
  58193. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  58194. * @param start defines the start value
  58195. * @param end defines the end value
  58196. * @param amount max defines amount between both (between 0 and 1)
  58197. * @returns the new Vector3
  58198. */
  58199. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  58200. /**
  58201. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  58202. * @param start defines the start value
  58203. * @param end defines the end value
  58204. * @param amount max defines amount between both (between 0 and 1)
  58205. * @param result defines the Vector3 where to store the result
  58206. */
  58207. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  58208. /**
  58209. * Returns the dot product (float) between the vectors "left" and "right"
  58210. * @param left defines the left operand
  58211. * @param right defines the right operand
  58212. * @returns the dot product
  58213. */
  58214. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  58215. /**
  58216. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  58217. * The cross product is then orthogonal to both "left" and "right"
  58218. * @param left defines the left operand
  58219. * @param right defines the right operand
  58220. * @returns the cross product
  58221. */
  58222. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58223. /**
  58224. * Sets the given vector "result" with the cross product of "left" and "right"
  58225. * The cross product is then orthogonal to both "left" and "right"
  58226. * @param left defines the left operand
  58227. * @param right defines the right operand
  58228. * @param result defines the Vector3 where to store the result
  58229. */
  58230. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  58231. /**
  58232. * Returns a new Vector3 as the normalization of the given vector
  58233. * @param vector defines the Vector3 to normalize
  58234. * @returns the new Vector3
  58235. */
  58236. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  58237. /**
  58238. * Sets the given vector "result" with the normalization of the given first vector
  58239. * @param vector defines the Vector3 to normalize
  58240. * @param result defines the Vector3 where to store the result
  58241. */
  58242. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  58243. /**
  58244. * Project a Vector3 onto screen space
  58245. * @param vector defines the Vector3 to project
  58246. * @param world defines the world matrix to use
  58247. * @param transform defines the transform (view x projection) matrix to use
  58248. * @param viewport defines the screen viewport to use
  58249. * @returns the new Vector3
  58250. */
  58251. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  58252. /** @hidden */
  58253. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  58254. /**
  58255. * Unproject from screen space to object space
  58256. * @param source defines the screen space Vector3 to use
  58257. * @param viewportWidth defines the current width of the viewport
  58258. * @param viewportHeight defines the current height of the viewport
  58259. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58260. * @param transform defines the transform (view x projection) matrix to use
  58261. * @returns the new Vector3
  58262. */
  58263. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  58264. /**
  58265. * Unproject from screen space to object space
  58266. * @param source defines the screen space Vector3 to use
  58267. * @param viewportWidth defines the current width of the viewport
  58268. * @param viewportHeight defines the current height of the viewport
  58269. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58270. * @param view defines the view matrix to use
  58271. * @param projection defines the projection matrix to use
  58272. * @returns the new Vector3
  58273. */
  58274. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  58275. /**
  58276. * Unproject from screen space to object space
  58277. * @param source defines the screen space Vector3 to use
  58278. * @param viewportWidth defines the current width of the viewport
  58279. * @param viewportHeight defines the current height of the viewport
  58280. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58281. * @param view defines the view matrix to use
  58282. * @param projection defines the projection matrix to use
  58283. * @param result defines the Vector3 where to store the result
  58284. */
  58285. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  58286. /**
  58287. * Unproject from screen space to object space
  58288. * @param sourceX defines the screen space x coordinate to use
  58289. * @param sourceY defines the screen space y coordinate to use
  58290. * @param sourceZ defines the screen space z coordinate to use
  58291. * @param viewportWidth defines the current width of the viewport
  58292. * @param viewportHeight defines the current height of the viewport
  58293. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58294. * @param view defines the view matrix to use
  58295. * @param projection defines the projection matrix to use
  58296. * @param result defines the Vector3 where to store the result
  58297. */
  58298. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  58299. /**
  58300. * Gets the minimal coordinate values between two Vector3
  58301. * @param left defines the first operand
  58302. * @param right defines the second operand
  58303. * @returns the new Vector3
  58304. */
  58305. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58306. /**
  58307. * Gets the maximal coordinate values between two Vector3
  58308. * @param left defines the first operand
  58309. * @param right defines the second operand
  58310. * @returns the new Vector3
  58311. */
  58312. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58313. /**
  58314. * Returns the distance between the vectors "value1" and "value2"
  58315. * @param value1 defines the first operand
  58316. * @param value2 defines the second operand
  58317. * @returns the distance
  58318. */
  58319. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  58320. /**
  58321. * Returns the squared distance between the vectors "value1" and "value2"
  58322. * @param value1 defines the first operand
  58323. * @param value2 defines the second operand
  58324. * @returns the squared distance
  58325. */
  58326. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  58327. /**
  58328. * Returns a new Vector3 located at the center between "value1" and "value2"
  58329. * @param value1 defines the first operand
  58330. * @param value2 defines the second operand
  58331. * @returns the new Vector3
  58332. */
  58333. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  58334. /**
  58335. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  58336. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  58337. * to something in order to rotate it from its local system to the given target system
  58338. * Note: axis1, axis2 and axis3 are normalized during this operation
  58339. * @param axis1 defines the first axis
  58340. * @param axis2 defines the second axis
  58341. * @param axis3 defines the third axis
  58342. * @returns a new Vector3
  58343. */
  58344. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  58345. /**
  58346. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  58347. * @param axis1 defines the first axis
  58348. * @param axis2 defines the second axis
  58349. * @param axis3 defines the third axis
  58350. * @param ref defines the Vector3 where to store the result
  58351. */
  58352. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  58353. }
  58354. /**
  58355. * Vector4 class created for EulerAngle class conversion to Quaternion
  58356. */
  58357. export class Vector4 {
  58358. /** x value of the vector */
  58359. x: number;
  58360. /** y value of the vector */
  58361. y: number;
  58362. /** z value of the vector */
  58363. z: number;
  58364. /** w value of the vector */
  58365. w: number;
  58366. /**
  58367. * Creates a Vector4 object from the given floats.
  58368. * @param x x value of the vector
  58369. * @param y y value of the vector
  58370. * @param z z value of the vector
  58371. * @param w w value of the vector
  58372. */
  58373. constructor(
  58374. /** x value of the vector */
  58375. x: number,
  58376. /** y value of the vector */
  58377. y: number,
  58378. /** z value of the vector */
  58379. z: number,
  58380. /** w value of the vector */
  58381. w: number);
  58382. /**
  58383. * Returns the string with the Vector4 coordinates.
  58384. * @returns a string containing all the vector values
  58385. */
  58386. toString(): string;
  58387. /**
  58388. * Returns the string "Vector4".
  58389. * @returns "Vector4"
  58390. */
  58391. getClassName(): string;
  58392. /**
  58393. * Returns the Vector4 hash code.
  58394. * @returns a unique hash code
  58395. */
  58396. getHashCode(): number;
  58397. /**
  58398. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  58399. * @returns the resulting array
  58400. */
  58401. asArray(): number[];
  58402. /**
  58403. * Populates the given array from the given index with the Vector4 coordinates.
  58404. * @param array array to populate
  58405. * @param index index of the array to start at (default: 0)
  58406. * @returns the Vector4.
  58407. */
  58408. toArray(array: FloatArray, index?: number): Vector4;
  58409. /**
  58410. * Adds the given vector to the current Vector4.
  58411. * @param otherVector the vector to add
  58412. * @returns the updated Vector4.
  58413. */
  58414. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58415. /**
  58416. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  58417. * @param otherVector the vector to add
  58418. * @returns the resulting vector
  58419. */
  58420. add(otherVector: DeepImmutable<Vector4>): Vector4;
  58421. /**
  58422. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  58423. * @param otherVector the vector to add
  58424. * @param result the vector to store the result
  58425. * @returns the current Vector4.
  58426. */
  58427. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58428. /**
  58429. * Subtract in place the given vector from the current Vector4.
  58430. * @param otherVector the vector to subtract
  58431. * @returns the updated Vector4.
  58432. */
  58433. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58434. /**
  58435. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  58436. * @param otherVector the vector to add
  58437. * @returns the new vector with the result
  58438. */
  58439. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  58440. /**
  58441. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  58442. * @param otherVector the vector to subtract
  58443. * @param result the vector to store the result
  58444. * @returns the current Vector4.
  58445. */
  58446. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58447. /**
  58448. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58449. */
  58450. /**
  58451. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58452. * @param x value to subtract
  58453. * @param y value to subtract
  58454. * @param z value to subtract
  58455. * @param w value to subtract
  58456. * @returns new vector containing the result
  58457. */
  58458. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  58459. /**
  58460. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58461. * @param x value to subtract
  58462. * @param y value to subtract
  58463. * @param z value to subtract
  58464. * @param w value to subtract
  58465. * @param result the vector to store the result in
  58466. * @returns the current Vector4.
  58467. */
  58468. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  58469. /**
  58470. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  58471. * @returns a new vector with the negated values
  58472. */
  58473. negate(): Vector4;
  58474. /**
  58475. * Multiplies the current Vector4 coordinates by scale (float).
  58476. * @param scale the number to scale with
  58477. * @returns the updated Vector4.
  58478. */
  58479. scaleInPlace(scale: number): Vector4;
  58480. /**
  58481. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  58482. * @param scale the number to scale with
  58483. * @returns a new vector with the result
  58484. */
  58485. scale(scale: number): Vector4;
  58486. /**
  58487. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  58488. * @param scale the number to scale with
  58489. * @param result a vector to store the result in
  58490. * @returns the current Vector4.
  58491. */
  58492. scaleToRef(scale: number, result: Vector4): Vector4;
  58493. /**
  58494. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  58495. * @param scale defines the scale factor
  58496. * @param result defines the Vector4 object where to store the result
  58497. * @returns the unmodified current Vector4
  58498. */
  58499. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  58500. /**
  58501. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  58502. * @param otherVector the vector to compare against
  58503. * @returns true if they are equal
  58504. */
  58505. equals(otherVector: DeepImmutable<Vector4>): boolean;
  58506. /**
  58507. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  58508. * @param otherVector vector to compare against
  58509. * @param epsilon (Default: very small number)
  58510. * @returns true if they are equal
  58511. */
  58512. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  58513. /**
  58514. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  58515. * @param x x value to compare against
  58516. * @param y y value to compare against
  58517. * @param z z value to compare against
  58518. * @param w w value to compare against
  58519. * @returns true if equal
  58520. */
  58521. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  58522. /**
  58523. * Multiplies in place the current Vector4 by the given one.
  58524. * @param otherVector vector to multiple with
  58525. * @returns the updated Vector4.
  58526. */
  58527. multiplyInPlace(otherVector: Vector4): Vector4;
  58528. /**
  58529. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  58530. * @param otherVector vector to multiple with
  58531. * @returns resulting new vector
  58532. */
  58533. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  58534. /**
  58535. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  58536. * @param otherVector vector to multiple with
  58537. * @param result vector to store the result
  58538. * @returns the current Vector4.
  58539. */
  58540. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58541. /**
  58542. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  58543. * @param x x value multiply with
  58544. * @param y y value multiply with
  58545. * @param z z value multiply with
  58546. * @param w w value multiply with
  58547. * @returns resulting new vector
  58548. */
  58549. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  58550. /**
  58551. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  58552. * @param otherVector vector to devide with
  58553. * @returns resulting new vector
  58554. */
  58555. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  58556. /**
  58557. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  58558. * @param otherVector vector to devide with
  58559. * @param result vector to store the result
  58560. * @returns the current Vector4.
  58561. */
  58562. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58563. /**
  58564. * Divides the current Vector3 coordinates by the given ones.
  58565. * @param otherVector vector to devide with
  58566. * @returns the updated Vector3.
  58567. */
  58568. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58569. /**
  58570. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  58571. * @param other defines the second operand
  58572. * @returns the current updated Vector4
  58573. */
  58574. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  58575. /**
  58576. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  58577. * @param other defines the second operand
  58578. * @returns the current updated Vector4
  58579. */
  58580. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  58581. /**
  58582. * Gets a new Vector4 from current Vector4 floored values
  58583. * @returns a new Vector4
  58584. */
  58585. floor(): Vector4;
  58586. /**
  58587. * Gets a new Vector4 from current Vector3 floored values
  58588. * @returns a new Vector4
  58589. */
  58590. fract(): Vector4;
  58591. /**
  58592. * Returns the Vector4 length (float).
  58593. * @returns the length
  58594. */
  58595. length(): number;
  58596. /**
  58597. * Returns the Vector4 squared length (float).
  58598. * @returns the length squared
  58599. */
  58600. lengthSquared(): number;
  58601. /**
  58602. * Normalizes in place the Vector4.
  58603. * @returns the updated Vector4.
  58604. */
  58605. normalize(): Vector4;
  58606. /**
  58607. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  58608. * @returns this converted to a new vector3
  58609. */
  58610. toVector3(): Vector3;
  58611. /**
  58612. * Returns a new Vector4 copied from the current one.
  58613. * @returns the new cloned vector
  58614. */
  58615. clone(): Vector4;
  58616. /**
  58617. * Updates the current Vector4 with the given one coordinates.
  58618. * @param source the source vector to copy from
  58619. * @returns the updated Vector4.
  58620. */
  58621. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  58622. /**
  58623. * Updates the current Vector4 coordinates with the given floats.
  58624. * @param x float to copy from
  58625. * @param y float to copy from
  58626. * @param z float to copy from
  58627. * @param w float to copy from
  58628. * @returns the updated Vector4.
  58629. */
  58630. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  58631. /**
  58632. * Updates the current Vector4 coordinates with the given floats.
  58633. * @param x float to set from
  58634. * @param y float to set from
  58635. * @param z float to set from
  58636. * @param w float to set from
  58637. * @returns the updated Vector4.
  58638. */
  58639. set(x: number, y: number, z: number, w: number): Vector4;
  58640. /**
  58641. * Copies the given float to the current Vector3 coordinates
  58642. * @param v defines the x, y, z and w coordinates of the operand
  58643. * @returns the current updated Vector3
  58644. */
  58645. setAll(v: number): Vector4;
  58646. /**
  58647. * Returns a new Vector4 set from the starting index of the given array.
  58648. * @param array the array to pull values from
  58649. * @param offset the offset into the array to start at
  58650. * @returns the new vector
  58651. */
  58652. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  58653. /**
  58654. * Updates the given vector "result" from the starting index of the given array.
  58655. * @param array the array to pull values from
  58656. * @param offset the offset into the array to start at
  58657. * @param result the vector to store the result in
  58658. */
  58659. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  58660. /**
  58661. * Updates the given vector "result" from the starting index of the given Float32Array.
  58662. * @param array the array to pull values from
  58663. * @param offset the offset into the array to start at
  58664. * @param result the vector to store the result in
  58665. */
  58666. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  58667. /**
  58668. * Updates the given vector "result" coordinates from the given floats.
  58669. * @param x float to set from
  58670. * @param y float to set from
  58671. * @param z float to set from
  58672. * @param w float to set from
  58673. * @param result the vector to the floats in
  58674. */
  58675. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  58676. /**
  58677. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  58678. * @returns the new vector
  58679. */
  58680. static Zero(): Vector4;
  58681. /**
  58682. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  58683. * @returns the new vector
  58684. */
  58685. static One(): Vector4;
  58686. /**
  58687. * Returns a new normalized Vector4 from the given one.
  58688. * @param vector the vector to normalize
  58689. * @returns the vector
  58690. */
  58691. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  58692. /**
  58693. * Updates the given vector "result" from the normalization of the given one.
  58694. * @param vector the vector to normalize
  58695. * @param result the vector to store the result in
  58696. */
  58697. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  58698. /**
  58699. * Returns a vector with the minimum values from the left and right vectors
  58700. * @param left left vector to minimize
  58701. * @param right right vector to minimize
  58702. * @returns a new vector with the minimum of the left and right vector values
  58703. */
  58704. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  58705. /**
  58706. * Returns a vector with the maximum values from the left and right vectors
  58707. * @param left left vector to maximize
  58708. * @param right right vector to maximize
  58709. * @returns a new vector with the maximum of the left and right vector values
  58710. */
  58711. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  58712. /**
  58713. * Returns the distance (float) between the vectors "value1" and "value2".
  58714. * @param value1 value to calulate the distance between
  58715. * @param value2 value to calulate the distance between
  58716. * @return the distance between the two vectors
  58717. */
  58718. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  58719. /**
  58720. * Returns the squared distance (float) between the vectors "value1" and "value2".
  58721. * @param value1 value to calulate the distance between
  58722. * @param value2 value to calulate the distance between
  58723. * @return the distance between the two vectors squared
  58724. */
  58725. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  58726. /**
  58727. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  58728. * @param value1 value to calulate the center between
  58729. * @param value2 value to calulate the center between
  58730. * @return the center between the two vectors
  58731. */
  58732. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  58733. /**
  58734. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  58735. * This methods computes transformed normalized direction vectors only.
  58736. * @param vector the vector to transform
  58737. * @param transformation the transformation matrix to apply
  58738. * @returns the new vector
  58739. */
  58740. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  58741. /**
  58742. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  58743. * This methods computes transformed normalized direction vectors only.
  58744. * @param vector the vector to transform
  58745. * @param transformation the transformation matrix to apply
  58746. * @param result the vector to store the result in
  58747. */
  58748. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  58749. /**
  58750. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  58751. * This methods computes transformed normalized direction vectors only.
  58752. * @param x value to transform
  58753. * @param y value to transform
  58754. * @param z value to transform
  58755. * @param w value to transform
  58756. * @param transformation the transformation matrix to apply
  58757. * @param result the vector to store the results in
  58758. */
  58759. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  58760. /**
  58761. * Creates a new Vector4 from a Vector3
  58762. * @param source defines the source data
  58763. * @param w defines the 4th component (default is 0)
  58764. * @returns a new Vector4
  58765. */
  58766. static FromVector3(source: Vector3, w?: number): Vector4;
  58767. }
  58768. /**
  58769. * Interface for the size containing width and height
  58770. */
  58771. export interface ISize {
  58772. /**
  58773. * Width
  58774. */
  58775. width: number;
  58776. /**
  58777. * Heighht
  58778. */
  58779. height: number;
  58780. }
  58781. /**
  58782. * Size containing widht and height
  58783. */
  58784. export class Size implements ISize {
  58785. /**
  58786. * Width
  58787. */
  58788. width: number;
  58789. /**
  58790. * Height
  58791. */
  58792. height: number;
  58793. /**
  58794. * Creates a Size object from the given width and height (floats).
  58795. * @param width width of the new size
  58796. * @param height height of the new size
  58797. */
  58798. constructor(width: number, height: number);
  58799. /**
  58800. * Returns a string with the Size width and height
  58801. * @returns a string with the Size width and height
  58802. */
  58803. toString(): string;
  58804. /**
  58805. * "Size"
  58806. * @returns the string "Size"
  58807. */
  58808. getClassName(): string;
  58809. /**
  58810. * Returns the Size hash code.
  58811. * @returns a hash code for a unique width and height
  58812. */
  58813. getHashCode(): number;
  58814. /**
  58815. * Updates the current size from the given one.
  58816. * @param src the given size
  58817. */
  58818. copyFrom(src: Size): void;
  58819. /**
  58820. * Updates in place the current Size from the given floats.
  58821. * @param width width of the new size
  58822. * @param height height of the new size
  58823. * @returns the updated Size.
  58824. */
  58825. copyFromFloats(width: number, height: number): Size;
  58826. /**
  58827. * Updates in place the current Size from the given floats.
  58828. * @param width width to set
  58829. * @param height height to set
  58830. * @returns the updated Size.
  58831. */
  58832. set(width: number, height: number): Size;
  58833. /**
  58834. * Multiplies the width and height by numbers
  58835. * @param w factor to multiple the width by
  58836. * @param h factor to multiple the height by
  58837. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  58838. */
  58839. multiplyByFloats(w: number, h: number): Size;
  58840. /**
  58841. * Clones the size
  58842. * @returns a new Size copied from the given one.
  58843. */
  58844. clone(): Size;
  58845. /**
  58846. * True if the current Size and the given one width and height are strictly equal.
  58847. * @param other the other size to compare against
  58848. * @returns True if the current Size and the given one width and height are strictly equal.
  58849. */
  58850. equals(other: Size): boolean;
  58851. /**
  58852. * The surface of the Size : width * height (float).
  58853. */
  58854. readonly surface: number;
  58855. /**
  58856. * Create a new size of zero
  58857. * @returns a new Size set to (0.0, 0.0)
  58858. */
  58859. static Zero(): Size;
  58860. /**
  58861. * Sums the width and height of two sizes
  58862. * @param otherSize size to add to this size
  58863. * @returns a new Size set as the addition result of the current Size and the given one.
  58864. */
  58865. add(otherSize: Size): Size;
  58866. /**
  58867. * Subtracts the width and height of two
  58868. * @param otherSize size to subtract to this size
  58869. * @returns a new Size set as the subtraction result of the given one from the current Size.
  58870. */
  58871. subtract(otherSize: Size): Size;
  58872. /**
  58873. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  58874. * @param start starting size to lerp between
  58875. * @param end end size to lerp between
  58876. * @param amount amount to lerp between the start and end values
  58877. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  58878. */
  58879. static Lerp(start: Size, end: Size, amount: number): Size;
  58880. }
  58881. /**
  58882. * Class used to store quaternion data
  58883. * @see https://en.wikipedia.org/wiki/Quaternion
  58884. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  58885. */
  58886. export class Quaternion {
  58887. /** defines the first component (0 by default) */
  58888. x: number;
  58889. /** defines the second component (0 by default) */
  58890. y: number;
  58891. /** defines the third component (0 by default) */
  58892. z: number;
  58893. /** defines the fourth component (1.0 by default) */
  58894. w: number;
  58895. /**
  58896. * Creates a new Quaternion from the given floats
  58897. * @param x defines the first component (0 by default)
  58898. * @param y defines the second component (0 by default)
  58899. * @param z defines the third component (0 by default)
  58900. * @param w defines the fourth component (1.0 by default)
  58901. */
  58902. constructor(
  58903. /** defines the first component (0 by default) */
  58904. x?: number,
  58905. /** defines the second component (0 by default) */
  58906. y?: number,
  58907. /** defines the third component (0 by default) */
  58908. z?: number,
  58909. /** defines the fourth component (1.0 by default) */
  58910. w?: number);
  58911. /**
  58912. * Gets a string representation for the current quaternion
  58913. * @returns a string with the Quaternion coordinates
  58914. */
  58915. toString(): string;
  58916. /**
  58917. * Gets the class name of the quaternion
  58918. * @returns the string "Quaternion"
  58919. */
  58920. getClassName(): string;
  58921. /**
  58922. * Gets a hash code for this quaternion
  58923. * @returns the quaternion hash code
  58924. */
  58925. getHashCode(): number;
  58926. /**
  58927. * Copy the quaternion to an array
  58928. * @returns a new array populated with 4 elements from the quaternion coordinates
  58929. */
  58930. asArray(): number[];
  58931. /**
  58932. * Check if two quaternions are equals
  58933. * @param otherQuaternion defines the second operand
  58934. * @return true if the current quaternion and the given one coordinates are strictly equals
  58935. */
  58936. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  58937. /**
  58938. * Clone the current quaternion
  58939. * @returns a new quaternion copied from the current one
  58940. */
  58941. clone(): Quaternion;
  58942. /**
  58943. * Copy a quaternion to the current one
  58944. * @param other defines the other quaternion
  58945. * @returns the updated current quaternion
  58946. */
  58947. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  58948. /**
  58949. * Updates the current quaternion with the given float coordinates
  58950. * @param x defines the x coordinate
  58951. * @param y defines the y coordinate
  58952. * @param z defines the z coordinate
  58953. * @param w defines the w coordinate
  58954. * @returns the updated current quaternion
  58955. */
  58956. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  58957. /**
  58958. * Updates the current quaternion from the given float coordinates
  58959. * @param x defines the x coordinate
  58960. * @param y defines the y coordinate
  58961. * @param z defines the z coordinate
  58962. * @param w defines the w coordinate
  58963. * @returns the updated current quaternion
  58964. */
  58965. set(x: number, y: number, z: number, w: number): Quaternion;
  58966. /**
  58967. * Adds two quaternions
  58968. * @param other defines the second operand
  58969. * @returns a new quaternion as the addition result of the given one and the current quaternion
  58970. */
  58971. add(other: DeepImmutable<Quaternion>): Quaternion;
  58972. /**
  58973. * Add a quaternion to the current one
  58974. * @param other defines the quaternion to add
  58975. * @returns the current quaternion
  58976. */
  58977. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  58978. /**
  58979. * Subtract two quaternions
  58980. * @param other defines the second operand
  58981. * @returns a new quaternion as the subtraction result of the given one from the current one
  58982. */
  58983. subtract(other: Quaternion): Quaternion;
  58984. /**
  58985. * Multiplies the current quaternion by a scale factor
  58986. * @param value defines the scale factor
  58987. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  58988. */
  58989. scale(value: number): Quaternion;
  58990. /**
  58991. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  58992. * @param scale defines the scale factor
  58993. * @param result defines the Quaternion object where to store the result
  58994. * @returns the unmodified current quaternion
  58995. */
  58996. scaleToRef(scale: number, result: Quaternion): Quaternion;
  58997. /**
  58998. * Multiplies in place the current quaternion by a scale factor
  58999. * @param value defines the scale factor
  59000. * @returns the current modified quaternion
  59001. */
  59002. scaleInPlace(value: number): Quaternion;
  59003. /**
  59004. * Scale the current quaternion values by a factor and add the result to a given quaternion
  59005. * @param scale defines the scale factor
  59006. * @param result defines the Quaternion object where to store the result
  59007. * @returns the unmodified current quaternion
  59008. */
  59009. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  59010. /**
  59011. * Multiplies two quaternions
  59012. * @param q1 defines the second operand
  59013. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  59014. */
  59015. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  59016. /**
  59017. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  59018. * @param q1 defines the second operand
  59019. * @param result defines the target quaternion
  59020. * @returns the current quaternion
  59021. */
  59022. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  59023. /**
  59024. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  59025. * @param q1 defines the second operand
  59026. * @returns the currentupdated quaternion
  59027. */
  59028. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  59029. /**
  59030. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  59031. * @param ref defines the target quaternion
  59032. * @returns the current quaternion
  59033. */
  59034. conjugateToRef(ref: Quaternion): Quaternion;
  59035. /**
  59036. * Conjugates in place (1-q) the current quaternion
  59037. * @returns the current updated quaternion
  59038. */
  59039. conjugateInPlace(): Quaternion;
  59040. /**
  59041. * Conjugates in place (1-q) the current quaternion
  59042. * @returns a new quaternion
  59043. */
  59044. conjugate(): Quaternion;
  59045. /**
  59046. * Gets length of current quaternion
  59047. * @returns the quaternion length (float)
  59048. */
  59049. length(): number;
  59050. /**
  59051. * Normalize in place the current quaternion
  59052. * @returns the current updated quaternion
  59053. */
  59054. normalize(): Quaternion;
  59055. /**
  59056. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  59057. * @param order is a reserved parameter and is ignore for now
  59058. * @returns a new Vector3 containing the Euler angles
  59059. */
  59060. toEulerAngles(order?: string): Vector3;
  59061. /**
  59062. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  59063. * @param result defines the vector which will be filled with the Euler angles
  59064. * @param order is a reserved parameter and is ignore for now
  59065. * @returns the current unchanged quaternion
  59066. */
  59067. toEulerAnglesToRef(result: Vector3): Quaternion;
  59068. /**
  59069. * Updates the given rotation matrix with the current quaternion values
  59070. * @param result defines the target matrix
  59071. * @returns the current unchanged quaternion
  59072. */
  59073. toRotationMatrix(result: Matrix): Quaternion;
  59074. /**
  59075. * Updates the current quaternion from the given rotation matrix values
  59076. * @param matrix defines the source matrix
  59077. * @returns the current updated quaternion
  59078. */
  59079. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  59080. /**
  59081. * Creates a new quaternion from a rotation matrix
  59082. * @param matrix defines the source matrix
  59083. * @returns a new quaternion created from the given rotation matrix values
  59084. */
  59085. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  59086. /**
  59087. * Updates the given quaternion with the given rotation matrix values
  59088. * @param matrix defines the source matrix
  59089. * @param result defines the target quaternion
  59090. */
  59091. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  59092. /**
  59093. * Returns the dot product (float) between the quaternions "left" and "right"
  59094. * @param left defines the left operand
  59095. * @param right defines the right operand
  59096. * @returns the dot product
  59097. */
  59098. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  59099. /**
  59100. * Checks if the two quaternions are close to each other
  59101. * @param quat0 defines the first quaternion to check
  59102. * @param quat1 defines the second quaternion to check
  59103. * @returns true if the two quaternions are close to each other
  59104. */
  59105. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  59106. /**
  59107. * Creates an empty quaternion
  59108. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  59109. */
  59110. static Zero(): Quaternion;
  59111. /**
  59112. * Inverse a given quaternion
  59113. * @param q defines the source quaternion
  59114. * @returns a new quaternion as the inverted current quaternion
  59115. */
  59116. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  59117. /**
  59118. * Inverse a given quaternion
  59119. * @param q defines the source quaternion
  59120. * @param result the quaternion the result will be stored in
  59121. * @returns the result quaternion
  59122. */
  59123. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  59124. /**
  59125. * Creates an identity quaternion
  59126. * @returns the identity quaternion
  59127. */
  59128. static Identity(): Quaternion;
  59129. /**
  59130. * Gets a boolean indicating if the given quaternion is identity
  59131. * @param quaternion defines the quaternion to check
  59132. * @returns true if the quaternion is identity
  59133. */
  59134. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  59135. /**
  59136. * Creates a quaternion from a rotation around an axis
  59137. * @param axis defines the axis to use
  59138. * @param angle defines the angle to use
  59139. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  59140. */
  59141. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  59142. /**
  59143. * Creates a rotation around an axis and stores it into the given quaternion
  59144. * @param axis defines the axis to use
  59145. * @param angle defines the angle to use
  59146. * @param result defines the target quaternion
  59147. * @returns the target quaternion
  59148. */
  59149. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  59150. /**
  59151. * Creates a new quaternion from data stored into an array
  59152. * @param array defines the data source
  59153. * @param offset defines the offset in the source array where the data starts
  59154. * @returns a new quaternion
  59155. */
  59156. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  59157. /**
  59158. * Create a quaternion from Euler rotation angles
  59159. * @param x Pitch
  59160. * @param y Yaw
  59161. * @param z Roll
  59162. * @returns the new Quaternion
  59163. */
  59164. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  59165. /**
  59166. * Updates a quaternion from Euler rotation angles
  59167. * @param x Pitch
  59168. * @param y Yaw
  59169. * @param z Roll
  59170. * @param result the quaternion to store the result
  59171. * @returns the updated quaternion
  59172. */
  59173. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  59174. /**
  59175. * Create a quaternion from Euler rotation vector
  59176. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  59177. * @returns the new Quaternion
  59178. */
  59179. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  59180. /**
  59181. * Updates a quaternion from Euler rotation vector
  59182. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  59183. * @param result the quaternion to store the result
  59184. * @returns the updated quaternion
  59185. */
  59186. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  59187. /**
  59188. * Creates a new quaternion from the given Euler float angles (y, x, z)
  59189. * @param yaw defines the rotation around Y axis
  59190. * @param pitch defines the rotation around X axis
  59191. * @param roll defines the rotation around Z axis
  59192. * @returns the new quaternion
  59193. */
  59194. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  59195. /**
  59196. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  59197. * @param yaw defines the rotation around Y axis
  59198. * @param pitch defines the rotation around X axis
  59199. * @param roll defines the rotation around Z axis
  59200. * @param result defines the target quaternion
  59201. */
  59202. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  59203. /**
  59204. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  59205. * @param alpha defines the rotation around first axis
  59206. * @param beta defines the rotation around second axis
  59207. * @param gamma defines the rotation around third axis
  59208. * @returns the new quaternion
  59209. */
  59210. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  59211. /**
  59212. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  59213. * @param alpha defines the rotation around first axis
  59214. * @param beta defines the rotation around second axis
  59215. * @param gamma defines the rotation around third axis
  59216. * @param result defines the target quaternion
  59217. */
  59218. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  59219. /**
  59220. * 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)
  59221. * @param axis1 defines the first axis
  59222. * @param axis2 defines the second axis
  59223. * @param axis3 defines the third axis
  59224. * @returns the new quaternion
  59225. */
  59226. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  59227. /**
  59228. * 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
  59229. * @param axis1 defines the first axis
  59230. * @param axis2 defines the second axis
  59231. * @param axis3 defines the third axis
  59232. * @param ref defines the target quaternion
  59233. */
  59234. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  59235. /**
  59236. * Interpolates between two quaternions
  59237. * @param left defines first quaternion
  59238. * @param right defines second quaternion
  59239. * @param amount defines the gradient to use
  59240. * @returns the new interpolated quaternion
  59241. */
  59242. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  59243. /**
  59244. * Interpolates between two quaternions and stores it into a target quaternion
  59245. * @param left defines first quaternion
  59246. * @param right defines second quaternion
  59247. * @param amount defines the gradient to use
  59248. * @param result defines the target quaternion
  59249. */
  59250. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  59251. /**
  59252. * Interpolate between two quaternions using Hermite interpolation
  59253. * @param value1 defines first quaternion
  59254. * @param tangent1 defines the incoming tangent
  59255. * @param value2 defines second quaternion
  59256. * @param tangent2 defines the outgoing tangent
  59257. * @param amount defines the target quaternion
  59258. * @returns the new interpolated quaternion
  59259. */
  59260. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  59261. }
  59262. /**
  59263. * Class used to store matrix data (4x4)
  59264. */
  59265. export class Matrix {
  59266. private static _updateFlagSeed;
  59267. private static _identityReadOnly;
  59268. private _isIdentity;
  59269. private _isIdentityDirty;
  59270. private _isIdentity3x2;
  59271. private _isIdentity3x2Dirty;
  59272. /**
  59273. * Gets the update flag of the matrix which is an unique number for the matrix.
  59274. * It will be incremented every time the matrix data change.
  59275. * You can use it to speed the comparison between two versions of the same matrix.
  59276. */
  59277. updateFlag: number;
  59278. private readonly _m;
  59279. /**
  59280. * Gets the internal data of the matrix
  59281. */
  59282. readonly m: DeepImmutable<Float32Array>;
  59283. /** @hidden */
  59284. _markAsUpdated(): void;
  59285. /** @hidden */
  59286. private _updateIdentityStatus;
  59287. /**
  59288. * Creates an empty matrix (filled with zeros)
  59289. */
  59290. constructor();
  59291. /**
  59292. * Check if the current matrix is identity
  59293. * @returns true is the matrix is the identity matrix
  59294. */
  59295. isIdentity(): boolean;
  59296. /**
  59297. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  59298. * @returns true is the matrix is the identity matrix
  59299. */
  59300. isIdentityAs3x2(): boolean;
  59301. /**
  59302. * Gets the determinant of the matrix
  59303. * @returns the matrix determinant
  59304. */
  59305. determinant(): number;
  59306. /**
  59307. * Returns the matrix as a Float32Array
  59308. * @returns the matrix underlying array
  59309. */
  59310. toArray(): DeepImmutable<Float32Array>;
  59311. /**
  59312. * Returns the matrix as a Float32Array
  59313. * @returns the matrix underlying array.
  59314. */
  59315. asArray(): DeepImmutable<Float32Array>;
  59316. /**
  59317. * Inverts the current matrix in place
  59318. * @returns the current inverted matrix
  59319. */
  59320. invert(): Matrix;
  59321. /**
  59322. * Sets all the matrix elements to zero
  59323. * @returns the current matrix
  59324. */
  59325. reset(): Matrix;
  59326. /**
  59327. * Adds the current matrix with a second one
  59328. * @param other defines the matrix to add
  59329. * @returns a new matrix as the addition of the current matrix and the given one
  59330. */
  59331. add(other: DeepImmutable<Matrix>): Matrix;
  59332. /**
  59333. * Sets the given matrix "result" to the addition of the current matrix and the given one
  59334. * @param other defines the matrix to add
  59335. * @param result defines the target matrix
  59336. * @returns the current matrix
  59337. */
  59338. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  59339. /**
  59340. * Adds in place the given matrix to the current matrix
  59341. * @param other defines the second operand
  59342. * @returns the current updated matrix
  59343. */
  59344. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  59345. /**
  59346. * Sets the given matrix to the current inverted Matrix
  59347. * @param other defines the target matrix
  59348. * @returns the unmodified current matrix
  59349. */
  59350. invertToRef(other: Matrix): Matrix;
  59351. /**
  59352. * add a value at the specified position in the current Matrix
  59353. * @param index the index of the value within the matrix. between 0 and 15.
  59354. * @param value the value to be added
  59355. * @returns the current updated matrix
  59356. */
  59357. addAtIndex(index: number, value: number): Matrix;
  59358. /**
  59359. * mutiply the specified position in the current Matrix by a value
  59360. * @param index the index of the value within the matrix. between 0 and 15.
  59361. * @param value the value to be added
  59362. * @returns the current updated matrix
  59363. */
  59364. multiplyAtIndex(index: number, value: number): Matrix;
  59365. /**
  59366. * Inserts the translation vector (using 3 floats) in the current matrix
  59367. * @param x defines the 1st component of the translation
  59368. * @param y defines the 2nd component of the translation
  59369. * @param z defines the 3rd component of the translation
  59370. * @returns the current updated matrix
  59371. */
  59372. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  59373. /**
  59374. * Inserts the translation vector in the current matrix
  59375. * @param vector3 defines the translation to insert
  59376. * @returns the current updated matrix
  59377. */
  59378. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  59379. /**
  59380. * Gets the translation value of the current matrix
  59381. * @returns a new Vector3 as the extracted translation from the matrix
  59382. */
  59383. getTranslation(): Vector3;
  59384. /**
  59385. * Fill a Vector3 with the extracted translation from the matrix
  59386. * @param result defines the Vector3 where to store the translation
  59387. * @returns the current matrix
  59388. */
  59389. getTranslationToRef(result: Vector3): Matrix;
  59390. /**
  59391. * Remove rotation and scaling part from the matrix
  59392. * @returns the updated matrix
  59393. */
  59394. removeRotationAndScaling(): Matrix;
  59395. /**
  59396. * Multiply two matrices
  59397. * @param other defines the second operand
  59398. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  59399. */
  59400. multiply(other: DeepImmutable<Matrix>): Matrix;
  59401. /**
  59402. * Copy the current matrix from the given one
  59403. * @param other defines the source matrix
  59404. * @returns the current updated matrix
  59405. */
  59406. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  59407. /**
  59408. * Populates the given array from the starting index with the current matrix values
  59409. * @param array defines the target array
  59410. * @param offset defines the offset in the target array where to start storing values
  59411. * @returns the current matrix
  59412. */
  59413. copyToArray(array: Float32Array, offset?: number): Matrix;
  59414. /**
  59415. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  59416. * @param other defines the second operand
  59417. * @param result defines the matrix where to store the multiplication
  59418. * @returns the current matrix
  59419. */
  59420. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  59421. /**
  59422. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  59423. * @param other defines the second operand
  59424. * @param result defines the array where to store the multiplication
  59425. * @param offset defines the offset in the target array where to start storing values
  59426. * @returns the current matrix
  59427. */
  59428. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  59429. /**
  59430. * Check equality between this matrix and a second one
  59431. * @param value defines the second matrix to compare
  59432. * @returns true is the current matrix and the given one values are strictly equal
  59433. */
  59434. equals(value: DeepImmutable<Matrix>): boolean;
  59435. /**
  59436. * Clone the current matrix
  59437. * @returns a new matrix from the current matrix
  59438. */
  59439. clone(): Matrix;
  59440. /**
  59441. * Returns the name of the current matrix class
  59442. * @returns the string "Matrix"
  59443. */
  59444. getClassName(): string;
  59445. /**
  59446. * Gets the hash code of the current matrix
  59447. * @returns the hash code
  59448. */
  59449. getHashCode(): number;
  59450. /**
  59451. * Decomposes the current Matrix into a translation, rotation and scaling components
  59452. * @param scale defines the scale vector3 given as a reference to update
  59453. * @param rotation defines the rotation quaternion given as a reference to update
  59454. * @param translation defines the translation vector3 given as a reference to update
  59455. * @returns true if operation was successful
  59456. */
  59457. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  59458. /**
  59459. * Gets specific row of the matrix
  59460. * @param index defines the number of the row to get
  59461. * @returns the index-th row of the current matrix as a new Vector4
  59462. */
  59463. getRow(index: number): Nullable<Vector4>;
  59464. /**
  59465. * Sets the index-th row of the current matrix to the vector4 values
  59466. * @param index defines the number of the row to set
  59467. * @param row defines the target vector4
  59468. * @returns the updated current matrix
  59469. */
  59470. setRow(index: number, row: Vector4): Matrix;
  59471. /**
  59472. * Compute the transpose of the matrix
  59473. * @returns the new transposed matrix
  59474. */
  59475. transpose(): Matrix;
  59476. /**
  59477. * Compute the transpose of the matrix and store it in a given matrix
  59478. * @param result defines the target matrix
  59479. * @returns the current matrix
  59480. */
  59481. transposeToRef(result: Matrix): Matrix;
  59482. /**
  59483. * Sets the index-th row of the current matrix with the given 4 x float values
  59484. * @param index defines the row index
  59485. * @param x defines the x component to set
  59486. * @param y defines the y component to set
  59487. * @param z defines the z component to set
  59488. * @param w defines the w component to set
  59489. * @returns the updated current matrix
  59490. */
  59491. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  59492. /**
  59493. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  59494. * @param scale defines the scale factor
  59495. * @returns a new matrix
  59496. */
  59497. scale(scale: number): Matrix;
  59498. /**
  59499. * Scale the current matrix values by a factor to a given result matrix
  59500. * @param scale defines the scale factor
  59501. * @param result defines the matrix to store the result
  59502. * @returns the current matrix
  59503. */
  59504. scaleToRef(scale: number, result: Matrix): Matrix;
  59505. /**
  59506. * Scale the current matrix values by a factor and add the result to a given matrix
  59507. * @param scale defines the scale factor
  59508. * @param result defines the Matrix to store the result
  59509. * @returns the current matrix
  59510. */
  59511. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  59512. /**
  59513. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  59514. * @param ref matrix to store the result
  59515. */
  59516. toNormalMatrix(ref: Matrix): void;
  59517. /**
  59518. * Gets only rotation part of the current matrix
  59519. * @returns a new matrix sets to the extracted rotation matrix from the current one
  59520. */
  59521. getRotationMatrix(): Matrix;
  59522. /**
  59523. * Extracts the rotation matrix from the current one and sets it as the given "result"
  59524. * @param result defines the target matrix to store data to
  59525. * @returns the current matrix
  59526. */
  59527. getRotationMatrixToRef(result: Matrix): Matrix;
  59528. /**
  59529. * Toggles model matrix from being right handed to left handed in place and vice versa
  59530. */
  59531. toggleModelMatrixHandInPlace(): void;
  59532. /**
  59533. * Toggles projection matrix from being right handed to left handed in place and vice versa
  59534. */
  59535. toggleProjectionMatrixHandInPlace(): void;
  59536. /**
  59537. * Creates a matrix from an array
  59538. * @param array defines the source array
  59539. * @param offset defines an offset in the source array
  59540. * @returns a new Matrix set from the starting index of the given array
  59541. */
  59542. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  59543. /**
  59544. * Copy the content of an array into a given matrix
  59545. * @param array defines the source array
  59546. * @param offset defines an offset in the source array
  59547. * @param result defines the target matrix
  59548. */
  59549. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  59550. /**
  59551. * Stores an array into a matrix after having multiplied each component by a given factor
  59552. * @param array defines the source array
  59553. * @param offset defines the offset in the source array
  59554. * @param scale defines the scaling factor
  59555. * @param result defines the target matrix
  59556. */
  59557. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  59558. /**
  59559. * Gets an identity matrix that must not be updated
  59560. */
  59561. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  59562. /**
  59563. * Stores a list of values (16) inside a given matrix
  59564. * @param initialM11 defines 1st value of 1st row
  59565. * @param initialM12 defines 2nd value of 1st row
  59566. * @param initialM13 defines 3rd value of 1st row
  59567. * @param initialM14 defines 4th value of 1st row
  59568. * @param initialM21 defines 1st value of 2nd row
  59569. * @param initialM22 defines 2nd value of 2nd row
  59570. * @param initialM23 defines 3rd value of 2nd row
  59571. * @param initialM24 defines 4th value of 2nd row
  59572. * @param initialM31 defines 1st value of 3rd row
  59573. * @param initialM32 defines 2nd value of 3rd row
  59574. * @param initialM33 defines 3rd value of 3rd row
  59575. * @param initialM34 defines 4th value of 3rd row
  59576. * @param initialM41 defines 1st value of 4th row
  59577. * @param initialM42 defines 2nd value of 4th row
  59578. * @param initialM43 defines 3rd value of 4th row
  59579. * @param initialM44 defines 4th value of 4th row
  59580. * @param result defines the target matrix
  59581. */
  59582. 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;
  59583. /**
  59584. * Creates new matrix from a list of values (16)
  59585. * @param initialM11 defines 1st value of 1st row
  59586. * @param initialM12 defines 2nd value of 1st row
  59587. * @param initialM13 defines 3rd value of 1st row
  59588. * @param initialM14 defines 4th value of 1st row
  59589. * @param initialM21 defines 1st value of 2nd row
  59590. * @param initialM22 defines 2nd value of 2nd row
  59591. * @param initialM23 defines 3rd value of 2nd row
  59592. * @param initialM24 defines 4th value of 2nd row
  59593. * @param initialM31 defines 1st value of 3rd row
  59594. * @param initialM32 defines 2nd value of 3rd row
  59595. * @param initialM33 defines 3rd value of 3rd row
  59596. * @param initialM34 defines 4th value of 3rd row
  59597. * @param initialM41 defines 1st value of 4th row
  59598. * @param initialM42 defines 2nd value of 4th row
  59599. * @param initialM43 defines 3rd value of 4th row
  59600. * @param initialM44 defines 4th value of 4th row
  59601. * @returns the new matrix
  59602. */
  59603. 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;
  59604. /**
  59605. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  59606. * @param scale defines the scale vector3
  59607. * @param rotation defines the rotation quaternion
  59608. * @param translation defines the translation vector3
  59609. * @returns a new matrix
  59610. */
  59611. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  59612. /**
  59613. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  59614. * @param scale defines the scale vector3
  59615. * @param rotation defines the rotation quaternion
  59616. * @param translation defines the translation vector3
  59617. * @param result defines the target matrix
  59618. */
  59619. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  59620. /**
  59621. * Creates a new identity matrix
  59622. * @returns a new identity matrix
  59623. */
  59624. static Identity(): Matrix;
  59625. /**
  59626. * Creates a new identity matrix and stores the result in a given matrix
  59627. * @param result defines the target matrix
  59628. */
  59629. static IdentityToRef(result: Matrix): void;
  59630. /**
  59631. * Creates a new zero matrix
  59632. * @returns a new zero matrix
  59633. */
  59634. static Zero(): Matrix;
  59635. /**
  59636. * Creates a new rotation matrix for "angle" radians around the X axis
  59637. * @param angle defines the angle (in radians) to use
  59638. * @return the new matrix
  59639. */
  59640. static RotationX(angle: number): Matrix;
  59641. /**
  59642. * Creates a new matrix as the invert of a given matrix
  59643. * @param source defines the source matrix
  59644. * @returns the new matrix
  59645. */
  59646. static Invert(source: DeepImmutable<Matrix>): Matrix;
  59647. /**
  59648. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  59649. * @param angle defines the angle (in radians) to use
  59650. * @param result defines the target matrix
  59651. */
  59652. static RotationXToRef(angle: number, result: Matrix): void;
  59653. /**
  59654. * Creates a new rotation matrix for "angle" radians around the Y axis
  59655. * @param angle defines the angle (in radians) to use
  59656. * @return the new matrix
  59657. */
  59658. static RotationY(angle: number): Matrix;
  59659. /**
  59660. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  59661. * @param angle defines the angle (in radians) to use
  59662. * @param result defines the target matrix
  59663. */
  59664. static RotationYToRef(angle: number, result: Matrix): void;
  59665. /**
  59666. * Creates a new rotation matrix for "angle" radians around the Z axis
  59667. * @param angle defines the angle (in radians) to use
  59668. * @return the new matrix
  59669. */
  59670. static RotationZ(angle: number): Matrix;
  59671. /**
  59672. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  59673. * @param angle defines the angle (in radians) to use
  59674. * @param result defines the target matrix
  59675. */
  59676. static RotationZToRef(angle: number, result: Matrix): void;
  59677. /**
  59678. * Creates a new rotation matrix for "angle" radians around the given axis
  59679. * @param axis defines the axis to use
  59680. * @param angle defines the angle (in radians) to use
  59681. * @return the new matrix
  59682. */
  59683. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  59684. /**
  59685. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  59686. * @param axis defines the axis to use
  59687. * @param angle defines the angle (in radians) to use
  59688. * @param result defines the target matrix
  59689. */
  59690. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  59691. /**
  59692. * Creates a rotation matrix
  59693. * @param yaw defines the yaw angle in radians (Y axis)
  59694. * @param pitch defines the pitch angle in radians (X axis)
  59695. * @param roll defines the roll angle in radians (X axis)
  59696. * @returns the new rotation matrix
  59697. */
  59698. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  59699. /**
  59700. * Creates a rotation matrix and stores it in a given matrix
  59701. * @param yaw defines the yaw angle in radians (Y axis)
  59702. * @param pitch defines the pitch angle in radians (X axis)
  59703. * @param roll defines the roll angle in radians (X axis)
  59704. * @param result defines the target matrix
  59705. */
  59706. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  59707. /**
  59708. * Creates a scaling matrix
  59709. * @param x defines the scale factor on X axis
  59710. * @param y defines the scale factor on Y axis
  59711. * @param z defines the scale factor on Z axis
  59712. * @returns the new matrix
  59713. */
  59714. static Scaling(x: number, y: number, z: number): Matrix;
  59715. /**
  59716. * Creates a scaling matrix and stores it in a given matrix
  59717. * @param x defines the scale factor on X axis
  59718. * @param y defines the scale factor on Y axis
  59719. * @param z defines the scale factor on Z axis
  59720. * @param result defines the target matrix
  59721. */
  59722. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  59723. /**
  59724. * Creates a translation matrix
  59725. * @param x defines the translation on X axis
  59726. * @param y defines the translation on Y axis
  59727. * @param z defines the translationon Z axis
  59728. * @returns the new matrix
  59729. */
  59730. static Translation(x: number, y: number, z: number): Matrix;
  59731. /**
  59732. * Creates a translation matrix and stores it in a given matrix
  59733. * @param x defines the translation on X axis
  59734. * @param y defines the translation on Y axis
  59735. * @param z defines the translationon Z axis
  59736. * @param result defines the target matrix
  59737. */
  59738. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  59739. /**
  59740. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  59741. * @param startValue defines the start value
  59742. * @param endValue defines the end value
  59743. * @param gradient defines the gradient factor
  59744. * @returns the new matrix
  59745. */
  59746. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  59747. /**
  59748. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  59749. * @param startValue defines the start value
  59750. * @param endValue defines the end value
  59751. * @param gradient defines the gradient factor
  59752. * @param result defines the Matrix object where to store data
  59753. */
  59754. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  59755. /**
  59756. * Builds a new matrix whose values are computed by:
  59757. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  59758. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  59759. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  59760. * @param startValue defines the first matrix
  59761. * @param endValue defines the second matrix
  59762. * @param gradient defines the gradient between the two matrices
  59763. * @returns the new matrix
  59764. */
  59765. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  59766. /**
  59767. * Update a matrix to values which are computed by:
  59768. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  59769. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  59770. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  59771. * @param startValue defines the first matrix
  59772. * @param endValue defines the second matrix
  59773. * @param gradient defines the gradient between the two matrices
  59774. * @param result defines the target matrix
  59775. */
  59776. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  59777. /**
  59778. * 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"
  59779. * This function works in left handed mode
  59780. * @param eye defines the final position of the entity
  59781. * @param target defines where the entity should look at
  59782. * @param up defines the up vector for the entity
  59783. * @returns the new matrix
  59784. */
  59785. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  59786. /**
  59787. * 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".
  59788. * This function works in left handed mode
  59789. * @param eye defines the final position of the entity
  59790. * @param target defines where the entity should look at
  59791. * @param up defines the up vector for the entity
  59792. * @param result defines the target matrix
  59793. */
  59794. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  59795. /**
  59796. * 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"
  59797. * This function works in right handed mode
  59798. * @param eye defines the final position of the entity
  59799. * @param target defines where the entity should look at
  59800. * @param up defines the up vector for the entity
  59801. * @returns the new matrix
  59802. */
  59803. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  59804. /**
  59805. * 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".
  59806. * This function works in right handed mode
  59807. * @param eye defines the final position of the entity
  59808. * @param target defines where the entity should look at
  59809. * @param up defines the up vector for the entity
  59810. * @param result defines the target matrix
  59811. */
  59812. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  59813. /**
  59814. * Create a left-handed orthographic projection matrix
  59815. * @param width defines the viewport width
  59816. * @param height defines the viewport height
  59817. * @param znear defines the near clip plane
  59818. * @param zfar defines the far clip plane
  59819. * @returns a new matrix as a left-handed orthographic projection matrix
  59820. */
  59821. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  59822. /**
  59823. * Store a left-handed orthographic projection to a given matrix
  59824. * @param width defines the viewport width
  59825. * @param height defines the viewport height
  59826. * @param znear defines the near clip plane
  59827. * @param zfar defines the far clip plane
  59828. * @param result defines the target matrix
  59829. */
  59830. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  59831. /**
  59832. * Create a left-handed orthographic projection matrix
  59833. * @param left defines the viewport left coordinate
  59834. * @param right defines the viewport right coordinate
  59835. * @param bottom defines the viewport bottom coordinate
  59836. * @param top defines the viewport top coordinate
  59837. * @param znear defines the near clip plane
  59838. * @param zfar defines the far clip plane
  59839. * @returns a new matrix as a left-handed orthographic projection matrix
  59840. */
  59841. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  59842. /**
  59843. * Stores a left-handed orthographic projection into a given matrix
  59844. * @param left defines the viewport left coordinate
  59845. * @param right defines the viewport right coordinate
  59846. * @param bottom defines the viewport bottom coordinate
  59847. * @param top defines the viewport top coordinate
  59848. * @param znear defines the near clip plane
  59849. * @param zfar defines the far clip plane
  59850. * @param result defines the target matrix
  59851. */
  59852. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  59853. /**
  59854. * Creates a right-handed orthographic projection matrix
  59855. * @param left defines the viewport left coordinate
  59856. * @param right defines the viewport right coordinate
  59857. * @param bottom defines the viewport bottom coordinate
  59858. * @param top defines the viewport top coordinate
  59859. * @param znear defines the near clip plane
  59860. * @param zfar defines the far clip plane
  59861. * @returns a new matrix as a right-handed orthographic projection matrix
  59862. */
  59863. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  59864. /**
  59865. * Stores a right-handed orthographic projection into a given matrix
  59866. * @param left defines the viewport left coordinate
  59867. * @param right defines the viewport right coordinate
  59868. * @param bottom defines the viewport bottom coordinate
  59869. * @param top defines the viewport top coordinate
  59870. * @param znear defines the near clip plane
  59871. * @param zfar defines the far clip plane
  59872. * @param result defines the target matrix
  59873. */
  59874. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  59875. /**
  59876. * Creates a left-handed perspective projection matrix
  59877. * @param width defines the viewport width
  59878. * @param height defines the viewport height
  59879. * @param znear defines the near clip plane
  59880. * @param zfar defines the far clip plane
  59881. * @returns a new matrix as a left-handed perspective projection matrix
  59882. */
  59883. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  59884. /**
  59885. * Creates a left-handed perspective projection matrix
  59886. * @param fov defines the horizontal field of view
  59887. * @param aspect defines the aspect ratio
  59888. * @param znear defines the near clip plane
  59889. * @param zfar defines the far clip plane
  59890. * @returns a new matrix as a left-handed perspective projection matrix
  59891. */
  59892. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  59893. /**
  59894. * Stores a left-handed perspective projection into a given matrix
  59895. * @param fov defines the horizontal field of view
  59896. * @param aspect defines the aspect ratio
  59897. * @param znear defines the near clip plane
  59898. * @param zfar defines the far clip plane
  59899. * @param result defines the target matrix
  59900. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  59901. */
  59902. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  59903. /**
  59904. * Creates a right-handed perspective projection matrix
  59905. * @param fov defines the horizontal field of view
  59906. * @param aspect defines the aspect ratio
  59907. * @param znear defines the near clip plane
  59908. * @param zfar defines the far clip plane
  59909. * @returns a new matrix as a right-handed perspective projection matrix
  59910. */
  59911. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  59912. /**
  59913. * Stores a right-handed perspective projection into a given matrix
  59914. * @param fov defines the horizontal field of view
  59915. * @param aspect defines the aspect ratio
  59916. * @param znear defines the near clip plane
  59917. * @param zfar defines the far clip plane
  59918. * @param result defines the target matrix
  59919. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  59920. */
  59921. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  59922. /**
  59923. * Stores a perspective projection for WebVR info a given matrix
  59924. * @param fov defines the field of view
  59925. * @param znear defines the near clip plane
  59926. * @param zfar defines the far clip plane
  59927. * @param result defines the target matrix
  59928. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  59929. */
  59930. static PerspectiveFovWebVRToRef(fov: {
  59931. upDegrees: number;
  59932. downDegrees: number;
  59933. leftDegrees: number;
  59934. rightDegrees: number;
  59935. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  59936. /**
  59937. * Computes a complete transformation matrix
  59938. * @param viewport defines the viewport to use
  59939. * @param world defines the world matrix
  59940. * @param view defines the view matrix
  59941. * @param projection defines the projection matrix
  59942. * @param zmin defines the near clip plane
  59943. * @param zmax defines the far clip plane
  59944. * @returns the transformation matrix
  59945. */
  59946. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  59947. /**
  59948. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  59949. * @param matrix defines the matrix to use
  59950. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  59951. */
  59952. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  59953. /**
  59954. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  59955. * @param matrix defines the matrix to use
  59956. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  59957. */
  59958. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  59959. /**
  59960. * Compute the transpose of a given matrix
  59961. * @param matrix defines the matrix to transpose
  59962. * @returns the new matrix
  59963. */
  59964. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  59965. /**
  59966. * Compute the transpose of a matrix and store it in a target matrix
  59967. * @param matrix defines the matrix to transpose
  59968. * @param result defines the target matrix
  59969. */
  59970. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  59971. /**
  59972. * Computes a reflection matrix from a plane
  59973. * @param plane defines the reflection plane
  59974. * @returns a new matrix
  59975. */
  59976. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  59977. /**
  59978. * Computes a reflection matrix from a plane
  59979. * @param plane defines the reflection plane
  59980. * @param result defines the target matrix
  59981. */
  59982. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  59983. /**
  59984. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  59985. * @param xaxis defines the value of the 1st axis
  59986. * @param yaxis defines the value of the 2nd axis
  59987. * @param zaxis defines the value of the 3rd axis
  59988. * @param result defines the target matrix
  59989. */
  59990. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  59991. /**
  59992. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  59993. * @param quat defines the quaternion to use
  59994. * @param result defines the target matrix
  59995. */
  59996. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  59997. }
  59998. /**
  59999. * Represens a plane by the equation ax + by + cz + d = 0
  60000. */
  60001. export class Plane {
  60002. /**
  60003. * Normal of the plane (a,b,c)
  60004. */
  60005. normal: Vector3;
  60006. /**
  60007. * d component of the plane
  60008. */
  60009. d: number;
  60010. /**
  60011. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  60012. * @param a a component of the plane
  60013. * @param b b component of the plane
  60014. * @param c c component of the plane
  60015. * @param d d component of the plane
  60016. */
  60017. constructor(a: number, b: number, c: number, d: number);
  60018. /**
  60019. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  60020. */
  60021. asArray(): number[];
  60022. /**
  60023. * @returns a new plane copied from the current Plane.
  60024. */
  60025. clone(): Plane;
  60026. /**
  60027. * @returns the string "Plane".
  60028. */
  60029. getClassName(): string;
  60030. /**
  60031. * @returns the Plane hash code.
  60032. */
  60033. getHashCode(): number;
  60034. /**
  60035. * Normalize the current Plane in place.
  60036. * @returns the updated Plane.
  60037. */
  60038. normalize(): Plane;
  60039. /**
  60040. * Applies a transformation the plane and returns the result
  60041. * @param transformation the transformation matrix to be applied to the plane
  60042. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  60043. */
  60044. transform(transformation: DeepImmutable<Matrix>): Plane;
  60045. /**
  60046. * Calcualtte the dot product between the point and the plane normal
  60047. * @param point point to calculate the dot product with
  60048. * @returns the dot product (float) of the point coordinates and the plane normal.
  60049. */
  60050. dotCoordinate(point: DeepImmutable<Vector3>): number;
  60051. /**
  60052. * Updates the current Plane from the plane defined by the three given points.
  60053. * @param point1 one of the points used to contruct the plane
  60054. * @param point2 one of the points used to contruct the plane
  60055. * @param point3 one of the points used to contruct the plane
  60056. * @returns the updated Plane.
  60057. */
  60058. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  60059. /**
  60060. * Checks if the plane is facing a given direction
  60061. * @param direction the direction to check if the plane is facing
  60062. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  60063. * @returns True is the vector "direction" is the same side than the plane normal.
  60064. */
  60065. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  60066. /**
  60067. * Calculates the distance to a point
  60068. * @param point point to calculate distance to
  60069. * @returns the signed distance (float) from the given point to the Plane.
  60070. */
  60071. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  60072. /**
  60073. * Creates a plane from an array
  60074. * @param array the array to create a plane from
  60075. * @returns a new Plane from the given array.
  60076. */
  60077. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  60078. /**
  60079. * Creates a plane from three points
  60080. * @param point1 point used to create the plane
  60081. * @param point2 point used to create the plane
  60082. * @param point3 point used to create the plane
  60083. * @returns a new Plane defined by the three given points.
  60084. */
  60085. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  60086. /**
  60087. * Creates a plane from an origin point and a normal
  60088. * @param origin origin of the plane to be constructed
  60089. * @param normal normal of the plane to be constructed
  60090. * @returns a new Plane the normal vector to this plane at the given origin point.
  60091. * Note : the vector "normal" is updated because normalized.
  60092. */
  60093. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  60094. /**
  60095. * Calculates the distance from a plane and a point
  60096. * @param origin origin of the plane to be constructed
  60097. * @param normal normal of the plane to be constructed
  60098. * @param point point to calculate distance to
  60099. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  60100. */
  60101. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  60102. }
  60103. /**
  60104. * Class used to represent a viewport on screen
  60105. */
  60106. export class Viewport {
  60107. /** viewport left coordinate */
  60108. x: number;
  60109. /** viewport top coordinate */
  60110. y: number;
  60111. /**viewport width */
  60112. width: number;
  60113. /** viewport height */
  60114. height: number;
  60115. /**
  60116. * Creates a Viewport object located at (x, y) and sized (width, height)
  60117. * @param x defines viewport left coordinate
  60118. * @param y defines viewport top coordinate
  60119. * @param width defines the viewport width
  60120. * @param height defines the viewport height
  60121. */
  60122. constructor(
  60123. /** viewport left coordinate */
  60124. x: number,
  60125. /** viewport top coordinate */
  60126. y: number,
  60127. /**viewport width */
  60128. width: number,
  60129. /** viewport height */
  60130. height: number);
  60131. /**
  60132. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  60133. * @param renderWidth defines the rendering width
  60134. * @param renderHeight defines the rendering height
  60135. * @returns a new Viewport
  60136. */
  60137. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  60138. /**
  60139. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  60140. * @param renderWidth defines the rendering width
  60141. * @param renderHeight defines the rendering height
  60142. * @param ref defines the target viewport
  60143. * @returns the current viewport
  60144. */
  60145. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  60146. /**
  60147. * Returns a new Viewport copied from the current one
  60148. * @returns a new Viewport
  60149. */
  60150. clone(): Viewport;
  60151. }
  60152. /**
  60153. * Reprasents a camera frustum
  60154. */
  60155. export class Frustum {
  60156. /**
  60157. * Gets the planes representing the frustum
  60158. * @param transform matrix to be applied to the returned planes
  60159. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  60160. */
  60161. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  60162. /**
  60163. * Gets the near frustum plane transformed by the transform matrix
  60164. * @param transform transformation matrix to be applied to the resulting frustum plane
  60165. * @param frustumPlane the resuling frustum plane
  60166. */
  60167. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60168. /**
  60169. * Gets the far frustum plane transformed by the transform matrix
  60170. * @param transform transformation matrix to be applied to the resulting frustum plane
  60171. * @param frustumPlane the resuling frustum plane
  60172. */
  60173. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60174. /**
  60175. * Gets the left frustum plane transformed by the transform matrix
  60176. * @param transform transformation matrix to be applied to the resulting frustum plane
  60177. * @param frustumPlane the resuling frustum plane
  60178. */
  60179. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60180. /**
  60181. * Gets the right frustum plane transformed by the transform matrix
  60182. * @param transform transformation matrix to be applied to the resulting frustum plane
  60183. * @param frustumPlane the resuling frustum plane
  60184. */
  60185. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60186. /**
  60187. * Gets the top frustum plane transformed by the transform matrix
  60188. * @param transform transformation matrix to be applied to the resulting frustum plane
  60189. * @param frustumPlane the resuling frustum plane
  60190. */
  60191. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60192. /**
  60193. * Gets the bottom frustum plane transformed by the transform matrix
  60194. * @param transform transformation matrix to be applied to the resulting frustum plane
  60195. * @param frustumPlane the resuling frustum plane
  60196. */
  60197. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60198. /**
  60199. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  60200. * @param transform transformation matrix to be applied to the resulting frustum planes
  60201. * @param frustumPlanes the resuling frustum planes
  60202. */
  60203. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  60204. }
  60205. /** Defines supported spaces */
  60206. export enum Space {
  60207. /** Local (object) space */
  60208. LOCAL = 0,
  60209. /** World space */
  60210. WORLD = 1,
  60211. /** Bone space */
  60212. BONE = 2
  60213. }
  60214. /** Defines the 3 main axes */
  60215. export class Axis {
  60216. /** X axis */
  60217. static X: Vector3;
  60218. /** Y axis */
  60219. static Y: Vector3;
  60220. /** Z axis */
  60221. static Z: Vector3;
  60222. }
  60223. /** Class used to represent a Bezier curve */
  60224. export class BezierCurve {
  60225. /**
  60226. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  60227. * @param t defines the time
  60228. * @param x1 defines the left coordinate on X axis
  60229. * @param y1 defines the left coordinate on Y axis
  60230. * @param x2 defines the right coordinate on X axis
  60231. * @param y2 defines the right coordinate on Y axis
  60232. * @returns the interpolated value
  60233. */
  60234. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  60235. }
  60236. /**
  60237. * Defines potential orientation for back face culling
  60238. */
  60239. export enum Orientation {
  60240. /**
  60241. * Clockwise
  60242. */
  60243. CW = 0,
  60244. /** Counter clockwise */
  60245. CCW = 1
  60246. }
  60247. /**
  60248. * Defines angle representation
  60249. */
  60250. export class Angle {
  60251. private _radians;
  60252. /**
  60253. * Creates an Angle object of "radians" radians (float).
  60254. * @param radians the angle in radians
  60255. */
  60256. constructor(radians: number);
  60257. /**
  60258. * Get value in degrees
  60259. * @returns the Angle value in degrees (float)
  60260. */
  60261. degrees(): number;
  60262. /**
  60263. * Get value in radians
  60264. * @returns the Angle value in radians (float)
  60265. */
  60266. radians(): number;
  60267. /**
  60268. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  60269. * @param a defines first vector
  60270. * @param b defines second vector
  60271. * @returns a new Angle
  60272. */
  60273. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  60274. /**
  60275. * Gets a new Angle object from the given float in radians
  60276. * @param radians defines the angle value in radians
  60277. * @returns a new Angle
  60278. */
  60279. static FromRadians(radians: number): Angle;
  60280. /**
  60281. * Gets a new Angle object from the given float in degrees
  60282. * @param degrees defines the angle value in degrees
  60283. * @returns a new Angle
  60284. */
  60285. static FromDegrees(degrees: number): Angle;
  60286. }
  60287. /**
  60288. * This represents an arc in a 2d space.
  60289. */
  60290. export class Arc2 {
  60291. /** Defines the start point of the arc */
  60292. startPoint: Vector2;
  60293. /** Defines the mid point of the arc */
  60294. midPoint: Vector2;
  60295. /** Defines the end point of the arc */
  60296. endPoint: Vector2;
  60297. /**
  60298. * Defines the center point of the arc.
  60299. */
  60300. centerPoint: Vector2;
  60301. /**
  60302. * Defines the radius of the arc.
  60303. */
  60304. radius: number;
  60305. /**
  60306. * Defines the angle of the arc (from mid point to end point).
  60307. */
  60308. angle: Angle;
  60309. /**
  60310. * Defines the start angle of the arc (from start point to middle point).
  60311. */
  60312. startAngle: Angle;
  60313. /**
  60314. * Defines the orientation of the arc (clock wise/counter clock wise).
  60315. */
  60316. orientation: Orientation;
  60317. /**
  60318. * Creates an Arc object from the three given points : start, middle and end.
  60319. * @param startPoint Defines the start point of the arc
  60320. * @param midPoint Defines the midlle point of the arc
  60321. * @param endPoint Defines the end point of the arc
  60322. */
  60323. constructor(
  60324. /** Defines the start point of the arc */
  60325. startPoint: Vector2,
  60326. /** Defines the mid point of the arc */
  60327. midPoint: Vector2,
  60328. /** Defines the end point of the arc */
  60329. endPoint: Vector2);
  60330. }
  60331. /**
  60332. * Represents a 2D path made up of multiple 2D points
  60333. */
  60334. export class Path2 {
  60335. private _points;
  60336. private _length;
  60337. /**
  60338. * If the path start and end point are the same
  60339. */
  60340. closed: boolean;
  60341. /**
  60342. * Creates a Path2 object from the starting 2D coordinates x and y.
  60343. * @param x the starting points x value
  60344. * @param y the starting points y value
  60345. */
  60346. constructor(x: number, y: number);
  60347. /**
  60348. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  60349. * @param x the added points x value
  60350. * @param y the added points y value
  60351. * @returns the updated Path2.
  60352. */
  60353. addLineTo(x: number, y: number): Path2;
  60354. /**
  60355. * 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.
  60356. * @param midX middle point x value
  60357. * @param midY middle point y value
  60358. * @param endX end point x value
  60359. * @param endY end point y value
  60360. * @param numberOfSegments (default: 36)
  60361. * @returns the updated Path2.
  60362. */
  60363. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  60364. /**
  60365. * Closes the Path2.
  60366. * @returns the Path2.
  60367. */
  60368. close(): Path2;
  60369. /**
  60370. * Gets the sum of the distance between each sequential point in the path
  60371. * @returns the Path2 total length (float).
  60372. */
  60373. length(): number;
  60374. /**
  60375. * Gets the points which construct the path
  60376. * @returns the Path2 internal array of points.
  60377. */
  60378. getPoints(): Vector2[];
  60379. /**
  60380. * Retreives the point at the distance aways from the starting point
  60381. * @param normalizedLengthPosition the length along the path to retreive the point from
  60382. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  60383. */
  60384. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  60385. /**
  60386. * Creates a new path starting from an x and y position
  60387. * @param x starting x value
  60388. * @param y starting y value
  60389. * @returns a new Path2 starting at the coordinates (x, y).
  60390. */
  60391. static StartingAt(x: number, y: number): Path2;
  60392. }
  60393. /**
  60394. * Represents a 3D path made up of multiple 3D points
  60395. */
  60396. export class Path3D {
  60397. /**
  60398. * an array of Vector3, the curve axis of the Path3D
  60399. */
  60400. path: Vector3[];
  60401. private _curve;
  60402. private _distances;
  60403. private _tangents;
  60404. private _normals;
  60405. private _binormals;
  60406. private _raw;
  60407. /**
  60408. * new Path3D(path, normal, raw)
  60409. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  60410. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  60411. * @param path an array of Vector3, the curve axis of the Path3D
  60412. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  60413. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  60414. */
  60415. constructor(
  60416. /**
  60417. * an array of Vector3, the curve axis of the Path3D
  60418. */
  60419. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  60420. /**
  60421. * Returns the Path3D array of successive Vector3 designing its curve.
  60422. * @returns the Path3D array of successive Vector3 designing its curve.
  60423. */
  60424. getCurve(): Vector3[];
  60425. /**
  60426. * Returns an array populated with tangent vectors on each Path3D curve point.
  60427. * @returns an array populated with tangent vectors on each Path3D curve point.
  60428. */
  60429. getTangents(): Vector3[];
  60430. /**
  60431. * Returns an array populated with normal vectors on each Path3D curve point.
  60432. * @returns an array populated with normal vectors on each Path3D curve point.
  60433. */
  60434. getNormals(): Vector3[];
  60435. /**
  60436. * Returns an array populated with binormal vectors on each Path3D curve point.
  60437. * @returns an array populated with binormal vectors on each Path3D curve point.
  60438. */
  60439. getBinormals(): Vector3[];
  60440. /**
  60441. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  60442. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  60443. */
  60444. getDistances(): number[];
  60445. /**
  60446. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  60447. * @param path path which all values are copied into the curves points
  60448. * @param firstNormal which should be projected onto the curve
  60449. * @returns the same object updated.
  60450. */
  60451. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  60452. private _compute;
  60453. private _getFirstNonNullVector;
  60454. private _getLastNonNullVector;
  60455. private _normalVector;
  60456. }
  60457. /**
  60458. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  60459. * A Curve3 is designed from a series of successive Vector3.
  60460. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  60461. */
  60462. export class Curve3 {
  60463. private _points;
  60464. private _length;
  60465. /**
  60466. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  60467. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  60468. * @param v1 (Vector3) the control point
  60469. * @param v2 (Vector3) the end point of the Quadratic Bezier
  60470. * @param nbPoints (integer) the wanted number of points in the curve
  60471. * @returns the created Curve3
  60472. */
  60473. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60474. /**
  60475. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  60476. * @param v0 (Vector3) the origin point of the Cubic Bezier
  60477. * @param v1 (Vector3) the first control point
  60478. * @param v2 (Vector3) the second control point
  60479. * @param v3 (Vector3) the end point of the Cubic Bezier
  60480. * @param nbPoints (integer) the wanted number of points in the curve
  60481. * @returns the created Curve3
  60482. */
  60483. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60484. /**
  60485. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  60486. * @param p1 (Vector3) the origin point of the Hermite Spline
  60487. * @param t1 (Vector3) the tangent vector at the origin point
  60488. * @param p2 (Vector3) the end point of the Hermite Spline
  60489. * @param t2 (Vector3) the tangent vector at the end point
  60490. * @param nbPoints (integer) the wanted number of points in the curve
  60491. * @returns the created Curve3
  60492. */
  60493. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60494. /**
  60495. * Returns a Curve3 object along a CatmullRom Spline curve :
  60496. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  60497. * @param nbPoints (integer) the wanted number of points between each curve control points
  60498. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  60499. * @returns the created Curve3
  60500. */
  60501. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  60502. /**
  60503. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  60504. * A Curve3 is designed from a series of successive Vector3.
  60505. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  60506. * @param points points which make up the curve
  60507. */
  60508. constructor(points: Vector3[]);
  60509. /**
  60510. * @returns the Curve3 stored array of successive Vector3
  60511. */
  60512. getPoints(): Vector3[];
  60513. /**
  60514. * @returns the computed length (float) of the curve.
  60515. */
  60516. length(): number;
  60517. /**
  60518. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  60519. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  60520. * curveA and curveB keep unchanged.
  60521. * @param curve the curve to continue from this curve
  60522. * @returns the newly constructed curve
  60523. */
  60524. continue(curve: DeepImmutable<Curve3>): Curve3;
  60525. private _computeLength;
  60526. }
  60527. /**
  60528. * Contains position and normal vectors for a vertex
  60529. */
  60530. export class PositionNormalVertex {
  60531. /** the position of the vertex (defaut: 0,0,0) */
  60532. position: Vector3;
  60533. /** the normal of the vertex (defaut: 0,1,0) */
  60534. normal: Vector3;
  60535. /**
  60536. * Creates a PositionNormalVertex
  60537. * @param position the position of the vertex (defaut: 0,0,0)
  60538. * @param normal the normal of the vertex (defaut: 0,1,0)
  60539. */
  60540. constructor(
  60541. /** the position of the vertex (defaut: 0,0,0) */
  60542. position?: Vector3,
  60543. /** the normal of the vertex (defaut: 0,1,0) */
  60544. normal?: Vector3);
  60545. /**
  60546. * Clones the PositionNormalVertex
  60547. * @returns the cloned PositionNormalVertex
  60548. */
  60549. clone(): PositionNormalVertex;
  60550. }
  60551. /**
  60552. * Contains position, normal and uv vectors for a vertex
  60553. */
  60554. export class PositionNormalTextureVertex {
  60555. /** the position of the vertex (defaut: 0,0,0) */
  60556. position: Vector3;
  60557. /** the normal of the vertex (defaut: 0,1,0) */
  60558. normal: Vector3;
  60559. /** the uv of the vertex (default: 0,0) */
  60560. uv: Vector2;
  60561. /**
  60562. * Creates a PositionNormalTextureVertex
  60563. * @param position the position of the vertex (defaut: 0,0,0)
  60564. * @param normal the normal of the vertex (defaut: 0,1,0)
  60565. * @param uv the uv of the vertex (default: 0,0)
  60566. */
  60567. constructor(
  60568. /** the position of the vertex (defaut: 0,0,0) */
  60569. position?: Vector3,
  60570. /** the normal of the vertex (defaut: 0,1,0) */
  60571. normal?: Vector3,
  60572. /** the uv of the vertex (default: 0,0) */
  60573. uv?: Vector2);
  60574. /**
  60575. * Clones the PositionNormalTextureVertex
  60576. * @returns the cloned PositionNormalTextureVertex
  60577. */
  60578. clone(): PositionNormalTextureVertex;
  60579. }
  60580. /**
  60581. * @hidden
  60582. */
  60583. export class Tmp {
  60584. static Color3: Color3[];
  60585. static Color4: Color4[];
  60586. static Vector2: Vector2[];
  60587. static Vector3: Vector3[];
  60588. static Vector4: Vector4[];
  60589. static Quaternion: Quaternion[];
  60590. static Matrix: Matrix[];
  60591. }
  60592. }
  60593. declare module BABYLON {
  60594. /**
  60595. * Class used to enable access to offline support
  60596. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60597. */
  60598. export interface IOfflineProvider {
  60599. /**
  60600. * Gets a boolean indicating if scene must be saved in the database
  60601. */
  60602. enableSceneOffline: boolean;
  60603. /**
  60604. * Gets a boolean indicating if textures must be saved in the database
  60605. */
  60606. enableTexturesOffline: boolean;
  60607. /**
  60608. * Open the offline support and make it available
  60609. * @param successCallback defines the callback to call on success
  60610. * @param errorCallback defines the callback to call on error
  60611. */
  60612. open(successCallback: () => void, errorCallback: () => void): void;
  60613. /**
  60614. * Loads an image from the offline support
  60615. * @param url defines the url to load from
  60616. * @param image defines the target DOM image
  60617. */
  60618. loadImage(url: string, image: HTMLImageElement): void;
  60619. /**
  60620. * Loads a file from offline support
  60621. * @param url defines the URL to load from
  60622. * @param sceneLoaded defines a callback to call on success
  60623. * @param progressCallBack defines a callback to call when progress changed
  60624. * @param errorCallback defines a callback to call on error
  60625. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60626. */
  60627. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60628. }
  60629. }
  60630. declare module BABYLON {
  60631. /**
  60632. * A class serves as a medium between the observable and its observers
  60633. */
  60634. export class EventState {
  60635. /**
  60636. * Create a new EventState
  60637. * @param mask defines the mask associated with this state
  60638. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60639. * @param target defines the original target of the state
  60640. * @param currentTarget defines the current target of the state
  60641. */
  60642. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  60643. /**
  60644. * Initialize the current event state
  60645. * @param mask defines the mask associated with this state
  60646. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60647. * @param target defines the original target of the state
  60648. * @param currentTarget defines the current target of the state
  60649. * @returns the current event state
  60650. */
  60651. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  60652. /**
  60653. * An Observer can set this property to true to prevent subsequent observers of being notified
  60654. */
  60655. skipNextObservers: boolean;
  60656. /**
  60657. * Get the mask value that were used to trigger the event corresponding to this EventState object
  60658. */
  60659. mask: number;
  60660. /**
  60661. * The object that originally notified the event
  60662. */
  60663. target?: any;
  60664. /**
  60665. * The current object in the bubbling phase
  60666. */
  60667. currentTarget?: any;
  60668. /**
  60669. * This will be populated with the return value of the last function that was executed.
  60670. * If it is the first function in the callback chain it will be the event data.
  60671. */
  60672. lastReturnValue?: any;
  60673. }
  60674. /**
  60675. * Represent an Observer registered to a given Observable object.
  60676. */
  60677. export class Observer<T> {
  60678. /**
  60679. * Defines the callback to call when the observer is notified
  60680. */
  60681. callback: (eventData: T, eventState: EventState) => void;
  60682. /**
  60683. * Defines the mask of the observer (used to filter notifications)
  60684. */
  60685. mask: number;
  60686. /**
  60687. * Defines the current scope used to restore the JS context
  60688. */
  60689. scope: any;
  60690. /** @hidden */
  60691. _willBeUnregistered: boolean;
  60692. /**
  60693. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  60694. */
  60695. unregisterOnNextCall: boolean;
  60696. /**
  60697. * Creates a new observer
  60698. * @param callback defines the callback to call when the observer is notified
  60699. * @param mask defines the mask of the observer (used to filter notifications)
  60700. * @param scope defines the current scope used to restore the JS context
  60701. */
  60702. constructor(
  60703. /**
  60704. * Defines the callback to call when the observer is notified
  60705. */
  60706. callback: (eventData: T, eventState: EventState) => void,
  60707. /**
  60708. * Defines the mask of the observer (used to filter notifications)
  60709. */
  60710. mask: number,
  60711. /**
  60712. * Defines the current scope used to restore the JS context
  60713. */
  60714. scope?: any);
  60715. }
  60716. /**
  60717. * Represent a list of observers registered to multiple Observables object.
  60718. */
  60719. export class MultiObserver<T> {
  60720. private _observers;
  60721. private _observables;
  60722. /**
  60723. * Release associated resources
  60724. */
  60725. dispose(): void;
  60726. /**
  60727. * Raise a callback when one of the observable will notify
  60728. * @param observables defines a list of observables to watch
  60729. * @param callback defines the callback to call on notification
  60730. * @param mask defines the mask used to filter notifications
  60731. * @param scope defines the current scope used to restore the JS context
  60732. * @returns the new MultiObserver
  60733. */
  60734. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  60735. }
  60736. /**
  60737. * The Observable class is a simple implementation of the Observable pattern.
  60738. *
  60739. * 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.
  60740. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  60741. * 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).
  60742. * 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.
  60743. */
  60744. export class Observable<T> {
  60745. private _observers;
  60746. private _eventState;
  60747. private _onObserverAdded;
  60748. /**
  60749. * Creates a new observable
  60750. * @param onObserverAdded defines a callback to call when a new observer is added
  60751. */
  60752. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  60753. /**
  60754. * Create a new Observer with the specified callback
  60755. * @param callback the callback that will be executed for that Observer
  60756. * @param mask the mask used to filter observers
  60757. * @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.
  60758. * @param scope optional scope for the callback to be called from
  60759. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  60760. * @returns the new observer created for the callback
  60761. */
  60762. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  60763. /**
  60764. * Create a new Observer with the specified callback and unregisters after the next notification
  60765. * @param callback the callback that will be executed for that Observer
  60766. * @returns the new observer created for the callback
  60767. */
  60768. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  60769. /**
  60770. * Remove an Observer from the Observable object
  60771. * @param observer the instance of the Observer to remove
  60772. * @returns false if it doesn't belong to this Observable
  60773. */
  60774. remove(observer: Nullable<Observer<T>>): boolean;
  60775. /**
  60776. * Remove a callback from the Observable object
  60777. * @param callback the callback to remove
  60778. * @param scope optional scope. If used only the callbacks with this scope will be removed
  60779. * @returns false if it doesn't belong to this Observable
  60780. */
  60781. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  60782. private _deferUnregister;
  60783. private _remove;
  60784. /**
  60785. * Notify all Observers by calling their respective callback with the given data
  60786. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  60787. * @param eventData defines the data to send to all observers
  60788. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  60789. * @param target defines the original target of the state
  60790. * @param currentTarget defines the current target of the state
  60791. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  60792. */
  60793. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  60794. /**
  60795. * Calling this will execute each callback, expecting it to be a promise or return a value.
  60796. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  60797. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  60798. * and it is crucial that all callbacks will be executed.
  60799. * The order of the callbacks is kept, callbacks are not executed parallel.
  60800. *
  60801. * @param eventData The data to be sent to each callback
  60802. * @param mask is used to filter observers defaults to -1
  60803. * @param target defines the callback target (see EventState)
  60804. * @param currentTarget defines he current object in the bubbling phase
  60805. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  60806. */
  60807. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  60808. /**
  60809. * Notify a specific observer
  60810. * @param observer defines the observer to notify
  60811. * @param eventData defines the data to be sent to each callback
  60812. * @param mask is used to filter observers defaults to -1
  60813. */
  60814. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  60815. /**
  60816. * Gets a boolean indicating if the observable has at least one observer
  60817. * @returns true is the Observable has at least one Observer registered
  60818. */
  60819. hasObservers(): boolean;
  60820. /**
  60821. * Clear the list of observers
  60822. */
  60823. clear(): void;
  60824. /**
  60825. * Clone the current observable
  60826. * @returns a new observable
  60827. */
  60828. clone(): Observable<T>;
  60829. /**
  60830. * Does this observable handles observer registered with a given mask
  60831. * @param mask defines the mask to be tested
  60832. * @return whether or not one observer registered with the given mask is handeled
  60833. **/
  60834. hasSpecificMask(mask?: number): boolean;
  60835. }
  60836. }
  60837. declare module BABYLON {
  60838. /**
  60839. * Class used to help managing file picking and drag'n'drop
  60840. * File Storage
  60841. */
  60842. export class FilesInputStore {
  60843. /**
  60844. * List of files ready to be loaded
  60845. */
  60846. static FilesToLoad: {
  60847. [key: string]: File;
  60848. };
  60849. }
  60850. }
  60851. declare module BABYLON {
  60852. /** Defines the cross module used constants to avoid circular dependncies */
  60853. export class Constants {
  60854. /** Defines that alpha blending is disabled */
  60855. static readonly ALPHA_DISABLE: number;
  60856. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  60857. static readonly ALPHA_ADD: number;
  60858. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  60859. static readonly ALPHA_COMBINE: number;
  60860. /** Defines that alpha blending to DEST - SRC * DEST */
  60861. static readonly ALPHA_SUBTRACT: number;
  60862. /** Defines that alpha blending to SRC * DEST */
  60863. static readonly ALPHA_MULTIPLY: number;
  60864. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  60865. static readonly ALPHA_MAXIMIZED: number;
  60866. /** Defines that alpha blending to SRC + DEST */
  60867. static readonly ALPHA_ONEONE: number;
  60868. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  60869. static readonly ALPHA_PREMULTIPLIED: number;
  60870. /**
  60871. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  60872. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  60873. */
  60874. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  60875. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  60876. static readonly ALPHA_INTERPOLATE: number;
  60877. /**
  60878. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  60879. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  60880. */
  60881. static readonly ALPHA_SCREENMODE: number;
  60882. /** Defines that the ressource is not delayed*/
  60883. static readonly DELAYLOADSTATE_NONE: number;
  60884. /** Defines that the ressource was successfully delay loaded */
  60885. static readonly DELAYLOADSTATE_LOADED: number;
  60886. /** Defines that the ressource is currently delay loading */
  60887. static readonly DELAYLOADSTATE_LOADING: number;
  60888. /** Defines that the ressource is delayed and has not started loading */
  60889. static readonly DELAYLOADSTATE_NOTLOADED: number;
  60890. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  60891. static readonly NEVER: number;
  60892. /** 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 */
  60893. static readonly ALWAYS: number;
  60894. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  60895. static readonly LESS: number;
  60896. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  60897. static readonly EQUAL: number;
  60898. /** 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 */
  60899. static readonly LEQUAL: number;
  60900. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  60901. static readonly GREATER: number;
  60902. /** 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 */
  60903. static readonly GEQUAL: number;
  60904. /** 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 */
  60905. static readonly NOTEQUAL: number;
  60906. /** Passed to stencilOperation to specify that stencil value must be kept */
  60907. static readonly KEEP: number;
  60908. /** Passed to stencilOperation to specify that stencil value must be replaced */
  60909. static readonly REPLACE: number;
  60910. /** Passed to stencilOperation to specify that stencil value must be incremented */
  60911. static readonly INCR: number;
  60912. /** Passed to stencilOperation to specify that stencil value must be decremented */
  60913. static readonly DECR: number;
  60914. /** Passed to stencilOperation to specify that stencil value must be inverted */
  60915. static readonly INVERT: number;
  60916. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  60917. static readonly INCR_WRAP: number;
  60918. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  60919. static readonly DECR_WRAP: number;
  60920. /** Texture is not repeating outside of 0..1 UVs */
  60921. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  60922. /** Texture is repeating outside of 0..1 UVs */
  60923. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  60924. /** Texture is repeating and mirrored */
  60925. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  60926. /** ALPHA */
  60927. static readonly TEXTUREFORMAT_ALPHA: number;
  60928. /** LUMINANCE */
  60929. static readonly TEXTUREFORMAT_LUMINANCE: number;
  60930. /** LUMINANCE_ALPHA */
  60931. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  60932. /** RGB */
  60933. static readonly TEXTUREFORMAT_RGB: number;
  60934. /** RGBA */
  60935. static readonly TEXTUREFORMAT_RGBA: number;
  60936. /** RED */
  60937. static readonly TEXTUREFORMAT_RED: number;
  60938. /** RED (2nd reference) */
  60939. static readonly TEXTUREFORMAT_R: number;
  60940. /** RG */
  60941. static readonly TEXTUREFORMAT_RG: number;
  60942. /** RED_INTEGER */
  60943. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  60944. /** RED_INTEGER (2nd reference) */
  60945. static readonly TEXTUREFORMAT_R_INTEGER: number;
  60946. /** RG_INTEGER */
  60947. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  60948. /** RGB_INTEGER */
  60949. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  60950. /** RGBA_INTEGER */
  60951. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  60952. /** UNSIGNED_BYTE */
  60953. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  60954. /** UNSIGNED_BYTE (2nd reference) */
  60955. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  60956. /** FLOAT */
  60957. static readonly TEXTURETYPE_FLOAT: number;
  60958. /** HALF_FLOAT */
  60959. static readonly TEXTURETYPE_HALF_FLOAT: number;
  60960. /** BYTE */
  60961. static readonly TEXTURETYPE_BYTE: number;
  60962. /** SHORT */
  60963. static readonly TEXTURETYPE_SHORT: number;
  60964. /** UNSIGNED_SHORT */
  60965. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  60966. /** INT */
  60967. static readonly TEXTURETYPE_INT: number;
  60968. /** UNSIGNED_INT */
  60969. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  60970. /** UNSIGNED_SHORT_4_4_4_4 */
  60971. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  60972. /** UNSIGNED_SHORT_5_5_5_1 */
  60973. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  60974. /** UNSIGNED_SHORT_5_6_5 */
  60975. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  60976. /** UNSIGNED_INT_2_10_10_10_REV */
  60977. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  60978. /** UNSIGNED_INT_24_8 */
  60979. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  60980. /** UNSIGNED_INT_10F_11F_11F_REV */
  60981. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  60982. /** UNSIGNED_INT_5_9_9_9_REV */
  60983. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  60984. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  60985. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  60986. /** nearest is mag = nearest and min = nearest and mip = linear */
  60987. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  60988. /** Bilinear is mag = linear and min = linear and mip = nearest */
  60989. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  60990. /** Trilinear is mag = linear and min = linear and mip = linear */
  60991. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  60992. /** nearest is mag = nearest and min = nearest and mip = linear */
  60993. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  60994. /** Bilinear is mag = linear and min = linear and mip = nearest */
  60995. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  60996. /** Trilinear is mag = linear and min = linear and mip = linear */
  60997. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  60998. /** mag = nearest and min = nearest and mip = nearest */
  60999. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  61000. /** mag = nearest and min = linear and mip = nearest */
  61001. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  61002. /** mag = nearest and min = linear and mip = linear */
  61003. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  61004. /** mag = nearest and min = linear and mip = none */
  61005. static readonly TEXTURE_NEAREST_LINEAR: number;
  61006. /** mag = nearest and min = nearest and mip = none */
  61007. static readonly TEXTURE_NEAREST_NEAREST: number;
  61008. /** mag = linear and min = nearest and mip = nearest */
  61009. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  61010. /** mag = linear and min = nearest and mip = linear */
  61011. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  61012. /** mag = linear and min = linear and mip = none */
  61013. static readonly TEXTURE_LINEAR_LINEAR: number;
  61014. /** mag = linear and min = nearest and mip = none */
  61015. static readonly TEXTURE_LINEAR_NEAREST: number;
  61016. /** Explicit coordinates mode */
  61017. static readonly TEXTURE_EXPLICIT_MODE: number;
  61018. /** Spherical coordinates mode */
  61019. static readonly TEXTURE_SPHERICAL_MODE: number;
  61020. /** Planar coordinates mode */
  61021. static readonly TEXTURE_PLANAR_MODE: number;
  61022. /** Cubic coordinates mode */
  61023. static readonly TEXTURE_CUBIC_MODE: number;
  61024. /** Projection coordinates mode */
  61025. static readonly TEXTURE_PROJECTION_MODE: number;
  61026. /** Skybox coordinates mode */
  61027. static readonly TEXTURE_SKYBOX_MODE: number;
  61028. /** Inverse Cubic coordinates mode */
  61029. static readonly TEXTURE_INVCUBIC_MODE: number;
  61030. /** Equirectangular coordinates mode */
  61031. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  61032. /** Equirectangular Fixed coordinates mode */
  61033. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  61034. /** Equirectangular Fixed Mirrored coordinates mode */
  61035. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  61036. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  61037. static readonly SCALEMODE_FLOOR: number;
  61038. /** Defines that texture rescaling will look for the nearest power of 2 size */
  61039. static readonly SCALEMODE_NEAREST: number;
  61040. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  61041. static readonly SCALEMODE_CEILING: number;
  61042. /**
  61043. * The dirty texture flag value
  61044. */
  61045. static readonly MATERIAL_TextureDirtyFlag: number;
  61046. /**
  61047. * The dirty light flag value
  61048. */
  61049. static readonly MATERIAL_LightDirtyFlag: number;
  61050. /**
  61051. * The dirty fresnel flag value
  61052. */
  61053. static readonly MATERIAL_FresnelDirtyFlag: number;
  61054. /**
  61055. * The dirty attribute flag value
  61056. */
  61057. static readonly MATERIAL_AttributesDirtyFlag: number;
  61058. /**
  61059. * The dirty misc flag value
  61060. */
  61061. static readonly MATERIAL_MiscDirtyFlag: number;
  61062. /**
  61063. * The all dirty flag value
  61064. */
  61065. static readonly MATERIAL_AllDirtyFlag: number;
  61066. /**
  61067. * Returns the triangle fill mode
  61068. */
  61069. static readonly MATERIAL_TriangleFillMode: number;
  61070. /**
  61071. * Returns the wireframe mode
  61072. */
  61073. static readonly MATERIAL_WireFrameFillMode: number;
  61074. /**
  61075. * Returns the point fill mode
  61076. */
  61077. static readonly MATERIAL_PointFillMode: number;
  61078. /**
  61079. * Returns the point list draw mode
  61080. */
  61081. static readonly MATERIAL_PointListDrawMode: number;
  61082. /**
  61083. * Returns the line list draw mode
  61084. */
  61085. static readonly MATERIAL_LineListDrawMode: number;
  61086. /**
  61087. * Returns the line loop draw mode
  61088. */
  61089. static readonly MATERIAL_LineLoopDrawMode: number;
  61090. /**
  61091. * Returns the line strip draw mode
  61092. */
  61093. static readonly MATERIAL_LineStripDrawMode: number;
  61094. /**
  61095. * Returns the triangle strip draw mode
  61096. */
  61097. static readonly MATERIAL_TriangleStripDrawMode: number;
  61098. /**
  61099. * Returns the triangle fan draw mode
  61100. */
  61101. static readonly MATERIAL_TriangleFanDrawMode: number;
  61102. /**
  61103. * Stores the clock-wise side orientation
  61104. */
  61105. static readonly MATERIAL_ClockWiseSideOrientation: number;
  61106. /**
  61107. * Stores the counter clock-wise side orientation
  61108. */
  61109. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  61110. /**
  61111. * Nothing
  61112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61113. */
  61114. static readonly ACTION_NothingTrigger: number;
  61115. /**
  61116. * On pick
  61117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61118. */
  61119. static readonly ACTION_OnPickTrigger: number;
  61120. /**
  61121. * On left pick
  61122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61123. */
  61124. static readonly ACTION_OnLeftPickTrigger: number;
  61125. /**
  61126. * On right pick
  61127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61128. */
  61129. static readonly ACTION_OnRightPickTrigger: number;
  61130. /**
  61131. * On center pick
  61132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61133. */
  61134. static readonly ACTION_OnCenterPickTrigger: number;
  61135. /**
  61136. * On pick down
  61137. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61138. */
  61139. static readonly ACTION_OnPickDownTrigger: number;
  61140. /**
  61141. * On double pick
  61142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61143. */
  61144. static readonly ACTION_OnDoublePickTrigger: number;
  61145. /**
  61146. * On pick up
  61147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61148. */
  61149. static readonly ACTION_OnPickUpTrigger: number;
  61150. /**
  61151. * On pick out.
  61152. * This trigger will only be raised if you also declared a OnPickDown
  61153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61154. */
  61155. static readonly ACTION_OnPickOutTrigger: number;
  61156. /**
  61157. * On long press
  61158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61159. */
  61160. static readonly ACTION_OnLongPressTrigger: number;
  61161. /**
  61162. * On pointer over
  61163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61164. */
  61165. static readonly ACTION_OnPointerOverTrigger: number;
  61166. /**
  61167. * On pointer out
  61168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61169. */
  61170. static readonly ACTION_OnPointerOutTrigger: number;
  61171. /**
  61172. * On every frame
  61173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61174. */
  61175. static readonly ACTION_OnEveryFrameTrigger: number;
  61176. /**
  61177. * On intersection enter
  61178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61179. */
  61180. static readonly ACTION_OnIntersectionEnterTrigger: number;
  61181. /**
  61182. * On intersection exit
  61183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61184. */
  61185. static readonly ACTION_OnIntersectionExitTrigger: number;
  61186. /**
  61187. * On key down
  61188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61189. */
  61190. static readonly ACTION_OnKeyDownTrigger: number;
  61191. /**
  61192. * On key up
  61193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61194. */
  61195. static readonly ACTION_OnKeyUpTrigger: number;
  61196. /**
  61197. * Billboard mode will only apply to Y axis
  61198. */
  61199. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  61200. /**
  61201. * Billboard mode will apply to all axes
  61202. */
  61203. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  61204. /**
  61205. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  61206. */
  61207. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  61208. /**
  61209. * Gets or sets base Assets URL
  61210. */
  61211. static readonly PARTICLES_BaseAssetsUrl: string;
  61212. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  61213. * Test order :
  61214. * Is the bounding sphere outside the frustum ?
  61215. * If not, are the bounding box vertices outside the frustum ?
  61216. * It not, then the cullable object is in the frustum.
  61217. */
  61218. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  61219. /** Culling strategy : Bounding Sphere Only.
  61220. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  61221. * It's also less accurate than the standard because some not visible objects can still be selected.
  61222. * Test : is the bounding sphere outside the frustum ?
  61223. * If not, then the cullable object is in the frustum.
  61224. */
  61225. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  61226. /** Culling strategy : Optimistic Inclusion.
  61227. * This in an inclusion test first, then the standard exclusion test.
  61228. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  61229. * 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.
  61230. * Anyway, it's as accurate as the standard strategy.
  61231. * Test :
  61232. * Is the cullable object bounding sphere center in the frustum ?
  61233. * If not, apply the default culling strategy.
  61234. */
  61235. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  61236. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  61237. * This in an inclusion test first, then the bounding sphere only exclusion test.
  61238. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  61239. * 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.
  61240. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  61241. * Test :
  61242. * Is the cullable object bounding sphere center in the frustum ?
  61243. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  61244. */
  61245. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  61246. /**
  61247. * No logging while loading
  61248. */
  61249. static readonly SCENELOADER_NO_LOGGING: number;
  61250. /**
  61251. * Minimal logging while loading
  61252. */
  61253. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  61254. /**
  61255. * Summary logging while loading
  61256. */
  61257. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  61258. /**
  61259. * Detailled logging while loading
  61260. */
  61261. static readonly SCENELOADER_DETAILED_LOGGING: number;
  61262. }
  61263. }
  61264. declare module BABYLON {
  61265. /**
  61266. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  61267. * Babylon.js
  61268. */
  61269. export class DomManagement {
  61270. /**
  61271. * Checks if the window object exists
  61272. * @returns true if the window object exists
  61273. */
  61274. static IsWindowObjectExist(): boolean;
  61275. /**
  61276. * Extracts text content from a DOM element hierarchy
  61277. * @param element defines the root element
  61278. * @returns a string
  61279. */
  61280. static GetDOMTextContent(element: HTMLElement): string;
  61281. }
  61282. }
  61283. declare module BABYLON {
  61284. /**
  61285. * Logger used througouht the application to allow configuration of
  61286. * the log level required for the messages.
  61287. */
  61288. export class Logger {
  61289. /**
  61290. * No log
  61291. */
  61292. static readonly NoneLogLevel: number;
  61293. /**
  61294. * Only message logs
  61295. */
  61296. static readonly MessageLogLevel: number;
  61297. /**
  61298. * Only warning logs
  61299. */
  61300. static readonly WarningLogLevel: number;
  61301. /**
  61302. * Only error logs
  61303. */
  61304. static readonly ErrorLogLevel: number;
  61305. /**
  61306. * All logs
  61307. */
  61308. static readonly AllLogLevel: number;
  61309. private static _LogCache;
  61310. /**
  61311. * Gets a value indicating the number of loading errors
  61312. * @ignorenaming
  61313. */
  61314. static errorsCount: number;
  61315. /**
  61316. * Callback called when a new log is added
  61317. */
  61318. static OnNewCacheEntry: (entry: string) => void;
  61319. private static _AddLogEntry;
  61320. private static _FormatMessage;
  61321. private static _LogDisabled;
  61322. private static _LogEnabled;
  61323. private static _WarnDisabled;
  61324. private static _WarnEnabled;
  61325. private static _ErrorDisabled;
  61326. private static _ErrorEnabled;
  61327. /**
  61328. * Log a message to the console
  61329. */
  61330. static Log: (message: string) => void;
  61331. /**
  61332. * Write a warning message to the console
  61333. */
  61334. static Warn: (message: string) => void;
  61335. /**
  61336. * Write an error message to the console
  61337. */
  61338. static Error: (message: string) => void;
  61339. /**
  61340. * Gets current log cache (list of logs)
  61341. */
  61342. static readonly LogCache: string;
  61343. /**
  61344. * Clears the log cache
  61345. */
  61346. static ClearLogCache(): void;
  61347. /**
  61348. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  61349. */
  61350. static LogLevels: number;
  61351. }
  61352. }
  61353. declare module BABYLON {
  61354. /** @hidden */
  61355. export class _TypeStore {
  61356. /** @hidden */
  61357. static RegisteredTypes: {
  61358. [key: string]: Object;
  61359. };
  61360. /** @hidden */
  61361. static GetClass(fqdn: string): any;
  61362. }
  61363. }
  61364. declare module BABYLON {
  61365. /**
  61366. * Class containing a set of static utilities functions for deep copy.
  61367. */
  61368. export class DeepCopier {
  61369. /**
  61370. * Tries to copy an object by duplicating every property
  61371. * @param source defines the source object
  61372. * @param destination defines the target object
  61373. * @param doNotCopyList defines a list of properties to avoid
  61374. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  61375. */
  61376. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  61377. }
  61378. }
  61379. declare module BABYLON {
  61380. /**
  61381. * Class containing a set of static utilities functions for precision date
  61382. */
  61383. export class PrecisionDate {
  61384. /**
  61385. * Gets either window.performance.now() if supported or Date.now() else
  61386. */
  61387. static readonly Now: number;
  61388. }
  61389. }
  61390. declare module BABYLON {
  61391. /** @hidden */
  61392. export class _DevTools {
  61393. static WarnImport(name: string): string;
  61394. }
  61395. }
  61396. declare module BABYLON {
  61397. /**
  61398. * Class used to evalaute queries containing `and` and `or` operators
  61399. */
  61400. export class AndOrNotEvaluator {
  61401. /**
  61402. * Evaluate a query
  61403. * @param query defines the query to evaluate
  61404. * @param evaluateCallback defines the callback used to filter result
  61405. * @returns true if the query matches
  61406. */
  61407. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  61408. private static _HandleParenthesisContent;
  61409. private static _SimplifyNegation;
  61410. }
  61411. }
  61412. declare module BABYLON {
  61413. /**
  61414. * Class used to store custom tags
  61415. */
  61416. export class Tags {
  61417. /**
  61418. * Adds support for tags on the given object
  61419. * @param obj defines the object to use
  61420. */
  61421. static EnableFor(obj: any): void;
  61422. /**
  61423. * Removes tags support
  61424. * @param obj defines the object to use
  61425. */
  61426. static DisableFor(obj: any): void;
  61427. /**
  61428. * Gets a boolean indicating if the given object has tags
  61429. * @param obj defines the object to use
  61430. * @returns a boolean
  61431. */
  61432. static HasTags(obj: any): boolean;
  61433. /**
  61434. * Gets the tags available on a given object
  61435. * @param obj defines the object to use
  61436. * @param asString defines if the tags must be returned as a string instead of an array of strings
  61437. * @returns the tags
  61438. */
  61439. static GetTags(obj: any, asString?: boolean): any;
  61440. /**
  61441. * Adds tags to an object
  61442. * @param obj defines the object to use
  61443. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  61444. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  61445. */
  61446. static AddTagsTo(obj: any, tagsString: string): void;
  61447. /**
  61448. * @hidden
  61449. */
  61450. static _AddTagTo(obj: any, tag: string): void;
  61451. /**
  61452. * Removes specific tags from a specific object
  61453. * @param obj defines the object to use
  61454. * @param tagsString defines the tags to remove
  61455. */
  61456. static RemoveTagsFrom(obj: any, tagsString: string): void;
  61457. /**
  61458. * @hidden
  61459. */
  61460. static _RemoveTagFrom(obj: any, tag: string): void;
  61461. /**
  61462. * Defines if tags hosted on an object match a given query
  61463. * @param obj defines the object to use
  61464. * @param tagsQuery defines the tag query
  61465. * @returns a boolean
  61466. */
  61467. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  61468. }
  61469. }
  61470. declare module BABYLON {
  61471. /**
  61472. * Manages the defines for the Material
  61473. */
  61474. export class MaterialDefines {
  61475. private _keys;
  61476. private _isDirty;
  61477. /** @hidden */
  61478. _renderId: number;
  61479. /** @hidden */
  61480. _areLightsDirty: boolean;
  61481. /** @hidden */
  61482. _areAttributesDirty: boolean;
  61483. /** @hidden */
  61484. _areTexturesDirty: boolean;
  61485. /** @hidden */
  61486. _areFresnelDirty: boolean;
  61487. /** @hidden */
  61488. _areMiscDirty: boolean;
  61489. /** @hidden */
  61490. _areImageProcessingDirty: boolean;
  61491. /** @hidden */
  61492. _normals: boolean;
  61493. /** @hidden */
  61494. _uvs: boolean;
  61495. /** @hidden */
  61496. _needNormals: boolean;
  61497. /** @hidden */
  61498. _needUVs: boolean;
  61499. /**
  61500. * Specifies if the material needs to be re-calculated
  61501. */
  61502. readonly isDirty: boolean;
  61503. /**
  61504. * Marks the material to indicate that it has been re-calculated
  61505. */
  61506. markAsProcessed(): void;
  61507. /**
  61508. * Marks the material to indicate that it needs to be re-calculated
  61509. */
  61510. markAsUnprocessed(): void;
  61511. /**
  61512. * Marks the material to indicate all of its defines need to be re-calculated
  61513. */
  61514. markAllAsDirty(): void;
  61515. /**
  61516. * Marks the material to indicate that image processing needs to be re-calculated
  61517. */
  61518. markAsImageProcessingDirty(): void;
  61519. /**
  61520. * Marks the material to indicate the lights need to be re-calculated
  61521. */
  61522. markAsLightDirty(): void;
  61523. /**
  61524. * Marks the attribute state as changed
  61525. */
  61526. markAsAttributesDirty(): void;
  61527. /**
  61528. * Marks the texture state as changed
  61529. */
  61530. markAsTexturesDirty(): void;
  61531. /**
  61532. * Marks the fresnel state as changed
  61533. */
  61534. markAsFresnelDirty(): void;
  61535. /**
  61536. * Marks the misc state as changed
  61537. */
  61538. markAsMiscDirty(): void;
  61539. /**
  61540. * Rebuilds the material defines
  61541. */
  61542. rebuild(): void;
  61543. /**
  61544. * Specifies if two material defines are equal
  61545. * @param other - A material define instance to compare to
  61546. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  61547. */
  61548. isEqual(other: MaterialDefines): boolean;
  61549. /**
  61550. * Clones this instance's defines to another instance
  61551. * @param other - material defines to clone values to
  61552. */
  61553. cloneTo(other: MaterialDefines): void;
  61554. /**
  61555. * Resets the material define values
  61556. */
  61557. reset(): void;
  61558. /**
  61559. * Converts the material define values to a string
  61560. * @returns - String of material define information
  61561. */
  61562. toString(): string;
  61563. }
  61564. }
  61565. declare module BABYLON {
  61566. /**
  61567. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  61568. */
  61569. export class PerformanceMonitor {
  61570. private _enabled;
  61571. private _rollingFrameTime;
  61572. private _lastFrameTimeMs;
  61573. /**
  61574. * constructor
  61575. * @param frameSampleSize The number of samples required to saturate the sliding window
  61576. */
  61577. constructor(frameSampleSize?: number);
  61578. /**
  61579. * Samples current frame
  61580. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  61581. */
  61582. sampleFrame(timeMs?: number): void;
  61583. /**
  61584. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  61585. */
  61586. readonly averageFrameTime: number;
  61587. /**
  61588. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  61589. */
  61590. readonly averageFrameTimeVariance: number;
  61591. /**
  61592. * Returns the frame time of the most recent frame
  61593. */
  61594. readonly instantaneousFrameTime: number;
  61595. /**
  61596. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  61597. */
  61598. readonly averageFPS: number;
  61599. /**
  61600. * Returns the average framerate in frames per second using the most recent frame time
  61601. */
  61602. readonly instantaneousFPS: number;
  61603. /**
  61604. * Returns true if enough samples have been taken to completely fill the sliding window
  61605. */
  61606. readonly isSaturated: boolean;
  61607. /**
  61608. * Enables contributions to the sliding window sample set
  61609. */
  61610. enable(): void;
  61611. /**
  61612. * Disables contributions to the sliding window sample set
  61613. * Samples will not be interpolated over the disabled period
  61614. */
  61615. disable(): void;
  61616. /**
  61617. * Returns true if sampling is enabled
  61618. */
  61619. readonly isEnabled: boolean;
  61620. /**
  61621. * Resets performance monitor
  61622. */
  61623. reset(): void;
  61624. }
  61625. /**
  61626. * RollingAverage
  61627. *
  61628. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  61629. */
  61630. export class RollingAverage {
  61631. /**
  61632. * Current average
  61633. */
  61634. average: number;
  61635. /**
  61636. * Current variance
  61637. */
  61638. variance: number;
  61639. protected _samples: Array<number>;
  61640. protected _sampleCount: number;
  61641. protected _pos: number;
  61642. protected _m2: number;
  61643. /**
  61644. * constructor
  61645. * @param length The number of samples required to saturate the sliding window
  61646. */
  61647. constructor(length: number);
  61648. /**
  61649. * Adds a sample to the sample set
  61650. * @param v The sample value
  61651. */
  61652. add(v: number): void;
  61653. /**
  61654. * Returns previously added values or null if outside of history or outside the sliding window domain
  61655. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  61656. * @return Value previously recorded with add() or null if outside of range
  61657. */
  61658. history(i: number): number;
  61659. /**
  61660. * Returns true if enough samples have been taken to completely fill the sliding window
  61661. * @return true if sample-set saturated
  61662. */
  61663. isSaturated(): boolean;
  61664. /**
  61665. * Resets the rolling average (equivalent to 0 samples taken so far)
  61666. */
  61667. reset(): void;
  61668. /**
  61669. * Wraps a value around the sample range boundaries
  61670. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  61671. * @return Wrapped position in sample range
  61672. */
  61673. protected _wrapPosition(i: number): number;
  61674. }
  61675. }
  61676. declare module BABYLON {
  61677. /**
  61678. * This class implement a typical dictionary using a string as key and the generic type T as value.
  61679. * The underlying implementation relies on an associative array to ensure the best performances.
  61680. * The value can be anything including 'null' but except 'undefined'
  61681. */
  61682. export class StringDictionary<T> {
  61683. /**
  61684. * This will clear this dictionary and copy the content from the 'source' one.
  61685. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  61686. * @param source the dictionary to take the content from and copy to this dictionary
  61687. */
  61688. copyFrom(source: StringDictionary<T>): void;
  61689. /**
  61690. * Get a value based from its key
  61691. * @param key the given key to get the matching value from
  61692. * @return the value if found, otherwise undefined is returned
  61693. */
  61694. get(key: string): T | undefined;
  61695. /**
  61696. * Get a value from its key or add it if it doesn't exist.
  61697. * This method will ensure you that a given key/data will be present in the dictionary.
  61698. * @param key the given key to get the matching value from
  61699. * @param factory the factory that will create the value if the key is not present in the dictionary.
  61700. * The factory will only be invoked if there's no data for the given key.
  61701. * @return the value corresponding to the key.
  61702. */
  61703. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  61704. /**
  61705. * Get a value from its key if present in the dictionary otherwise add it
  61706. * @param key the key to get the value from
  61707. * @param val if there's no such key/value pair in the dictionary add it with this value
  61708. * @return the value corresponding to the key
  61709. */
  61710. getOrAdd(key: string, val: T): T;
  61711. /**
  61712. * Check if there's a given key in the dictionary
  61713. * @param key the key to check for
  61714. * @return true if the key is present, false otherwise
  61715. */
  61716. contains(key: string): boolean;
  61717. /**
  61718. * Add a new key and its corresponding value
  61719. * @param key the key to add
  61720. * @param value the value corresponding to the key
  61721. * @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
  61722. */
  61723. add(key: string, value: T): boolean;
  61724. /**
  61725. * Update a specific value associated to a key
  61726. * @param key defines the key to use
  61727. * @param value defines the value to store
  61728. * @returns true if the value was updated (or false if the key was not found)
  61729. */
  61730. set(key: string, value: T): boolean;
  61731. /**
  61732. * Get the element of the given key and remove it from the dictionary
  61733. * @param key defines the key to search
  61734. * @returns the value associated with the key or null if not found
  61735. */
  61736. getAndRemove(key: string): Nullable<T>;
  61737. /**
  61738. * Remove a key/value from the dictionary.
  61739. * @param key the key to remove
  61740. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  61741. */
  61742. remove(key: string): boolean;
  61743. /**
  61744. * Clear the whole content of the dictionary
  61745. */
  61746. clear(): void;
  61747. /**
  61748. * Gets the current count
  61749. */
  61750. readonly count: number;
  61751. /**
  61752. * Execute a callback on each key/val of the dictionary.
  61753. * Note that you can remove any element in this dictionary in the callback implementation
  61754. * @param callback the callback to execute on a given key/value pair
  61755. */
  61756. forEach(callback: (key: string, val: T) => void): void;
  61757. /**
  61758. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  61759. * If the callback returns null or undefined the method will iterate to the next key/value pair
  61760. * Note that you can remove any element in this dictionary in the callback implementation
  61761. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  61762. * @returns the first item
  61763. */
  61764. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  61765. private _count;
  61766. private _data;
  61767. }
  61768. }
  61769. declare module BABYLON {
  61770. /**
  61771. * Helper class that provides a small promise polyfill
  61772. */
  61773. export class PromisePolyfill {
  61774. /**
  61775. * Static function used to check if the polyfill is required
  61776. * If this is the case then the function will inject the polyfill to window.Promise
  61777. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  61778. */
  61779. static Apply(force?: boolean): void;
  61780. }
  61781. }
  61782. declare module BABYLON {
  61783. /**
  61784. * Class used to store data that will be store in GPU memory
  61785. */
  61786. export class Buffer {
  61787. private _engine;
  61788. private _buffer;
  61789. /** @hidden */
  61790. _data: Nullable<DataArray>;
  61791. private _updatable;
  61792. private _instanced;
  61793. /**
  61794. * Gets the byte stride.
  61795. */
  61796. readonly byteStride: number;
  61797. /**
  61798. * Constructor
  61799. * @param engine the engine
  61800. * @param data the data to use for this buffer
  61801. * @param updatable whether the data is updatable
  61802. * @param stride the stride (optional)
  61803. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  61804. * @param instanced whether the buffer is instanced (optional)
  61805. * @param useBytes set to true if the stride in in bytes (optional)
  61806. */
  61807. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  61808. /**
  61809. * Create a new VertexBuffer based on the current buffer
  61810. * @param kind defines the vertex buffer kind (position, normal, etc.)
  61811. * @param offset defines offset in the buffer (0 by default)
  61812. * @param size defines the size in floats of attributes (position is 3 for instance)
  61813. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  61814. * @param instanced defines if the vertex buffer contains indexed data
  61815. * @param useBytes defines if the offset and stride are in bytes
  61816. * @returns the new vertex buffer
  61817. */
  61818. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  61819. /**
  61820. * Gets a boolean indicating if the Buffer is updatable?
  61821. * @returns true if the buffer is updatable
  61822. */
  61823. isUpdatable(): boolean;
  61824. /**
  61825. * Gets current buffer's data
  61826. * @returns a DataArray or null
  61827. */
  61828. getData(): Nullable<DataArray>;
  61829. /**
  61830. * Gets underlying native buffer
  61831. * @returns underlying native buffer
  61832. */
  61833. getBuffer(): Nullable<WebGLBuffer>;
  61834. /**
  61835. * Gets the stride in float32 units (i.e. byte stride / 4).
  61836. * May not be an integer if the byte stride is not divisible by 4.
  61837. * DEPRECATED. Use byteStride instead.
  61838. * @returns the stride in float32 units
  61839. */
  61840. getStrideSize(): number;
  61841. /**
  61842. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  61843. * @param data defines the data to store
  61844. */
  61845. create(data?: Nullable<DataArray>): void;
  61846. /** @hidden */
  61847. _rebuild(): void;
  61848. /**
  61849. * Update current buffer data
  61850. * @param data defines the data to store
  61851. */
  61852. update(data: DataArray): void;
  61853. /**
  61854. * Updates the data directly.
  61855. * @param data the new data
  61856. * @param offset the new offset
  61857. * @param vertexCount the vertex count (optional)
  61858. * @param useBytes set to true if the offset is in bytes
  61859. */
  61860. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  61861. /**
  61862. * Release all resources
  61863. */
  61864. dispose(): void;
  61865. }
  61866. /**
  61867. * Specialized buffer used to store vertex data
  61868. */
  61869. export class VertexBuffer {
  61870. /** @hidden */
  61871. _buffer: Buffer;
  61872. private _kind;
  61873. private _size;
  61874. private _ownsBuffer;
  61875. private _instanced;
  61876. private _instanceDivisor;
  61877. /**
  61878. * The byte type.
  61879. */
  61880. static readonly BYTE: number;
  61881. /**
  61882. * The unsigned byte type.
  61883. */
  61884. static readonly UNSIGNED_BYTE: number;
  61885. /**
  61886. * The short type.
  61887. */
  61888. static readonly SHORT: number;
  61889. /**
  61890. * The unsigned short type.
  61891. */
  61892. static readonly UNSIGNED_SHORT: number;
  61893. /**
  61894. * The integer type.
  61895. */
  61896. static readonly INT: number;
  61897. /**
  61898. * The unsigned integer type.
  61899. */
  61900. static readonly UNSIGNED_INT: number;
  61901. /**
  61902. * The float type.
  61903. */
  61904. static readonly FLOAT: number;
  61905. /**
  61906. * Gets or sets the instance divisor when in instanced mode
  61907. */
  61908. instanceDivisor: number;
  61909. /**
  61910. * Gets the byte stride.
  61911. */
  61912. readonly byteStride: number;
  61913. /**
  61914. * Gets the byte offset.
  61915. */
  61916. readonly byteOffset: number;
  61917. /**
  61918. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  61919. */
  61920. readonly normalized: boolean;
  61921. /**
  61922. * Gets the data type of each component in the array.
  61923. */
  61924. readonly type: number;
  61925. /**
  61926. * Constructor
  61927. * @param engine the engine
  61928. * @param data the data to use for this vertex buffer
  61929. * @param kind the vertex buffer kind
  61930. * @param updatable whether the data is updatable
  61931. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  61932. * @param stride the stride (optional)
  61933. * @param instanced whether the buffer is instanced (optional)
  61934. * @param offset the offset of the data (optional)
  61935. * @param size the number of components (optional)
  61936. * @param type the type of the component (optional)
  61937. * @param normalized whether the data contains normalized data (optional)
  61938. * @param useBytes set to true if stride and offset are in bytes (optional)
  61939. */
  61940. 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);
  61941. /** @hidden */
  61942. _rebuild(): void;
  61943. /**
  61944. * Returns the kind of the VertexBuffer (string)
  61945. * @returns a string
  61946. */
  61947. getKind(): string;
  61948. /**
  61949. * Gets a boolean indicating if the VertexBuffer is updatable?
  61950. * @returns true if the buffer is updatable
  61951. */
  61952. isUpdatable(): boolean;
  61953. /**
  61954. * Gets current buffer's data
  61955. * @returns a DataArray or null
  61956. */
  61957. getData(): Nullable<DataArray>;
  61958. /**
  61959. * Gets underlying native buffer
  61960. * @returns underlying native buffer
  61961. */
  61962. getBuffer(): Nullable<WebGLBuffer>;
  61963. /**
  61964. * Gets the stride in float32 units (i.e. byte stride / 4).
  61965. * May not be an integer if the byte stride is not divisible by 4.
  61966. * DEPRECATED. Use byteStride instead.
  61967. * @returns the stride in float32 units
  61968. */
  61969. getStrideSize(): number;
  61970. /**
  61971. * Returns the offset as a multiple of the type byte length.
  61972. * DEPRECATED. Use byteOffset instead.
  61973. * @returns the offset in bytes
  61974. */
  61975. getOffset(): number;
  61976. /**
  61977. * Returns the number of components per vertex attribute (integer)
  61978. * @returns the size in float
  61979. */
  61980. getSize(): number;
  61981. /**
  61982. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  61983. * @returns true if this buffer is instanced
  61984. */
  61985. getIsInstanced(): boolean;
  61986. /**
  61987. * Returns the instancing divisor, zero for non-instanced (integer).
  61988. * @returns a number
  61989. */
  61990. getInstanceDivisor(): number;
  61991. /**
  61992. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  61993. * @param data defines the data to store
  61994. */
  61995. create(data?: DataArray): void;
  61996. /**
  61997. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  61998. * This function will create a new buffer if the current one is not updatable
  61999. * @param data defines the data to store
  62000. */
  62001. update(data: DataArray): void;
  62002. /**
  62003. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  62004. * Returns the directly updated WebGLBuffer.
  62005. * @param data the new data
  62006. * @param offset the new offset
  62007. * @param useBytes set to true if the offset is in bytes
  62008. */
  62009. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  62010. /**
  62011. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  62012. */
  62013. dispose(): void;
  62014. /**
  62015. * Enumerates each value of this vertex buffer as numbers.
  62016. * @param count the number of values to enumerate
  62017. * @param callback the callback function called for each value
  62018. */
  62019. forEach(count: number, callback: (value: number, index: number) => void): void;
  62020. /**
  62021. * Positions
  62022. */
  62023. static readonly PositionKind: string;
  62024. /**
  62025. * Normals
  62026. */
  62027. static readonly NormalKind: string;
  62028. /**
  62029. * Tangents
  62030. */
  62031. static readonly TangentKind: string;
  62032. /**
  62033. * Texture coordinates
  62034. */
  62035. static readonly UVKind: string;
  62036. /**
  62037. * Texture coordinates 2
  62038. */
  62039. static readonly UV2Kind: string;
  62040. /**
  62041. * Texture coordinates 3
  62042. */
  62043. static readonly UV3Kind: string;
  62044. /**
  62045. * Texture coordinates 4
  62046. */
  62047. static readonly UV4Kind: string;
  62048. /**
  62049. * Texture coordinates 5
  62050. */
  62051. static readonly UV5Kind: string;
  62052. /**
  62053. * Texture coordinates 6
  62054. */
  62055. static readonly UV6Kind: string;
  62056. /**
  62057. * Colors
  62058. */
  62059. static readonly ColorKind: string;
  62060. /**
  62061. * Matrix indices (for bones)
  62062. */
  62063. static readonly MatricesIndicesKind: string;
  62064. /**
  62065. * Matrix weights (for bones)
  62066. */
  62067. static readonly MatricesWeightsKind: string;
  62068. /**
  62069. * Additional matrix indices (for bones)
  62070. */
  62071. static readonly MatricesIndicesExtraKind: string;
  62072. /**
  62073. * Additional matrix weights (for bones)
  62074. */
  62075. static readonly MatricesWeightsExtraKind: string;
  62076. /**
  62077. * Deduces the stride given a kind.
  62078. * @param kind The kind string to deduce
  62079. * @returns The deduced stride
  62080. */
  62081. static DeduceStride(kind: string): number;
  62082. /**
  62083. * Gets the byte length of the given type.
  62084. * @param type the type
  62085. * @returns the number of bytes
  62086. */
  62087. static GetTypeByteLength(type: number): number;
  62088. /**
  62089. * Enumerates each value of the given parameters as numbers.
  62090. * @param data the data to enumerate
  62091. * @param byteOffset the byte offset of the data
  62092. * @param byteStride the byte stride of the data
  62093. * @param componentCount the number of components per element
  62094. * @param componentType the type of the component
  62095. * @param count the total number of components
  62096. * @param normalized whether the data is normalized
  62097. * @param callback the callback function called for each value
  62098. */
  62099. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  62100. private static _GetFloatValue;
  62101. }
  62102. }
  62103. declare module BABYLON {
  62104. /**
  62105. * Class representing spherical polynomial coefficients to the 3rd degree
  62106. */
  62107. export class SphericalPolynomial {
  62108. /**
  62109. * The x coefficients of the spherical polynomial
  62110. */
  62111. x: Vector3;
  62112. /**
  62113. * The y coefficients of the spherical polynomial
  62114. */
  62115. y: Vector3;
  62116. /**
  62117. * The z coefficients of the spherical polynomial
  62118. */
  62119. z: Vector3;
  62120. /**
  62121. * The xx coefficients of the spherical polynomial
  62122. */
  62123. xx: Vector3;
  62124. /**
  62125. * The yy coefficients of the spherical polynomial
  62126. */
  62127. yy: Vector3;
  62128. /**
  62129. * The zz coefficients of the spherical polynomial
  62130. */
  62131. zz: Vector3;
  62132. /**
  62133. * The xy coefficients of the spherical polynomial
  62134. */
  62135. xy: Vector3;
  62136. /**
  62137. * The yz coefficients of the spherical polynomial
  62138. */
  62139. yz: Vector3;
  62140. /**
  62141. * The zx coefficients of the spherical polynomial
  62142. */
  62143. zx: Vector3;
  62144. /**
  62145. * Adds an ambient color to the spherical polynomial
  62146. * @param color the color to add
  62147. */
  62148. addAmbient(color: Color3): void;
  62149. /**
  62150. * Scales the spherical polynomial by the given amount
  62151. * @param scale the amount to scale
  62152. */
  62153. scale(scale: number): void;
  62154. /**
  62155. * Gets the spherical polynomial from harmonics
  62156. * @param harmonics the spherical harmonics
  62157. * @returns the spherical polynomial
  62158. */
  62159. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  62160. /**
  62161. * Constructs a spherical polynomial from an array.
  62162. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  62163. * @returns the spherical polynomial
  62164. */
  62165. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  62166. }
  62167. /**
  62168. * Class representing spherical harmonics coefficients to the 3rd degree
  62169. */
  62170. export class SphericalHarmonics {
  62171. /**
  62172. * The l0,0 coefficients of the spherical harmonics
  62173. */
  62174. l00: Vector3;
  62175. /**
  62176. * The l1,-1 coefficients of the spherical harmonics
  62177. */
  62178. l1_1: Vector3;
  62179. /**
  62180. * The l1,0 coefficients of the spherical harmonics
  62181. */
  62182. l10: Vector3;
  62183. /**
  62184. * The l1,1 coefficients of the spherical harmonics
  62185. */
  62186. l11: Vector3;
  62187. /**
  62188. * The l2,-2 coefficients of the spherical harmonics
  62189. */
  62190. l2_2: Vector3;
  62191. /**
  62192. * The l2,-1 coefficients of the spherical harmonics
  62193. */
  62194. l2_1: Vector3;
  62195. /**
  62196. * The l2,0 coefficients of the spherical harmonics
  62197. */
  62198. l20: Vector3;
  62199. /**
  62200. * The l2,1 coefficients of the spherical harmonics
  62201. */
  62202. l21: Vector3;
  62203. /**
  62204. * The l2,2 coefficients of the spherical harmonics
  62205. */
  62206. lL22: Vector3;
  62207. /**
  62208. * Adds a light to the spherical harmonics
  62209. * @param direction the direction of the light
  62210. * @param color the color of the light
  62211. * @param deltaSolidAngle the delta solid angle of the light
  62212. */
  62213. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  62214. /**
  62215. * Scales the spherical harmonics by the given amount
  62216. * @param scale the amount to scale
  62217. */
  62218. scale(scale: number): void;
  62219. /**
  62220. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  62221. *
  62222. * ```
  62223. * E_lm = A_l * L_lm
  62224. * ```
  62225. *
  62226. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  62227. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  62228. * the scaling factors are given in equation 9.
  62229. */
  62230. convertIncidentRadianceToIrradiance(): void;
  62231. /**
  62232. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  62233. *
  62234. * ```
  62235. * L = (1/pi) * E * rho
  62236. * ```
  62237. *
  62238. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  62239. */
  62240. convertIrradianceToLambertianRadiance(): void;
  62241. /**
  62242. * Gets the spherical harmonics from polynomial
  62243. * @param polynomial the spherical polynomial
  62244. * @returns the spherical harmonics
  62245. */
  62246. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  62247. /**
  62248. * Constructs a spherical harmonics from an array.
  62249. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  62250. * @returns the spherical harmonics
  62251. */
  62252. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  62253. }
  62254. }
  62255. declare module BABYLON {
  62256. /**
  62257. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  62258. */
  62259. export interface CubeMapInfo {
  62260. /**
  62261. * The pixel array for the front face.
  62262. * This is stored in format, left to right, up to down format.
  62263. */
  62264. front: Nullable<ArrayBufferView>;
  62265. /**
  62266. * The pixel array for the back face.
  62267. * This is stored in format, left to right, up to down format.
  62268. */
  62269. back: Nullable<ArrayBufferView>;
  62270. /**
  62271. * The pixel array for the left face.
  62272. * This is stored in format, left to right, up to down format.
  62273. */
  62274. left: Nullable<ArrayBufferView>;
  62275. /**
  62276. * The pixel array for the right face.
  62277. * This is stored in format, left to right, up to down format.
  62278. */
  62279. right: Nullable<ArrayBufferView>;
  62280. /**
  62281. * The pixel array for the up face.
  62282. * This is stored in format, left to right, up to down format.
  62283. */
  62284. up: Nullable<ArrayBufferView>;
  62285. /**
  62286. * The pixel array for the down face.
  62287. * This is stored in format, left to right, up to down format.
  62288. */
  62289. down: Nullable<ArrayBufferView>;
  62290. /**
  62291. * The size of the cubemap stored.
  62292. *
  62293. * Each faces will be size * size pixels.
  62294. */
  62295. size: number;
  62296. /**
  62297. * The format of the texture.
  62298. *
  62299. * RGBA, RGB.
  62300. */
  62301. format: number;
  62302. /**
  62303. * The type of the texture data.
  62304. *
  62305. * UNSIGNED_INT, FLOAT.
  62306. */
  62307. type: number;
  62308. /**
  62309. * Specifies whether the texture is in gamma space.
  62310. */
  62311. gammaSpace: boolean;
  62312. }
  62313. /**
  62314. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  62315. */
  62316. export class PanoramaToCubeMapTools {
  62317. private static FACE_FRONT;
  62318. private static FACE_BACK;
  62319. private static FACE_RIGHT;
  62320. private static FACE_LEFT;
  62321. private static FACE_DOWN;
  62322. private static FACE_UP;
  62323. /**
  62324. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  62325. *
  62326. * @param float32Array The source data.
  62327. * @param inputWidth The width of the input panorama.
  62328. * @param inputHeight The height of the input panorama.
  62329. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  62330. * @return The cubemap data
  62331. */
  62332. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  62333. private static CreateCubemapTexture;
  62334. private static CalcProjectionSpherical;
  62335. }
  62336. }
  62337. declare module BABYLON {
  62338. /**
  62339. * Helper class dealing with the extraction of spherical polynomial dataArray
  62340. * from a cube map.
  62341. */
  62342. export class CubeMapToSphericalPolynomialTools {
  62343. private static FileFaces;
  62344. /**
  62345. * Converts a texture to the according Spherical Polynomial data.
  62346. * This extracts the first 3 orders only as they are the only one used in the lighting.
  62347. *
  62348. * @param texture The texture to extract the information from.
  62349. * @return The Spherical Polynomial data.
  62350. */
  62351. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  62352. /**
  62353. * Converts a cubemap to the according Spherical Polynomial data.
  62354. * This extracts the first 3 orders only as they are the only one used in the lighting.
  62355. *
  62356. * @param cubeInfo The Cube map to extract the information from.
  62357. * @return The Spherical Polynomial data.
  62358. */
  62359. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  62360. }
  62361. }
  62362. declare module BABYLON {
  62363. /**
  62364. * The engine store class is responsible to hold all the instances of Engine and Scene created
  62365. * during the life time of the application.
  62366. */
  62367. export class EngineStore {
  62368. /** Gets the list of created engines */
  62369. static Instances: Engine[];
  62370. /**
  62371. * Gets the latest created engine
  62372. */
  62373. static readonly LastCreatedEngine: Nullable<Engine>;
  62374. /**
  62375. * Gets the latest created scene
  62376. */
  62377. static readonly LastCreatedScene: Nullable<Scene>;
  62378. }
  62379. }
  62380. declare module BABYLON {
  62381. /**
  62382. * Define options used to create a render target texture
  62383. */
  62384. export class RenderTargetCreationOptions {
  62385. /**
  62386. * Specifies is mipmaps must be generated
  62387. */
  62388. generateMipMaps?: boolean;
  62389. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  62390. generateDepthBuffer?: boolean;
  62391. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  62392. generateStencilBuffer?: boolean;
  62393. /** Defines texture type (int by default) */
  62394. type?: number;
  62395. /** Defines sampling mode (trilinear by default) */
  62396. samplingMode?: number;
  62397. /** Defines format (RGBA by default) */
  62398. format?: number;
  62399. }
  62400. }
  62401. declare module BABYLON {
  62402. /**
  62403. * @hidden
  62404. **/
  62405. export class _AlphaState {
  62406. private _isAlphaBlendDirty;
  62407. private _isBlendFunctionParametersDirty;
  62408. private _isBlendEquationParametersDirty;
  62409. private _isBlendConstantsDirty;
  62410. private _alphaBlend;
  62411. private _blendFunctionParameters;
  62412. private _blendEquationParameters;
  62413. private _blendConstants;
  62414. /**
  62415. * Initializes the state.
  62416. */
  62417. constructor();
  62418. readonly isDirty: boolean;
  62419. alphaBlend: boolean;
  62420. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  62421. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  62422. setAlphaEquationParameters(rgb: number, alpha: number): void;
  62423. reset(): void;
  62424. apply(gl: WebGLRenderingContext): void;
  62425. }
  62426. }
  62427. declare module BABYLON {
  62428. /**
  62429. * @hidden
  62430. **/
  62431. export class _DepthCullingState {
  62432. private _isDepthTestDirty;
  62433. private _isDepthMaskDirty;
  62434. private _isDepthFuncDirty;
  62435. private _isCullFaceDirty;
  62436. private _isCullDirty;
  62437. private _isZOffsetDirty;
  62438. private _isFrontFaceDirty;
  62439. private _depthTest;
  62440. private _depthMask;
  62441. private _depthFunc;
  62442. private _cull;
  62443. private _cullFace;
  62444. private _zOffset;
  62445. private _frontFace;
  62446. /**
  62447. * Initializes the state.
  62448. */
  62449. constructor();
  62450. readonly isDirty: boolean;
  62451. zOffset: number;
  62452. cullFace: Nullable<number>;
  62453. cull: Nullable<boolean>;
  62454. depthFunc: Nullable<number>;
  62455. depthMask: boolean;
  62456. depthTest: boolean;
  62457. frontFace: Nullable<number>;
  62458. reset(): void;
  62459. apply(gl: WebGLRenderingContext): void;
  62460. }
  62461. }
  62462. declare module BABYLON {
  62463. /**
  62464. * @hidden
  62465. **/
  62466. export class _StencilState {
  62467. /** 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 */
  62468. static readonly ALWAYS: number;
  62469. /** Passed to stencilOperation to specify that stencil value must be kept */
  62470. static readonly KEEP: number;
  62471. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62472. static readonly REPLACE: number;
  62473. private _isStencilTestDirty;
  62474. private _isStencilMaskDirty;
  62475. private _isStencilFuncDirty;
  62476. private _isStencilOpDirty;
  62477. private _stencilTest;
  62478. private _stencilMask;
  62479. private _stencilFunc;
  62480. private _stencilFuncRef;
  62481. private _stencilFuncMask;
  62482. private _stencilOpStencilFail;
  62483. private _stencilOpDepthFail;
  62484. private _stencilOpStencilDepthPass;
  62485. readonly isDirty: boolean;
  62486. stencilFunc: number;
  62487. stencilFuncRef: number;
  62488. stencilFuncMask: number;
  62489. stencilOpStencilFail: number;
  62490. stencilOpDepthFail: number;
  62491. stencilOpStencilDepthPass: number;
  62492. stencilMask: number;
  62493. stencilTest: boolean;
  62494. constructor();
  62495. reset(): void;
  62496. apply(gl: WebGLRenderingContext): void;
  62497. }
  62498. }
  62499. declare module BABYLON {
  62500. /**
  62501. * @hidden
  62502. **/
  62503. export class _TimeToken {
  62504. _startTimeQuery: Nullable<WebGLQuery>;
  62505. _endTimeQuery: Nullable<WebGLQuery>;
  62506. _timeElapsedQuery: Nullable<WebGLQuery>;
  62507. _timeElapsedQueryEnded: boolean;
  62508. }
  62509. }
  62510. declare module BABYLON {
  62511. /**
  62512. * Internal interface used to track InternalTexture already bound to the GL context
  62513. */
  62514. export interface IInternalTextureTracker {
  62515. /**
  62516. * Gets or set the previous tracker in the list
  62517. */
  62518. previous: Nullable<IInternalTextureTracker>;
  62519. /**
  62520. * Gets or set the next tracker in the list
  62521. */
  62522. next: Nullable<IInternalTextureTracker>;
  62523. }
  62524. /**
  62525. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  62526. */
  62527. export class DummyInternalTextureTracker {
  62528. /**
  62529. * Gets or set the previous tracker in the list
  62530. */
  62531. previous: Nullable<IInternalTextureTracker>;
  62532. /**
  62533. * Gets or set the next tracker in the list
  62534. */
  62535. next: Nullable<IInternalTextureTracker>;
  62536. }
  62537. }
  62538. declare module BABYLON {
  62539. /**
  62540. * Class used to store data associated with WebGL texture data for the engine
  62541. * This class should not be used directly
  62542. */
  62543. export class InternalTexture implements IInternalTextureTracker {
  62544. /** hidden */
  62545. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  62546. /**
  62547. * The source of the texture data is unknown
  62548. */
  62549. static DATASOURCE_UNKNOWN: number;
  62550. /**
  62551. * Texture data comes from an URL
  62552. */
  62553. static DATASOURCE_URL: number;
  62554. /**
  62555. * Texture data is only used for temporary storage
  62556. */
  62557. static DATASOURCE_TEMP: number;
  62558. /**
  62559. * Texture data comes from raw data (ArrayBuffer)
  62560. */
  62561. static DATASOURCE_RAW: number;
  62562. /**
  62563. * Texture content is dynamic (video or dynamic texture)
  62564. */
  62565. static DATASOURCE_DYNAMIC: number;
  62566. /**
  62567. * Texture content is generated by rendering to it
  62568. */
  62569. static DATASOURCE_RENDERTARGET: number;
  62570. /**
  62571. * Texture content is part of a multi render target process
  62572. */
  62573. static DATASOURCE_MULTIRENDERTARGET: number;
  62574. /**
  62575. * Texture data comes from a cube data file
  62576. */
  62577. static DATASOURCE_CUBE: number;
  62578. /**
  62579. * Texture data comes from a raw cube data
  62580. */
  62581. static DATASOURCE_CUBERAW: number;
  62582. /**
  62583. * Texture data come from a prefiltered cube data file
  62584. */
  62585. static DATASOURCE_CUBEPREFILTERED: number;
  62586. /**
  62587. * Texture content is raw 3D data
  62588. */
  62589. static DATASOURCE_RAW3D: number;
  62590. /**
  62591. * Texture content is a depth texture
  62592. */
  62593. static DATASOURCE_DEPTHTEXTURE: number;
  62594. /**
  62595. * Texture data comes from a raw cube data encoded with RGBD
  62596. */
  62597. static DATASOURCE_CUBERAW_RGBD: number;
  62598. /**
  62599. * Defines if the texture is ready
  62600. */
  62601. isReady: boolean;
  62602. /**
  62603. * Defines if the texture is a cube texture
  62604. */
  62605. isCube: boolean;
  62606. /**
  62607. * Defines if the texture contains 3D data
  62608. */
  62609. is3D: boolean;
  62610. /**
  62611. * Gets the URL used to load this texture
  62612. */
  62613. url: string;
  62614. /**
  62615. * Gets the sampling mode of the texture
  62616. */
  62617. samplingMode: number;
  62618. /**
  62619. * Gets a boolean indicating if the texture needs mipmaps generation
  62620. */
  62621. generateMipMaps: boolean;
  62622. /**
  62623. * Gets the number of samples used by the texture (WebGL2+ only)
  62624. */
  62625. samples: number;
  62626. /**
  62627. * Gets the type of the texture (int, float...)
  62628. */
  62629. type: number;
  62630. /**
  62631. * Gets the format of the texture (RGB, RGBA...)
  62632. */
  62633. format: number;
  62634. /**
  62635. * Observable called when the texture is loaded
  62636. */
  62637. onLoadedObservable: Observable<InternalTexture>;
  62638. /**
  62639. * Gets the width of the texture
  62640. */
  62641. width: number;
  62642. /**
  62643. * Gets the height of the texture
  62644. */
  62645. height: number;
  62646. /**
  62647. * Gets the depth of the texture
  62648. */
  62649. depth: number;
  62650. /**
  62651. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  62652. */
  62653. baseWidth: number;
  62654. /**
  62655. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  62656. */
  62657. baseHeight: number;
  62658. /**
  62659. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  62660. */
  62661. baseDepth: number;
  62662. /**
  62663. * Gets a boolean indicating if the texture is inverted on Y axis
  62664. */
  62665. invertY: boolean;
  62666. /**
  62667. * Gets or set the previous tracker in the list
  62668. */
  62669. previous: Nullable<IInternalTextureTracker>;
  62670. /**
  62671. * Gets or set the next tracker in the list
  62672. */
  62673. next: Nullable<IInternalTextureTracker>;
  62674. /** @hidden */
  62675. _invertVScale: boolean;
  62676. /** @hidden */
  62677. _initialSlot: number;
  62678. /** @hidden */
  62679. _designatedSlot: number;
  62680. /** @hidden */
  62681. _dataSource: number;
  62682. /** @hidden */
  62683. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  62684. /** @hidden */
  62685. _bufferView: Nullable<ArrayBufferView>;
  62686. /** @hidden */
  62687. _bufferViewArray: Nullable<ArrayBufferView[]>;
  62688. /** @hidden */
  62689. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  62690. /** @hidden */
  62691. _size: number;
  62692. /** @hidden */
  62693. _extension: string;
  62694. /** @hidden */
  62695. _files: Nullable<string[]>;
  62696. /** @hidden */
  62697. _workingCanvas: HTMLCanvasElement;
  62698. /** @hidden */
  62699. _workingContext: CanvasRenderingContext2D;
  62700. /** @hidden */
  62701. _framebuffer: Nullable<WebGLFramebuffer>;
  62702. /** @hidden */
  62703. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  62704. /** @hidden */
  62705. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  62706. /** @hidden */
  62707. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  62708. /** @hidden */
  62709. _attachments: Nullable<number[]>;
  62710. /** @hidden */
  62711. _cachedCoordinatesMode: Nullable<number>;
  62712. /** @hidden */
  62713. _cachedWrapU: Nullable<number>;
  62714. /** @hidden */
  62715. _cachedWrapV: Nullable<number>;
  62716. /** @hidden */
  62717. _cachedWrapR: Nullable<number>;
  62718. /** @hidden */
  62719. _cachedAnisotropicFilteringLevel: Nullable<number>;
  62720. /** @hidden */
  62721. _isDisabled: boolean;
  62722. /** @hidden */
  62723. _compression: Nullable<string>;
  62724. /** @hidden */
  62725. _generateStencilBuffer: boolean;
  62726. /** @hidden */
  62727. _generateDepthBuffer: boolean;
  62728. /** @hidden */
  62729. _comparisonFunction: number;
  62730. /** @hidden */
  62731. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  62732. /** @hidden */
  62733. _lodGenerationScale: number;
  62734. /** @hidden */
  62735. _lodGenerationOffset: number;
  62736. /** @hidden */
  62737. _lodTextureHigh: BaseTexture;
  62738. /** @hidden */
  62739. _lodTextureMid: BaseTexture;
  62740. /** @hidden */
  62741. _lodTextureLow: BaseTexture;
  62742. /** @hidden */
  62743. _isRGBD: boolean;
  62744. /** @hidden */
  62745. _webGLTexture: Nullable<WebGLTexture>;
  62746. /** @hidden */
  62747. _references: number;
  62748. private _engine;
  62749. /**
  62750. * Gets the Engine the texture belongs to.
  62751. * @returns The babylon engine
  62752. */
  62753. getEngine(): Engine;
  62754. /**
  62755. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  62756. */
  62757. readonly dataSource: number;
  62758. /**
  62759. * Creates a new InternalTexture
  62760. * @param engine defines the engine to use
  62761. * @param dataSource defines the type of data that will be used
  62762. * @param delayAllocation if the texture allocation should be delayed (default: false)
  62763. */
  62764. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  62765. /**
  62766. * Increments the number of references (ie. the number of Texture that point to it)
  62767. */
  62768. incrementReferences(): void;
  62769. /**
  62770. * Change the size of the texture (not the size of the content)
  62771. * @param width defines the new width
  62772. * @param height defines the new height
  62773. * @param depth defines the new depth (1 by default)
  62774. */
  62775. updateSize(width: int, height: int, depth?: int): void;
  62776. /** @hidden */
  62777. _rebuild(): void;
  62778. /** @hidden */
  62779. _swapAndDie(target: InternalTexture): void;
  62780. /**
  62781. * Dispose the current allocated resources
  62782. */
  62783. dispose(): void;
  62784. }
  62785. }
  62786. declare module BABYLON {
  62787. /**
  62788. * This represents the main contract an easing function should follow.
  62789. * Easing functions are used throughout the animation system.
  62790. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62791. */
  62792. export interface IEasingFunction {
  62793. /**
  62794. * Given an input gradient between 0 and 1, this returns the corrseponding value
  62795. * of the easing function.
  62796. * The link below provides some of the most common examples of easing functions.
  62797. * @see https://easings.net/
  62798. * @param gradient Defines the value between 0 and 1 we want the easing value for
  62799. * @returns the corresponding value on the curve defined by the easing function
  62800. */
  62801. ease(gradient: number): number;
  62802. }
  62803. /**
  62804. * Base class used for every default easing function.
  62805. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62806. */
  62807. export class EasingFunction implements IEasingFunction {
  62808. /**
  62809. * Interpolation follows the mathematical formula associated with the easing function.
  62810. */
  62811. static readonly EASINGMODE_EASEIN: number;
  62812. /**
  62813. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  62814. */
  62815. static readonly EASINGMODE_EASEOUT: number;
  62816. /**
  62817. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  62818. */
  62819. static readonly EASINGMODE_EASEINOUT: number;
  62820. private _easingMode;
  62821. /**
  62822. * Sets the easing mode of the current function.
  62823. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  62824. */
  62825. setEasingMode(easingMode: number): void;
  62826. /**
  62827. * Gets the current easing mode.
  62828. * @returns the easing mode
  62829. */
  62830. getEasingMode(): number;
  62831. /**
  62832. * @hidden
  62833. */
  62834. easeInCore(gradient: number): number;
  62835. /**
  62836. * Given an input gradient between 0 and 1, this returns the corrseponding value
  62837. * of the easing function.
  62838. * @param gradient Defines the value between 0 and 1 we want the easing value for
  62839. * @returns the corresponding value on the curve defined by the easing function
  62840. */
  62841. ease(gradient: number): number;
  62842. }
  62843. /**
  62844. * Easing function with a circle shape (see link below).
  62845. * @see https://easings.net/#easeInCirc
  62846. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62847. */
  62848. export class CircleEase extends EasingFunction implements IEasingFunction {
  62849. /** @hidden */
  62850. easeInCore(gradient: number): number;
  62851. }
  62852. /**
  62853. * Easing function with a ease back shape (see link below).
  62854. * @see https://easings.net/#easeInBack
  62855. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62856. */
  62857. export class BackEase extends EasingFunction implements IEasingFunction {
  62858. /** Defines the amplitude of the function */
  62859. amplitude: number;
  62860. /**
  62861. * Instantiates a back ease easing
  62862. * @see https://easings.net/#easeInBack
  62863. * @param amplitude Defines the amplitude of the function
  62864. */
  62865. constructor(
  62866. /** Defines the amplitude of the function */
  62867. amplitude?: number);
  62868. /** @hidden */
  62869. easeInCore(gradient: number): number;
  62870. }
  62871. /**
  62872. * Easing function with a bouncing shape (see link below).
  62873. * @see https://easings.net/#easeInBounce
  62874. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62875. */
  62876. export class BounceEase extends EasingFunction implements IEasingFunction {
  62877. /** Defines the number of bounces */
  62878. bounces: number;
  62879. /** Defines the amplitude of the bounce */
  62880. bounciness: number;
  62881. /**
  62882. * Instantiates a bounce easing
  62883. * @see https://easings.net/#easeInBounce
  62884. * @param bounces Defines the number of bounces
  62885. * @param bounciness Defines the amplitude of the bounce
  62886. */
  62887. constructor(
  62888. /** Defines the number of bounces */
  62889. bounces?: number,
  62890. /** Defines the amplitude of the bounce */
  62891. bounciness?: number);
  62892. /** @hidden */
  62893. easeInCore(gradient: number): number;
  62894. }
  62895. /**
  62896. * Easing function with a power of 3 shape (see link below).
  62897. * @see https://easings.net/#easeInCubic
  62898. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62899. */
  62900. export class CubicEase extends EasingFunction implements IEasingFunction {
  62901. /** @hidden */
  62902. easeInCore(gradient: number): number;
  62903. }
  62904. /**
  62905. * Easing function with an elastic shape (see link below).
  62906. * @see https://easings.net/#easeInElastic
  62907. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62908. */
  62909. export class ElasticEase extends EasingFunction implements IEasingFunction {
  62910. /** Defines the number of oscillations*/
  62911. oscillations: number;
  62912. /** Defines the amplitude of the oscillations*/
  62913. springiness: number;
  62914. /**
  62915. * Instantiates an elastic easing function
  62916. * @see https://easings.net/#easeInElastic
  62917. * @param oscillations Defines the number of oscillations
  62918. * @param springiness Defines the amplitude of the oscillations
  62919. */
  62920. constructor(
  62921. /** Defines the number of oscillations*/
  62922. oscillations?: number,
  62923. /** Defines the amplitude of the oscillations*/
  62924. springiness?: number);
  62925. /** @hidden */
  62926. easeInCore(gradient: number): number;
  62927. }
  62928. /**
  62929. * Easing function with an exponential shape (see link below).
  62930. * @see https://easings.net/#easeInExpo
  62931. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62932. */
  62933. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  62934. /** Defines the exponent of the function */
  62935. exponent: number;
  62936. /**
  62937. * Instantiates an exponential easing function
  62938. * @see https://easings.net/#easeInExpo
  62939. * @param exponent Defines the exponent of the function
  62940. */
  62941. constructor(
  62942. /** Defines the exponent of the function */
  62943. exponent?: number);
  62944. /** @hidden */
  62945. easeInCore(gradient: number): number;
  62946. }
  62947. /**
  62948. * Easing function with a power shape (see link below).
  62949. * @see https://easings.net/#easeInQuad
  62950. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62951. */
  62952. export class PowerEase extends EasingFunction implements IEasingFunction {
  62953. /** Defines the power of the function */
  62954. power: number;
  62955. /**
  62956. * Instantiates an power base easing function
  62957. * @see https://easings.net/#easeInQuad
  62958. * @param power Defines the power of the function
  62959. */
  62960. constructor(
  62961. /** Defines the power of the function */
  62962. power?: number);
  62963. /** @hidden */
  62964. easeInCore(gradient: number): number;
  62965. }
  62966. /**
  62967. * Easing function with a power of 2 shape (see link below).
  62968. * @see https://easings.net/#easeInQuad
  62969. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62970. */
  62971. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  62972. /** @hidden */
  62973. easeInCore(gradient: number): number;
  62974. }
  62975. /**
  62976. * Easing function with a power of 4 shape (see link below).
  62977. * @see https://easings.net/#easeInQuart
  62978. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62979. */
  62980. export class QuarticEase extends EasingFunction implements IEasingFunction {
  62981. /** @hidden */
  62982. easeInCore(gradient: number): number;
  62983. }
  62984. /**
  62985. * Easing function with a power of 5 shape (see link below).
  62986. * @see https://easings.net/#easeInQuint
  62987. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62988. */
  62989. export class QuinticEase extends EasingFunction implements IEasingFunction {
  62990. /** @hidden */
  62991. easeInCore(gradient: number): number;
  62992. }
  62993. /**
  62994. * Easing function with a sin shape (see link below).
  62995. * @see https://easings.net/#easeInSine
  62996. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62997. */
  62998. export class SineEase extends EasingFunction implements IEasingFunction {
  62999. /** @hidden */
  63000. easeInCore(gradient: number): number;
  63001. }
  63002. /**
  63003. * Easing function with a bezier shape (see link below).
  63004. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  63005. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63006. */
  63007. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  63008. /** Defines the x component of the start tangent in the bezier curve */
  63009. x1: number;
  63010. /** Defines the y component of the start tangent in the bezier curve */
  63011. y1: number;
  63012. /** Defines the x component of the end tangent in the bezier curve */
  63013. x2: number;
  63014. /** Defines the y component of the end tangent in the bezier curve */
  63015. y2: number;
  63016. /**
  63017. * Instantiates a bezier function
  63018. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  63019. * @param x1 Defines the x component of the start tangent in the bezier curve
  63020. * @param y1 Defines the y component of the start tangent in the bezier curve
  63021. * @param x2 Defines the x component of the end tangent in the bezier curve
  63022. * @param y2 Defines the y component of the end tangent in the bezier curve
  63023. */
  63024. constructor(
  63025. /** Defines the x component of the start tangent in the bezier curve */
  63026. x1?: number,
  63027. /** Defines the y component of the start tangent in the bezier curve */
  63028. y1?: number,
  63029. /** Defines the x component of the end tangent in the bezier curve */
  63030. x2?: number,
  63031. /** Defines the y component of the end tangent in the bezier curve */
  63032. y2?: number);
  63033. /** @hidden */
  63034. easeInCore(gradient: number): number;
  63035. }
  63036. }
  63037. declare module BABYLON {
  63038. /**
  63039. * Defines an interface which represents an animation key frame
  63040. */
  63041. export interface IAnimationKey {
  63042. /**
  63043. * Frame of the key frame
  63044. */
  63045. frame: number;
  63046. /**
  63047. * Value at the specifies key frame
  63048. */
  63049. value: any;
  63050. /**
  63051. * The input tangent for the cubic hermite spline
  63052. */
  63053. inTangent?: any;
  63054. /**
  63055. * The output tangent for the cubic hermite spline
  63056. */
  63057. outTangent?: any;
  63058. /**
  63059. * The animation interpolation type
  63060. */
  63061. interpolation?: AnimationKeyInterpolation;
  63062. }
  63063. /**
  63064. * Enum for the animation key frame interpolation type
  63065. */
  63066. export enum AnimationKeyInterpolation {
  63067. /**
  63068. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  63069. */
  63070. STEP = 1
  63071. }
  63072. }
  63073. declare module BABYLON {
  63074. /**
  63075. * Represents the range of an animation
  63076. */
  63077. export class AnimationRange {
  63078. /**The name of the animation range**/
  63079. name: string;
  63080. /**The starting frame of the animation */
  63081. from: number;
  63082. /**The ending frame of the animation*/
  63083. to: number;
  63084. /**
  63085. * Initializes the range of an animation
  63086. * @param name The name of the animation range
  63087. * @param from The starting frame of the animation
  63088. * @param to The ending frame of the animation
  63089. */
  63090. constructor(
  63091. /**The name of the animation range**/
  63092. name: string,
  63093. /**The starting frame of the animation */
  63094. from: number,
  63095. /**The ending frame of the animation*/
  63096. to: number);
  63097. /**
  63098. * Makes a copy of the animation range
  63099. * @returns A copy of the animation range
  63100. */
  63101. clone(): AnimationRange;
  63102. }
  63103. }
  63104. declare module BABYLON {
  63105. /**
  63106. * Composed of a frame, and an action function
  63107. */
  63108. export class AnimationEvent {
  63109. /** The frame for which the event is triggered **/
  63110. frame: number;
  63111. /** The event to perform when triggered **/
  63112. action: (currentFrame: number) => void;
  63113. /** Specifies if the event should be triggered only once**/
  63114. onlyOnce?: boolean | undefined;
  63115. /**
  63116. * Specifies if the animation event is done
  63117. */
  63118. isDone: boolean;
  63119. /**
  63120. * Initializes the animation event
  63121. * @param frame The frame for which the event is triggered
  63122. * @param action The event to perform when triggered
  63123. * @param onlyOnce Specifies if the event should be triggered only once
  63124. */
  63125. constructor(
  63126. /** The frame for which the event is triggered **/
  63127. frame: number,
  63128. /** The event to perform when triggered **/
  63129. action: (currentFrame: number) => void,
  63130. /** Specifies if the event should be triggered only once**/
  63131. onlyOnce?: boolean | undefined);
  63132. /** @hidden */
  63133. _clone(): AnimationEvent;
  63134. }
  63135. }
  63136. declare module BABYLON {
  63137. /**
  63138. * Interface used to define a behavior
  63139. */
  63140. export interface Behavior<T> {
  63141. /** gets or sets behavior's name */
  63142. name: string;
  63143. /**
  63144. * Function called when the behavior needs to be initialized (after attaching it to a target)
  63145. */
  63146. init(): void;
  63147. /**
  63148. * Called when the behavior is attached to a target
  63149. * @param target defines the target where the behavior is attached to
  63150. */
  63151. attach(target: T): void;
  63152. /**
  63153. * Called when the behavior is detached from its target
  63154. */
  63155. detach(): void;
  63156. }
  63157. /**
  63158. * Interface implemented by classes supporting behaviors
  63159. */
  63160. export interface IBehaviorAware<T> {
  63161. /**
  63162. * Attach a behavior
  63163. * @param behavior defines the behavior to attach
  63164. * @returns the current host
  63165. */
  63166. addBehavior(behavior: Behavior<T>): T;
  63167. /**
  63168. * Remove a behavior from the current object
  63169. * @param behavior defines the behavior to detach
  63170. * @returns the current host
  63171. */
  63172. removeBehavior(behavior: Behavior<T>): T;
  63173. /**
  63174. * Gets a behavior using its name to search
  63175. * @param name defines the name to search
  63176. * @returns the behavior or null if not found
  63177. */
  63178. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  63179. }
  63180. }
  63181. declare module BABYLON {
  63182. /**
  63183. * Defines a runtime animation
  63184. */
  63185. export class RuntimeAnimation {
  63186. private _events;
  63187. /**
  63188. * The current frame of the runtime animation
  63189. */
  63190. private _currentFrame;
  63191. /**
  63192. * The animation used by the runtime animation
  63193. */
  63194. private _animation;
  63195. /**
  63196. * The target of the runtime animation
  63197. */
  63198. private _target;
  63199. /**
  63200. * The initiating animatable
  63201. */
  63202. private _host;
  63203. /**
  63204. * The original value of the runtime animation
  63205. */
  63206. private _originalValue;
  63207. /**
  63208. * The original blend value of the runtime animation
  63209. */
  63210. private _originalBlendValue;
  63211. /**
  63212. * The offsets cache of the runtime animation
  63213. */
  63214. private _offsetsCache;
  63215. /**
  63216. * The high limits cache of the runtime animation
  63217. */
  63218. private _highLimitsCache;
  63219. /**
  63220. * Specifies if the runtime animation has been stopped
  63221. */
  63222. private _stopped;
  63223. /**
  63224. * The blending factor of the runtime animation
  63225. */
  63226. private _blendingFactor;
  63227. /**
  63228. * The BabylonJS scene
  63229. */
  63230. private _scene;
  63231. /**
  63232. * The current value of the runtime animation
  63233. */
  63234. private _currentValue;
  63235. /** @hidden */
  63236. _workValue: any;
  63237. /**
  63238. * The active target of the runtime animation
  63239. */
  63240. private _activeTarget;
  63241. /**
  63242. * The target path of the runtime animation
  63243. */
  63244. private _targetPath;
  63245. /**
  63246. * The weight of the runtime animation
  63247. */
  63248. private _weight;
  63249. /**
  63250. * The ratio offset of the runtime animation
  63251. */
  63252. private _ratioOffset;
  63253. /**
  63254. * The previous delay of the runtime animation
  63255. */
  63256. private _previousDelay;
  63257. /**
  63258. * The previous ratio of the runtime animation
  63259. */
  63260. private _previousRatio;
  63261. /**
  63262. * Gets the current frame of the runtime animation
  63263. */
  63264. readonly currentFrame: number;
  63265. /**
  63266. * Gets the weight of the runtime animation
  63267. */
  63268. readonly weight: number;
  63269. /**
  63270. * Gets the current value of the runtime animation
  63271. */
  63272. readonly currentValue: any;
  63273. /**
  63274. * Gets the target path of the runtime animation
  63275. */
  63276. readonly targetPath: string;
  63277. /**
  63278. * Gets the actual target of the runtime animation
  63279. */
  63280. readonly target: any;
  63281. /**
  63282. * Create a new RuntimeAnimation object
  63283. * @param target defines the target of the animation
  63284. * @param animation defines the source animation object
  63285. * @param scene defines the hosting scene
  63286. * @param host defines the initiating Animatable
  63287. */
  63288. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  63289. /**
  63290. * Gets the animation from the runtime animation
  63291. */
  63292. readonly animation: Animation;
  63293. /**
  63294. * Resets the runtime animation to the beginning
  63295. * @param restoreOriginal defines whether to restore the target property to the original value
  63296. */
  63297. reset(restoreOriginal?: boolean): void;
  63298. /**
  63299. * Specifies if the runtime animation is stopped
  63300. * @returns Boolean specifying if the runtime animation is stopped
  63301. */
  63302. isStopped(): boolean;
  63303. /**
  63304. * Disposes of the runtime animation
  63305. */
  63306. dispose(): void;
  63307. /**
  63308. * Interpolates the animation from the current frame
  63309. * @param currentFrame The frame to interpolate the animation to
  63310. * @param repeatCount The number of times that the animation should loop
  63311. * @param loopMode The type of looping mode to use
  63312. * @param offsetValue Animation offset value
  63313. * @param highLimitValue The high limit value
  63314. * @returns The interpolated value
  63315. */
  63316. private _interpolate;
  63317. /**
  63318. * Apply the interpolated value to the target
  63319. * @param currentValue defines the value computed by the animation
  63320. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  63321. */
  63322. setValue(currentValue: any, weight?: number): void;
  63323. private _setValue;
  63324. /**
  63325. * Gets the loop pmode of the runtime animation
  63326. * @returns Loop Mode
  63327. */
  63328. private _getCorrectLoopMode;
  63329. /**
  63330. * Move the current animation to a given frame
  63331. * @param frame defines the frame to move to
  63332. */
  63333. goToFrame(frame: number): void;
  63334. /**
  63335. * @hidden Internal use only
  63336. */
  63337. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  63338. /**
  63339. * Execute the current animation
  63340. * @param delay defines the delay to add to the current frame
  63341. * @param from defines the lower bound of the animation range
  63342. * @param to defines the upper bound of the animation range
  63343. * @param loop defines if the current animation must loop
  63344. * @param speedRatio defines the current speed ratio
  63345. * @param weight defines the weight of the animation (default is -1 so no weight)
  63346. * @param onLoop optional callback called when animation loops
  63347. * @returns a boolean indicating if the animation is running
  63348. */
  63349. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  63350. }
  63351. }
  63352. declare module BABYLON {
  63353. /**
  63354. * @hidden
  63355. */
  63356. export class IntersectionInfo {
  63357. bu: Nullable<number>;
  63358. bv: Nullable<number>;
  63359. distance: number;
  63360. faceId: number;
  63361. subMeshId: number;
  63362. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  63363. }
  63364. }
  63365. declare module BABYLON {
  63366. /**
  63367. * Class used to store bounding sphere information
  63368. */
  63369. export class BoundingSphere {
  63370. /**
  63371. * Gets the center of the bounding sphere in local space
  63372. */
  63373. readonly center: Vector3;
  63374. /**
  63375. * Radius of the bounding sphere in local space
  63376. */
  63377. radius: number;
  63378. /**
  63379. * Gets the center of the bounding sphere in world space
  63380. */
  63381. readonly centerWorld: Vector3;
  63382. /**
  63383. * Radius of the bounding sphere in world space
  63384. */
  63385. radiusWorld: number;
  63386. /**
  63387. * Gets the minimum vector in local space
  63388. */
  63389. readonly minimum: Vector3;
  63390. /**
  63391. * Gets the maximum vector in local space
  63392. */
  63393. readonly maximum: Vector3;
  63394. private _worldMatrix;
  63395. private static readonly TmpVector3;
  63396. /**
  63397. * Creates a new bounding sphere
  63398. * @param min defines the minimum vector (in local space)
  63399. * @param max defines the maximum vector (in local space)
  63400. * @param worldMatrix defines the new world matrix
  63401. */
  63402. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63403. /**
  63404. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  63405. * @param min defines the new minimum vector (in local space)
  63406. * @param max defines the new maximum vector (in local space)
  63407. * @param worldMatrix defines the new world matrix
  63408. */
  63409. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63410. /**
  63411. * Scale the current bounding sphere by applying a scale factor
  63412. * @param factor defines the scale factor to apply
  63413. * @returns the current bounding box
  63414. */
  63415. scale(factor: number): BoundingSphere;
  63416. /**
  63417. * Gets the world matrix of the bounding box
  63418. * @returns a matrix
  63419. */
  63420. getWorldMatrix(): DeepImmutable<Matrix>;
  63421. /** @hidden */
  63422. _update(worldMatrix: DeepImmutable<Matrix>): void;
  63423. /**
  63424. * Tests if the bounding sphere is intersecting the frustum planes
  63425. * @param frustumPlanes defines the frustum planes to test
  63426. * @returns true if there is an intersection
  63427. */
  63428. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63429. /**
  63430. * Tests if the bounding sphere center is in between the frustum planes.
  63431. * Used for optimistic fast inclusion.
  63432. * @param frustumPlanes defines the frustum planes to test
  63433. * @returns true if the sphere center is in between the frustum planes
  63434. */
  63435. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63436. /**
  63437. * Tests if a point is inside the bounding sphere
  63438. * @param point defines the point to test
  63439. * @returns true if the point is inside the bounding sphere
  63440. */
  63441. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63442. /**
  63443. * Checks if two sphere intersct
  63444. * @param sphere0 sphere 0
  63445. * @param sphere1 sphere 1
  63446. * @returns true if the speres intersect
  63447. */
  63448. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  63449. }
  63450. }
  63451. declare module BABYLON {
  63452. /**
  63453. * Class used to store bounding box information
  63454. */
  63455. export class BoundingBox implements ICullable {
  63456. /**
  63457. * Gets the 8 vectors representing the bounding box in local space
  63458. */
  63459. readonly vectors: Vector3[];
  63460. /**
  63461. * Gets the center of the bounding box in local space
  63462. */
  63463. readonly center: Vector3;
  63464. /**
  63465. * Gets the center of the bounding box in world space
  63466. */
  63467. readonly centerWorld: Vector3;
  63468. /**
  63469. * Gets the extend size in local space
  63470. */
  63471. readonly extendSize: Vector3;
  63472. /**
  63473. * Gets the extend size in world space
  63474. */
  63475. readonly extendSizeWorld: Vector3;
  63476. /**
  63477. * Gets the OBB (object bounding box) directions
  63478. */
  63479. readonly directions: Vector3[];
  63480. /**
  63481. * Gets the 8 vectors representing the bounding box in world space
  63482. */
  63483. readonly vectorsWorld: Vector3[];
  63484. /**
  63485. * Gets the minimum vector in world space
  63486. */
  63487. readonly minimumWorld: Vector3;
  63488. /**
  63489. * Gets the maximum vector in world space
  63490. */
  63491. readonly maximumWorld: Vector3;
  63492. /**
  63493. * Gets the minimum vector in local space
  63494. */
  63495. readonly minimum: Vector3;
  63496. /**
  63497. * Gets the maximum vector in local space
  63498. */
  63499. readonly maximum: Vector3;
  63500. private _worldMatrix;
  63501. private static readonly TmpVector3;
  63502. /**
  63503. * @hidden
  63504. */
  63505. _tag: number;
  63506. /**
  63507. * Creates a new bounding box
  63508. * @param min defines the minimum vector (in local space)
  63509. * @param max defines the maximum vector (in local space)
  63510. * @param worldMatrix defines the new world matrix
  63511. */
  63512. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63513. /**
  63514. * Recreates the entire bounding box from scratch as if we call the constructor in place
  63515. * @param min defines the new minimum vector (in local space)
  63516. * @param max defines the new maximum vector (in local space)
  63517. * @param worldMatrix defines the new world matrix
  63518. */
  63519. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63520. /**
  63521. * Scale the current bounding box by applying a scale factor
  63522. * @param factor defines the scale factor to apply
  63523. * @returns the current bounding box
  63524. */
  63525. scale(factor: number): BoundingBox;
  63526. /**
  63527. * Gets the world matrix of the bounding box
  63528. * @returns a matrix
  63529. */
  63530. getWorldMatrix(): DeepImmutable<Matrix>;
  63531. /** @hidden */
  63532. _update(world: DeepImmutable<Matrix>): void;
  63533. /**
  63534. * Tests if the bounding box is intersecting the frustum planes
  63535. * @param frustumPlanes defines the frustum planes to test
  63536. * @returns true if there is an intersection
  63537. */
  63538. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63539. /**
  63540. * Tests if the bounding box is entirely inside the frustum planes
  63541. * @param frustumPlanes defines the frustum planes to test
  63542. * @returns true if there is an inclusion
  63543. */
  63544. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63545. /**
  63546. * Tests if a point is inside the bounding box
  63547. * @param point defines the point to test
  63548. * @returns true if the point is inside the bounding box
  63549. */
  63550. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63551. /**
  63552. * Tests if the bounding box intersects with a bounding sphere
  63553. * @param sphere defines the sphere to test
  63554. * @returns true if there is an intersection
  63555. */
  63556. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  63557. /**
  63558. * Tests if the bounding box intersects with a box defined by a min and max vectors
  63559. * @param min defines the min vector to use
  63560. * @param max defines the max vector to use
  63561. * @returns true if there is an intersection
  63562. */
  63563. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  63564. /**
  63565. * Tests if two bounding boxes are intersections
  63566. * @param box0 defines the first box to test
  63567. * @param box1 defines the second box to test
  63568. * @returns true if there is an intersection
  63569. */
  63570. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  63571. /**
  63572. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  63573. * @param minPoint defines the minimum vector of the bounding box
  63574. * @param maxPoint defines the maximum vector of the bounding box
  63575. * @param sphereCenter defines the sphere center
  63576. * @param sphereRadius defines the sphere radius
  63577. * @returns true if there is an intersection
  63578. */
  63579. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  63580. /**
  63581. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  63582. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  63583. * @param frustumPlanes defines the frustum planes to test
  63584. * @return true if there is an inclusion
  63585. */
  63586. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63587. /**
  63588. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  63589. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  63590. * @param frustumPlanes defines the frustum planes to test
  63591. * @return true if there is an intersection
  63592. */
  63593. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63594. }
  63595. }
  63596. declare module BABYLON {
  63597. /** @hidden */
  63598. export class Collider {
  63599. /** Define if a collision was found */
  63600. collisionFound: boolean;
  63601. /**
  63602. * Define last intersection point in local space
  63603. */
  63604. intersectionPoint: Vector3;
  63605. /**
  63606. * Define last collided mesh
  63607. */
  63608. collidedMesh: Nullable<AbstractMesh>;
  63609. private _collisionPoint;
  63610. private _planeIntersectionPoint;
  63611. private _tempVector;
  63612. private _tempVector2;
  63613. private _tempVector3;
  63614. private _tempVector4;
  63615. private _edge;
  63616. private _baseToVertex;
  63617. private _destinationPoint;
  63618. private _slidePlaneNormal;
  63619. private _displacementVector;
  63620. /** @hidden */
  63621. _radius: Vector3;
  63622. /** @hidden */
  63623. _retry: number;
  63624. private _velocity;
  63625. private _basePoint;
  63626. private _epsilon;
  63627. /** @hidden */
  63628. _velocityWorldLength: number;
  63629. /** @hidden */
  63630. _basePointWorld: Vector3;
  63631. private _velocityWorld;
  63632. private _normalizedVelocity;
  63633. /** @hidden */
  63634. _initialVelocity: Vector3;
  63635. /** @hidden */
  63636. _initialPosition: Vector3;
  63637. private _nearestDistance;
  63638. private _collisionMask;
  63639. collisionMask: number;
  63640. /**
  63641. * Gets the plane normal used to compute the sliding response (in local space)
  63642. */
  63643. readonly slidePlaneNormal: Vector3;
  63644. /** @hidden */
  63645. _initialize(source: Vector3, dir: Vector3, e: number): void;
  63646. /** @hidden */
  63647. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  63648. /** @hidden */
  63649. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  63650. /** @hidden */
  63651. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  63652. /** @hidden */
  63653. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  63654. /** @hidden */
  63655. _getResponse(pos: Vector3, vel: Vector3): void;
  63656. }
  63657. }
  63658. declare module BABYLON {
  63659. /**
  63660. * Interface for cullable objects
  63661. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  63662. */
  63663. export interface ICullable {
  63664. /**
  63665. * Checks if the object or part of the object is in the frustum
  63666. * @param frustumPlanes Camera near/planes
  63667. * @returns true if the object is in frustum otherwise false
  63668. */
  63669. isInFrustum(frustumPlanes: Plane[]): boolean;
  63670. /**
  63671. * Checks if a cullable object (mesh...) is in the camera frustum
  63672. * Unlike isInFrustum this cheks the full bounding box
  63673. * @param frustumPlanes Camera near/planes
  63674. * @returns true if the object is in frustum otherwise false
  63675. */
  63676. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  63677. }
  63678. /**
  63679. * Info for a bounding data of a mesh
  63680. */
  63681. export class BoundingInfo implements ICullable {
  63682. /**
  63683. * Bounding box for the mesh
  63684. */
  63685. readonly boundingBox: BoundingBox;
  63686. /**
  63687. * Bounding sphere for the mesh
  63688. */
  63689. readonly boundingSphere: BoundingSphere;
  63690. private _isLocked;
  63691. private static readonly TmpVector3;
  63692. /**
  63693. * Constructs bounding info
  63694. * @param minimum min vector of the bounding box/sphere
  63695. * @param maximum max vector of the bounding box/sphere
  63696. * @param worldMatrix defines the new world matrix
  63697. */
  63698. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63699. /**
  63700. * Recreates the entire bounding info from scratch as if we call the constructor in place
  63701. * @param min defines the new minimum vector (in local space)
  63702. * @param max defines the new maximum vector (in local space)
  63703. * @param worldMatrix defines the new world matrix
  63704. */
  63705. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63706. /**
  63707. * min vector of the bounding box/sphere
  63708. */
  63709. readonly minimum: Vector3;
  63710. /**
  63711. * max vector of the bounding box/sphere
  63712. */
  63713. readonly maximum: Vector3;
  63714. /**
  63715. * If the info is locked and won't be updated to avoid perf overhead
  63716. */
  63717. isLocked: boolean;
  63718. /**
  63719. * Updates the bounding sphere and box
  63720. * @param world world matrix to be used to update
  63721. */
  63722. update(world: DeepImmutable<Matrix>): void;
  63723. /**
  63724. * Recreate the bounding info to be centered around a specific point given a specific extend.
  63725. * @param center New center of the bounding info
  63726. * @param extend New extend of the bounding info
  63727. * @returns the current bounding info
  63728. */
  63729. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  63730. /**
  63731. * Scale the current bounding info by applying a scale factor
  63732. * @param factor defines the scale factor to apply
  63733. * @returns the current bounding info
  63734. */
  63735. scale(factor: number): BoundingInfo;
  63736. /**
  63737. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  63738. * @param frustumPlanes defines the frustum to test
  63739. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  63740. * @returns true if the bounding info is in the frustum planes
  63741. */
  63742. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  63743. /**
  63744. * Gets the world distance between the min and max points of the bounding box
  63745. */
  63746. readonly diagonalLength: number;
  63747. /**
  63748. * Checks if a cullable object (mesh...) is in the camera frustum
  63749. * Unlike isInFrustum this cheks the full bounding box
  63750. * @param frustumPlanes Camera near/planes
  63751. * @returns true if the object is in frustum otherwise false
  63752. */
  63753. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63754. /** @hidden */
  63755. _checkCollision(collider: Collider): boolean;
  63756. /**
  63757. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  63758. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  63759. * @param point the point to check intersection with
  63760. * @returns if the point intersects
  63761. */
  63762. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63763. /**
  63764. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  63765. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  63766. * @param boundingInfo the bounding info to check intersection with
  63767. * @param precise if the intersection should be done using OBB
  63768. * @returns if the bounding info intersects
  63769. */
  63770. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  63771. }
  63772. }
  63773. declare module BABYLON {
  63774. /**
  63775. * Defines an array and its length.
  63776. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  63777. */
  63778. export interface ISmartArrayLike<T> {
  63779. /**
  63780. * The data of the array.
  63781. */
  63782. data: Array<T>;
  63783. /**
  63784. * The active length of the array.
  63785. */
  63786. length: number;
  63787. }
  63788. /**
  63789. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  63790. */
  63791. export class SmartArray<T> implements ISmartArrayLike<T> {
  63792. /**
  63793. * The full set of data from the array.
  63794. */
  63795. data: Array<T>;
  63796. /**
  63797. * The active length of the array.
  63798. */
  63799. length: number;
  63800. protected _id: number;
  63801. /**
  63802. * Instantiates a Smart Array.
  63803. * @param capacity defines the default capacity of the array.
  63804. */
  63805. constructor(capacity: number);
  63806. /**
  63807. * Pushes a value at the end of the active data.
  63808. * @param value defines the object to push in the array.
  63809. */
  63810. push(value: T): void;
  63811. /**
  63812. * Iterates over the active data and apply the lambda to them.
  63813. * @param func defines the action to apply on each value.
  63814. */
  63815. forEach(func: (content: T) => void): void;
  63816. /**
  63817. * Sorts the full sets of data.
  63818. * @param compareFn defines the comparison function to apply.
  63819. */
  63820. sort(compareFn: (a: T, b: T) => number): void;
  63821. /**
  63822. * Resets the active data to an empty array.
  63823. */
  63824. reset(): void;
  63825. /**
  63826. * Releases all the data from the array as well as the array.
  63827. */
  63828. dispose(): void;
  63829. /**
  63830. * Concats the active data with a given array.
  63831. * @param array defines the data to concatenate with.
  63832. */
  63833. concat(array: any): void;
  63834. /**
  63835. * Returns the position of a value in the active data.
  63836. * @param value defines the value to find the index for
  63837. * @returns the index if found in the active data otherwise -1
  63838. */
  63839. indexOf(value: T): number;
  63840. /**
  63841. * Returns whether an element is part of the active data.
  63842. * @param value defines the value to look for
  63843. * @returns true if found in the active data otherwise false
  63844. */
  63845. contains(value: T): boolean;
  63846. private static _GlobalId;
  63847. }
  63848. /**
  63849. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  63850. * The data in this array can only be present once
  63851. */
  63852. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  63853. private _duplicateId;
  63854. /**
  63855. * Pushes a value at the end of the active data.
  63856. * THIS DOES NOT PREVENT DUPPLICATE DATA
  63857. * @param value defines the object to push in the array.
  63858. */
  63859. push(value: T): void;
  63860. /**
  63861. * Pushes a value at the end of the active data.
  63862. * If the data is already present, it won t be added again
  63863. * @param value defines the object to push in the array.
  63864. * @returns true if added false if it was already present
  63865. */
  63866. pushNoDuplicate(value: T): boolean;
  63867. /**
  63868. * Resets the active data to an empty array.
  63869. */
  63870. reset(): void;
  63871. /**
  63872. * Concats the active data with a given array.
  63873. * This ensures no dupplicate will be present in the result.
  63874. * @param array defines the data to concatenate with.
  63875. */
  63876. concatWithNoDuplicate(array: any): void;
  63877. }
  63878. }
  63879. declare module BABYLON {
  63880. /**
  63881. * Class used to represent data loading progression
  63882. */
  63883. export class SceneLoaderFlags {
  63884. private static _ForceFullSceneLoadingForIncremental;
  63885. private static _ShowLoadingScreen;
  63886. private static _CleanBoneMatrixWeights;
  63887. private static _loggingLevel;
  63888. /**
  63889. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  63890. */
  63891. static ForceFullSceneLoadingForIncremental: boolean;
  63892. /**
  63893. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  63894. */
  63895. static ShowLoadingScreen: boolean;
  63896. /**
  63897. * Defines the current logging level (while loading the scene)
  63898. * @ignorenaming
  63899. */
  63900. static loggingLevel: number;
  63901. /**
  63902. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  63903. */
  63904. static CleanBoneMatrixWeights: boolean;
  63905. }
  63906. }
  63907. declare module BABYLON {
  63908. /**
  63909. * Class used to override all child animations of a given target
  63910. */
  63911. export class AnimationPropertiesOverride {
  63912. /**
  63913. * Gets or sets a value indicating if animation blending must be used
  63914. */
  63915. enableBlending: boolean;
  63916. /**
  63917. * Gets or sets the blending speed to use when enableBlending is true
  63918. */
  63919. blendingSpeed: number;
  63920. /**
  63921. * Gets or sets the default loop mode to use
  63922. */
  63923. loopMode: number;
  63924. }
  63925. }
  63926. declare module BABYLON {
  63927. /**
  63928. * Defines a target to use with MorphTargetManager
  63929. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  63930. */
  63931. export class MorphTarget implements IAnimatable {
  63932. /** defines the name of the target */
  63933. name: string;
  63934. /**
  63935. * Gets or sets the list of animations
  63936. */
  63937. animations: Animation[];
  63938. private _scene;
  63939. private _positions;
  63940. private _normals;
  63941. private _tangents;
  63942. private _influence;
  63943. /**
  63944. * Observable raised when the influence changes
  63945. */
  63946. onInfluenceChanged: Observable<boolean>;
  63947. /** @hidden */
  63948. _onDataLayoutChanged: Observable<void>;
  63949. /**
  63950. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  63951. */
  63952. influence: number;
  63953. /**
  63954. * Gets or sets the id of the morph Target
  63955. */
  63956. id: string;
  63957. private _animationPropertiesOverride;
  63958. /**
  63959. * Gets or sets the animation properties override
  63960. */
  63961. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  63962. /**
  63963. * Creates a new MorphTarget
  63964. * @param name defines the name of the target
  63965. * @param influence defines the influence to use
  63966. * @param scene defines the scene the morphtarget belongs to
  63967. */
  63968. constructor(
  63969. /** defines the name of the target */
  63970. name: string, influence?: number, scene?: Nullable<Scene>);
  63971. /**
  63972. * Gets a boolean defining if the target contains position data
  63973. */
  63974. readonly hasPositions: boolean;
  63975. /**
  63976. * Gets a boolean defining if the target contains normal data
  63977. */
  63978. readonly hasNormals: boolean;
  63979. /**
  63980. * Gets a boolean defining if the target contains tangent data
  63981. */
  63982. readonly hasTangents: boolean;
  63983. /**
  63984. * Affects position data to this target
  63985. * @param data defines the position data to use
  63986. */
  63987. setPositions(data: Nullable<FloatArray>): void;
  63988. /**
  63989. * Gets the position data stored in this target
  63990. * @returns a FloatArray containing the position data (or null if not present)
  63991. */
  63992. getPositions(): Nullable<FloatArray>;
  63993. /**
  63994. * Affects normal data to this target
  63995. * @param data defines the normal data to use
  63996. */
  63997. setNormals(data: Nullable<FloatArray>): void;
  63998. /**
  63999. * Gets the normal data stored in this target
  64000. * @returns a FloatArray containing the normal data (or null if not present)
  64001. */
  64002. getNormals(): Nullable<FloatArray>;
  64003. /**
  64004. * Affects tangent data to this target
  64005. * @param data defines the tangent data to use
  64006. */
  64007. setTangents(data: Nullable<FloatArray>): void;
  64008. /**
  64009. * Gets the tangent data stored in this target
  64010. * @returns a FloatArray containing the tangent data (or null if not present)
  64011. */
  64012. getTangents(): Nullable<FloatArray>;
  64013. /**
  64014. * Serializes the current target into a Serialization object
  64015. * @returns the serialized object
  64016. */
  64017. serialize(): any;
  64018. /**
  64019. * Returns the string "MorphTarget"
  64020. * @returns "MorphTarget"
  64021. */
  64022. getClassName(): string;
  64023. /**
  64024. * Creates a new target from serialized data
  64025. * @param serializationObject defines the serialized data to use
  64026. * @returns a new MorphTarget
  64027. */
  64028. static Parse(serializationObject: any): MorphTarget;
  64029. /**
  64030. * Creates a MorphTarget from mesh data
  64031. * @param mesh defines the source mesh
  64032. * @param name defines the name to use for the new target
  64033. * @param influence defines the influence to attach to the target
  64034. * @returns a new MorphTarget
  64035. */
  64036. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  64037. }
  64038. }
  64039. declare module BABYLON {
  64040. /**
  64041. * This class is used to deform meshes using morphing between different targets
  64042. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  64043. */
  64044. export class MorphTargetManager {
  64045. private _targets;
  64046. private _targetInfluenceChangedObservers;
  64047. private _targetDataLayoutChangedObservers;
  64048. private _activeTargets;
  64049. private _scene;
  64050. private _influences;
  64051. private _supportsNormals;
  64052. private _supportsTangents;
  64053. private _vertexCount;
  64054. private _uniqueId;
  64055. private _tempInfluences;
  64056. /**
  64057. * Creates a new MorphTargetManager
  64058. * @param scene defines the current scene
  64059. */
  64060. constructor(scene?: Nullable<Scene>);
  64061. /**
  64062. * Gets the unique ID of this manager
  64063. */
  64064. readonly uniqueId: number;
  64065. /**
  64066. * Gets the number of vertices handled by this manager
  64067. */
  64068. readonly vertexCount: number;
  64069. /**
  64070. * Gets a boolean indicating if this manager supports morphing of normals
  64071. */
  64072. readonly supportsNormals: boolean;
  64073. /**
  64074. * Gets a boolean indicating if this manager supports morphing of tangents
  64075. */
  64076. readonly supportsTangents: boolean;
  64077. /**
  64078. * Gets the number of targets stored in this manager
  64079. */
  64080. readonly numTargets: number;
  64081. /**
  64082. * Gets the number of influencers (ie. the number of targets with influences > 0)
  64083. */
  64084. readonly numInfluencers: number;
  64085. /**
  64086. * Gets the list of influences (one per target)
  64087. */
  64088. readonly influences: Float32Array;
  64089. /**
  64090. * Gets the active target at specified index. An active target is a target with an influence > 0
  64091. * @param index defines the index to check
  64092. * @returns the requested target
  64093. */
  64094. getActiveTarget(index: number): MorphTarget;
  64095. /**
  64096. * Gets the target at specified index
  64097. * @param index defines the index to check
  64098. * @returns the requested target
  64099. */
  64100. getTarget(index: number): MorphTarget;
  64101. /**
  64102. * Add a new target to this manager
  64103. * @param target defines the target to add
  64104. */
  64105. addTarget(target: MorphTarget): void;
  64106. /**
  64107. * Removes a target from the manager
  64108. * @param target defines the target to remove
  64109. */
  64110. removeTarget(target: MorphTarget): void;
  64111. /**
  64112. * Serializes the current manager into a Serialization object
  64113. * @returns the serialized object
  64114. */
  64115. serialize(): any;
  64116. private _syncActiveTargets;
  64117. /**
  64118. * Syncrhonize the targets with all the meshes using this morph target manager
  64119. */
  64120. synchronize(): void;
  64121. /**
  64122. * Creates a new MorphTargetManager from serialized data
  64123. * @param serializationObject defines the serialized data
  64124. * @param scene defines the hosting scene
  64125. * @returns the new MorphTargetManager
  64126. */
  64127. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  64128. }
  64129. }
  64130. declare module BABYLON {
  64131. /**
  64132. * Creates an instance based on a source mesh.
  64133. */
  64134. export class InstancedMesh extends AbstractMesh {
  64135. private _sourceMesh;
  64136. private _currentLOD;
  64137. /** @hidden */
  64138. _indexInSourceMeshInstanceArray: number;
  64139. constructor(name: string, source: Mesh);
  64140. /**
  64141. * Returns the string "InstancedMesh".
  64142. */
  64143. getClassName(): string;
  64144. /**
  64145. * If the source mesh receives shadows
  64146. */
  64147. readonly receiveShadows: boolean;
  64148. /**
  64149. * The material of the source mesh
  64150. */
  64151. readonly material: Nullable<Material>;
  64152. /**
  64153. * Visibility of the source mesh
  64154. */
  64155. readonly visibility: number;
  64156. /**
  64157. * Skeleton of the source mesh
  64158. */
  64159. readonly skeleton: Nullable<Skeleton>;
  64160. /**
  64161. * Rendering ground id of the source mesh
  64162. */
  64163. renderingGroupId: number;
  64164. /**
  64165. * Returns the total number of vertices (integer).
  64166. */
  64167. getTotalVertices(): number;
  64168. /**
  64169. * Returns a positive integer : the total number of indices in this mesh geometry.
  64170. * @returns the numner of indices or zero if the mesh has no geometry.
  64171. */
  64172. getTotalIndices(): number;
  64173. /**
  64174. * The source mesh of the instance
  64175. */
  64176. readonly sourceMesh: Mesh;
  64177. /**
  64178. * Is this node ready to be used/rendered
  64179. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  64180. * @return {boolean} is it ready
  64181. */
  64182. isReady(completeCheck?: boolean): boolean;
  64183. /**
  64184. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  64185. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  64186. * @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.
  64187. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  64188. */
  64189. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  64190. /**
  64191. * Sets the vertex data of the mesh geometry for the requested `kind`.
  64192. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  64193. * The `data` are either a numeric array either a Float32Array.
  64194. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  64195. * 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).
  64196. * Note that a new underlying VertexBuffer object is created each call.
  64197. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  64198. *
  64199. * Possible `kind` values :
  64200. * - VertexBuffer.PositionKind
  64201. * - VertexBuffer.UVKind
  64202. * - VertexBuffer.UV2Kind
  64203. * - VertexBuffer.UV3Kind
  64204. * - VertexBuffer.UV4Kind
  64205. * - VertexBuffer.UV5Kind
  64206. * - VertexBuffer.UV6Kind
  64207. * - VertexBuffer.ColorKind
  64208. * - VertexBuffer.MatricesIndicesKind
  64209. * - VertexBuffer.MatricesIndicesExtraKind
  64210. * - VertexBuffer.MatricesWeightsKind
  64211. * - VertexBuffer.MatricesWeightsExtraKind
  64212. *
  64213. * Returns the Mesh.
  64214. */
  64215. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  64216. /**
  64217. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  64218. * If the mesh has no geometry, it is simply returned as it is.
  64219. * The `data` are either a numeric array either a Float32Array.
  64220. * No new underlying VertexBuffer object is created.
  64221. * 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.
  64222. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  64223. *
  64224. * Possible `kind` values :
  64225. * - VertexBuffer.PositionKind
  64226. * - VertexBuffer.UVKind
  64227. * - VertexBuffer.UV2Kind
  64228. * - VertexBuffer.UV3Kind
  64229. * - VertexBuffer.UV4Kind
  64230. * - VertexBuffer.UV5Kind
  64231. * - VertexBuffer.UV6Kind
  64232. * - VertexBuffer.ColorKind
  64233. * - VertexBuffer.MatricesIndicesKind
  64234. * - VertexBuffer.MatricesIndicesExtraKind
  64235. * - VertexBuffer.MatricesWeightsKind
  64236. * - VertexBuffer.MatricesWeightsExtraKind
  64237. *
  64238. * Returns the Mesh.
  64239. */
  64240. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  64241. /**
  64242. * Sets the mesh indices.
  64243. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  64244. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  64245. * This method creates a new index buffer each call.
  64246. * Returns the Mesh.
  64247. */
  64248. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  64249. /**
  64250. * Boolean : True if the mesh owns the requested kind of data.
  64251. */
  64252. isVerticesDataPresent(kind: string): boolean;
  64253. /**
  64254. * Returns an array of indices (IndicesArray).
  64255. */
  64256. getIndices(): Nullable<IndicesArray>;
  64257. readonly _positions: Nullable<Vector3[]>;
  64258. /**
  64259. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  64260. * This means the mesh underlying bounding box and sphere are recomputed.
  64261. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  64262. * @returns the current mesh
  64263. */
  64264. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  64265. /** @hidden */
  64266. _preActivate(): InstancedMesh;
  64267. /** @hidden */
  64268. _activate(renderId: number): InstancedMesh;
  64269. /**
  64270. * Returns the current associated LOD AbstractMesh.
  64271. */
  64272. getLOD(camera: Camera): AbstractMesh;
  64273. /** @hidden */
  64274. _syncSubMeshes(): InstancedMesh;
  64275. /** @hidden */
  64276. _generatePointsArray(): boolean;
  64277. /**
  64278. * Creates a new InstancedMesh from the current mesh.
  64279. * - name (string) : the cloned mesh name
  64280. * - newParent (optional Node) : the optional Node to parent the clone to.
  64281. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  64282. *
  64283. * Returns the clone.
  64284. */
  64285. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  64286. /**
  64287. * Disposes the InstancedMesh.
  64288. * Returns nothing.
  64289. */
  64290. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  64291. }
  64292. }
  64293. declare module BABYLON {
  64294. /**
  64295. * Class for creating a cube texture
  64296. */
  64297. export class CubeTexture extends BaseTexture {
  64298. private _delayedOnLoad;
  64299. /**
  64300. * The url of the texture
  64301. */
  64302. url: string;
  64303. /**
  64304. * Gets or sets the center of the bounding box associated with the cube texture.
  64305. * It must define where the camera used to render the texture was set
  64306. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  64307. */
  64308. boundingBoxPosition: Vector3;
  64309. private _boundingBoxSize;
  64310. /**
  64311. * Gets or sets the size of the bounding box associated with the cube texture
  64312. * When defined, the cubemap will switch to local mode
  64313. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64314. * @example https://www.babylonjs-playground.com/#RNASML
  64315. */
  64316. /**
  64317. * Returns the bounding box size
  64318. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  64319. */
  64320. boundingBoxSize: Vector3;
  64321. protected _rotationY: number;
  64322. /**
  64323. * Sets texture matrix rotation angle around Y axis in radians.
  64324. */
  64325. /**
  64326. * Gets texture matrix rotation angle around Y axis radians.
  64327. */
  64328. rotationY: number;
  64329. /**
  64330. * Are mip maps generated for this texture or not.
  64331. */
  64332. readonly noMipmap: boolean;
  64333. private _noMipmap;
  64334. private _files;
  64335. private _extensions;
  64336. private _textureMatrix;
  64337. private _format;
  64338. private _createPolynomials;
  64339. /** @hidden */
  64340. _prefiltered: boolean;
  64341. /**
  64342. * Creates a cube texture from an array of image urls
  64343. * @param files defines an array of image urls
  64344. * @param scene defines the hosting scene
  64345. * @param noMipmap specifies if mip maps are not used
  64346. * @returns a cube texture
  64347. */
  64348. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  64349. /**
  64350. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  64351. * @param url defines the url of the prefiltered texture
  64352. * @param scene defines the scene the texture is attached to
  64353. * @param forcedExtension defines the extension of the file if different from the url
  64354. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  64355. * @return the prefiltered texture
  64356. */
  64357. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  64358. /**
  64359. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  64360. * as prefiltered data.
  64361. * @param rootUrl defines the url of the texture or the root name of the six images
  64362. * @param scene defines the scene the texture is attached to
  64363. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  64364. * @param noMipmap defines if mipmaps should be created or not
  64365. * @param files defines the six files to load for the different faces
  64366. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  64367. * @param onError defines a callback triggered in case of error during load
  64368. * @param format defines the internal format to use for the texture once loaded
  64369. * @param prefiltered defines whether or not the texture is created from prefiltered data
  64370. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  64371. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  64372. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  64373. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  64374. * @return the cube texture
  64375. */
  64376. 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);
  64377. /**
  64378. * Get the current class name of the texture useful for serialization or dynamic coding.
  64379. * @returns "CubeTexture"
  64380. */
  64381. getClassName(): string;
  64382. /**
  64383. * Update the url (and optional buffer) of this texture if url was null during construction.
  64384. * @param url the url of the texture
  64385. * @param forcedExtension defines the extension to use
  64386. * @param onLoad callback called when the texture is loaded (defaults to null)
  64387. */
  64388. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  64389. /**
  64390. * Delays loading of the cube texture
  64391. * @param forcedExtension defines the extension to use
  64392. */
  64393. delayLoad(forcedExtension?: string): void;
  64394. /**
  64395. * Returns the reflection texture matrix
  64396. * @returns the reflection texture matrix
  64397. */
  64398. getReflectionTextureMatrix(): Matrix;
  64399. /**
  64400. * Sets the reflection texture matrix
  64401. * @param value Reflection texture matrix
  64402. */
  64403. setReflectionTextureMatrix(value: Matrix): void;
  64404. /**
  64405. * Parses text to create a cube texture
  64406. * @param parsedTexture define the serialized text to read from
  64407. * @param scene defines the hosting scene
  64408. * @param rootUrl defines the root url of the cube texture
  64409. * @returns a cube texture
  64410. */
  64411. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  64412. /**
  64413. * Makes a clone, or deep copy, of the cube texture
  64414. * @returns a new cube texture
  64415. */
  64416. clone(): CubeTexture;
  64417. }
  64418. }
  64419. declare module BABYLON {
  64420. /** @hidden */
  64421. export var postprocessVertexShader: {
  64422. name: string;
  64423. shader: string;
  64424. };
  64425. }
  64426. declare module BABYLON {
  64427. /**
  64428. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  64429. * This is the base of the follow, arc rotate cameras and Free camera
  64430. * @see http://doc.babylonjs.com/features/cameras
  64431. */
  64432. export class TargetCamera extends Camera {
  64433. private static _RigCamTransformMatrix;
  64434. private static _TargetTransformMatrix;
  64435. private static _TargetFocalPoint;
  64436. /**
  64437. * Define the current direction the camera is moving to
  64438. */
  64439. cameraDirection: Vector3;
  64440. /**
  64441. * Define the current rotation the camera is rotating to
  64442. */
  64443. cameraRotation: Vector2;
  64444. /**
  64445. * When set, the up vector of the camera will be updated by the rotation of the camera
  64446. */
  64447. updateUpVectorFromRotation: boolean;
  64448. private _tmpQuaternion;
  64449. /**
  64450. * Define the current rotation of the camera
  64451. */
  64452. rotation: Vector3;
  64453. /**
  64454. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  64455. */
  64456. rotationQuaternion: Quaternion;
  64457. /**
  64458. * Define the current speed of the camera
  64459. */
  64460. speed: number;
  64461. /**
  64462. * Add cconstraint to the camera to prevent it to move freely in all directions and
  64463. * around all axis.
  64464. */
  64465. noRotationConstraint: boolean;
  64466. /**
  64467. * Define the current target of the camera as an object or a position.
  64468. */
  64469. lockedTarget: any;
  64470. /** @hidden */
  64471. _currentTarget: Vector3;
  64472. /** @hidden */
  64473. _initialFocalDistance: number;
  64474. /** @hidden */
  64475. _viewMatrix: Matrix;
  64476. /** @hidden */
  64477. _camMatrix: Matrix;
  64478. /** @hidden */
  64479. _cameraTransformMatrix: Matrix;
  64480. /** @hidden */
  64481. _cameraRotationMatrix: Matrix;
  64482. /** @hidden */
  64483. _referencePoint: Vector3;
  64484. /** @hidden */
  64485. _transformedReferencePoint: Vector3;
  64486. protected _globalCurrentTarget: Vector3;
  64487. protected _globalCurrentUpVector: Vector3;
  64488. /** @hidden */
  64489. _reset: () => void;
  64490. private _defaultUp;
  64491. /**
  64492. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  64493. * This is the base of the follow, arc rotate cameras and Free camera
  64494. * @see http://doc.babylonjs.com/features/cameras
  64495. * @param name Defines the name of the camera in the scene
  64496. * @param position Defines the start position of the camera in the scene
  64497. * @param scene Defines the scene the camera belongs to
  64498. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  64499. */
  64500. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  64501. /**
  64502. * Gets the position in front of the camera at a given distance.
  64503. * @param distance The distance from the camera we want the position to be
  64504. * @returns the position
  64505. */
  64506. getFrontPosition(distance: number): Vector3;
  64507. /** @hidden */
  64508. _getLockedTargetPosition(): Nullable<Vector3>;
  64509. private _storedPosition;
  64510. private _storedRotation;
  64511. private _storedRotationQuaternion;
  64512. /**
  64513. * Store current camera state of the camera (fov, position, rotation, etc..)
  64514. * @returns the camera
  64515. */
  64516. storeState(): Camera;
  64517. /**
  64518. * Restored camera state. You must call storeState() first
  64519. * @returns whether it was successful or not
  64520. * @hidden
  64521. */
  64522. _restoreStateValues(): boolean;
  64523. /** @hidden */
  64524. _initCache(): void;
  64525. /** @hidden */
  64526. _updateCache(ignoreParentClass?: boolean): void;
  64527. /** @hidden */
  64528. _isSynchronizedViewMatrix(): boolean;
  64529. /** @hidden */
  64530. _computeLocalCameraSpeed(): number;
  64531. /** @hidden */
  64532. setTarget(target: Vector3): void;
  64533. /**
  64534. * Return the current target position of the camera. This value is expressed in local space.
  64535. * @returns the target position
  64536. */
  64537. getTarget(): Vector3;
  64538. /** @hidden */
  64539. _decideIfNeedsToMove(): boolean;
  64540. /** @hidden */
  64541. _updatePosition(): void;
  64542. /** @hidden */
  64543. _checkInputs(): void;
  64544. protected _updateCameraRotationMatrix(): void;
  64545. /**
  64546. * 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)
  64547. * @returns the current camera
  64548. */
  64549. private _rotateUpVectorWithCameraRotationMatrix;
  64550. private _cachedRotationZ;
  64551. private _cachedQuaternionRotationZ;
  64552. /** @hidden */
  64553. _getViewMatrix(): Matrix;
  64554. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  64555. /**
  64556. * @hidden
  64557. */
  64558. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  64559. /**
  64560. * @hidden
  64561. */
  64562. _updateRigCameras(): void;
  64563. private _getRigCamPositionAndTarget;
  64564. /**
  64565. * Gets the current object class name.
  64566. * @return the class name
  64567. */
  64568. getClassName(): string;
  64569. }
  64570. }
  64571. declare module BABYLON {
  64572. /**
  64573. * @ignore
  64574. * This is a list of all the different input types that are available in the application.
  64575. * Fo instance: ArcRotateCameraGamepadInput...
  64576. */
  64577. export var CameraInputTypes: {};
  64578. /**
  64579. * This is the contract to implement in order to create a new input class.
  64580. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  64581. */
  64582. export interface ICameraInput<TCamera extends Camera> {
  64583. /**
  64584. * Defines the camera the input is attached to.
  64585. */
  64586. camera: Nullable<TCamera>;
  64587. /**
  64588. * Gets the class name of the current intput.
  64589. * @returns the class name
  64590. */
  64591. getClassName(): string;
  64592. /**
  64593. * Get the friendly name associated with the input class.
  64594. * @returns the input friendly name
  64595. */
  64596. getSimpleName(): string;
  64597. /**
  64598. * Attach the input controls to a specific dom element to get the input from.
  64599. * @param element Defines the element the controls should be listened from
  64600. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64601. */
  64602. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  64603. /**
  64604. * Detach the current controls from the specified dom element.
  64605. * @param element Defines the element to stop listening the inputs from
  64606. */
  64607. detachControl(element: Nullable<HTMLElement>): void;
  64608. /**
  64609. * Update the current camera state depending on the inputs that have been used this frame.
  64610. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  64611. */
  64612. checkInputs?: () => void;
  64613. }
  64614. /**
  64615. * Represents a map of input types to input instance or input index to input instance.
  64616. */
  64617. export interface CameraInputsMap<TCamera extends Camera> {
  64618. /**
  64619. * Accessor to the input by input type.
  64620. */
  64621. [name: string]: ICameraInput<TCamera>;
  64622. /**
  64623. * Accessor to the input by input index.
  64624. */
  64625. [idx: number]: ICameraInput<TCamera>;
  64626. }
  64627. /**
  64628. * This represents the input manager used within a camera.
  64629. * It helps dealing with all the different kind of input attached to a camera.
  64630. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64631. */
  64632. export class CameraInputsManager<TCamera extends Camera> {
  64633. /**
  64634. * Defines the list of inputs attahed to the camera.
  64635. */
  64636. attached: CameraInputsMap<TCamera>;
  64637. /**
  64638. * Defines the dom element the camera is collecting inputs from.
  64639. * This is null if the controls have not been attached.
  64640. */
  64641. attachedElement: Nullable<HTMLElement>;
  64642. /**
  64643. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64644. */
  64645. noPreventDefault: boolean;
  64646. /**
  64647. * Defined the camera the input manager belongs to.
  64648. */
  64649. camera: TCamera;
  64650. /**
  64651. * Update the current camera state depending on the inputs that have been used this frame.
  64652. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  64653. */
  64654. checkInputs: () => void;
  64655. /**
  64656. * Instantiate a new Camera Input Manager.
  64657. * @param camera Defines the camera the input manager blongs to
  64658. */
  64659. constructor(camera: TCamera);
  64660. /**
  64661. * Add an input method to a camera
  64662. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64663. * @param input camera input method
  64664. */
  64665. add(input: ICameraInput<TCamera>): void;
  64666. /**
  64667. * Remove a specific input method from a camera
  64668. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  64669. * @param inputToRemove camera input method
  64670. */
  64671. remove(inputToRemove: ICameraInput<TCamera>): void;
  64672. /**
  64673. * Remove a specific input type from a camera
  64674. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  64675. * @param inputType the type of the input to remove
  64676. */
  64677. removeByType(inputType: string): void;
  64678. private _addCheckInputs;
  64679. /**
  64680. * Attach the input controls to the currently attached dom element to listen the events from.
  64681. * @param input Defines the input to attach
  64682. */
  64683. attachInput(input: ICameraInput<TCamera>): void;
  64684. /**
  64685. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  64686. * @param element Defines the dom element to collect the events from
  64687. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64688. */
  64689. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  64690. /**
  64691. * Detach the current manager inputs controls from a specific dom element.
  64692. * @param element Defines the dom element to collect the events from
  64693. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  64694. */
  64695. detachElement(element: HTMLElement, disconnect?: boolean): void;
  64696. /**
  64697. * Rebuild the dynamic inputCheck function from the current list of
  64698. * defined inputs in the manager.
  64699. */
  64700. rebuildInputCheck(): void;
  64701. /**
  64702. * Remove all attached input methods from a camera
  64703. */
  64704. clear(): void;
  64705. /**
  64706. * Serialize the current input manager attached to a camera.
  64707. * This ensures than once parsed,
  64708. * the input associated to the camera will be identical to the current ones
  64709. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  64710. */
  64711. serialize(serializedCamera: any): void;
  64712. /**
  64713. * Parses an input manager serialized JSON to restore the previous list of inputs
  64714. * and states associated to a camera.
  64715. * @param parsedCamera Defines the JSON to parse
  64716. */
  64717. parse(parsedCamera: any): void;
  64718. }
  64719. }
  64720. declare module BABYLON {
  64721. /**
  64722. * Gather the list of keyboard event types as constants.
  64723. */
  64724. export class KeyboardEventTypes {
  64725. /**
  64726. * The keydown event is fired when a key becomes active (pressed).
  64727. */
  64728. static readonly KEYDOWN: number;
  64729. /**
  64730. * The keyup event is fired when a key has been released.
  64731. */
  64732. static readonly KEYUP: number;
  64733. }
  64734. /**
  64735. * This class is used to store keyboard related info for the onKeyboardObservable event.
  64736. */
  64737. export class KeyboardInfo {
  64738. /**
  64739. * Defines the type of event (KeyboardEventTypes)
  64740. */
  64741. type: number;
  64742. /**
  64743. * Defines the related dom event
  64744. */
  64745. event: KeyboardEvent;
  64746. /**
  64747. * Instantiates a new keyboard info.
  64748. * This class is used to store keyboard related info for the onKeyboardObservable event.
  64749. * @param type Defines the type of event (KeyboardEventTypes)
  64750. * @param event Defines the related dom event
  64751. */
  64752. constructor(
  64753. /**
  64754. * Defines the type of event (KeyboardEventTypes)
  64755. */
  64756. type: number,
  64757. /**
  64758. * Defines the related dom event
  64759. */
  64760. event: KeyboardEvent);
  64761. }
  64762. /**
  64763. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  64764. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  64765. */
  64766. export class KeyboardInfoPre extends KeyboardInfo {
  64767. /**
  64768. * Defines the type of event (KeyboardEventTypes)
  64769. */
  64770. type: number;
  64771. /**
  64772. * Defines the related dom event
  64773. */
  64774. event: KeyboardEvent;
  64775. /**
  64776. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  64777. */
  64778. skipOnPointerObservable: boolean;
  64779. /**
  64780. * Instantiates a new keyboard pre info.
  64781. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  64782. * @param type Defines the type of event (KeyboardEventTypes)
  64783. * @param event Defines the related dom event
  64784. */
  64785. constructor(
  64786. /**
  64787. * Defines the type of event (KeyboardEventTypes)
  64788. */
  64789. type: number,
  64790. /**
  64791. * Defines the related dom event
  64792. */
  64793. event: KeyboardEvent);
  64794. }
  64795. }
  64796. declare module BABYLON {
  64797. /**
  64798. * Manage the keyboard inputs to control the movement of a free camera.
  64799. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64800. */
  64801. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  64802. /**
  64803. * Defines the camera the input is attached to.
  64804. */
  64805. camera: FreeCamera;
  64806. /**
  64807. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  64808. */
  64809. keysUp: number[];
  64810. /**
  64811. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  64812. */
  64813. keysDown: number[];
  64814. /**
  64815. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  64816. */
  64817. keysLeft: number[];
  64818. /**
  64819. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  64820. */
  64821. keysRight: number[];
  64822. private _keys;
  64823. private _onCanvasBlurObserver;
  64824. private _onKeyboardObserver;
  64825. private _engine;
  64826. private _scene;
  64827. /**
  64828. * Attach the input controls to a specific dom element to get the input from.
  64829. * @param element Defines the element the controls should be listened from
  64830. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64831. */
  64832. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  64833. /**
  64834. * Detach the current controls from the specified dom element.
  64835. * @param element Defines the element to stop listening the inputs from
  64836. */
  64837. detachControl(element: Nullable<HTMLElement>): void;
  64838. /**
  64839. * Update the current camera state depending on the inputs that have been used this frame.
  64840. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  64841. */
  64842. checkInputs(): void;
  64843. /**
  64844. * Gets the class name of the current intput.
  64845. * @returns the class name
  64846. */
  64847. getClassName(): string;
  64848. /** @hidden */
  64849. _onLostFocus(): void;
  64850. /**
  64851. * Get the friendly name associated with the input class.
  64852. * @returns the input friendly name
  64853. */
  64854. getSimpleName(): string;
  64855. }
  64856. }
  64857. declare module BABYLON {
  64858. /**
  64859. * Interface used to define ActionEvent
  64860. */
  64861. export interface IActionEvent {
  64862. /** The mesh or sprite that triggered the action */
  64863. source: any;
  64864. /** The X mouse cursor position at the time of the event */
  64865. pointerX: number;
  64866. /** The Y mouse cursor position at the time of the event */
  64867. pointerY: number;
  64868. /** The mesh that is currently pointed at (can be null) */
  64869. meshUnderPointer: Nullable<AbstractMesh>;
  64870. /** the original (browser) event that triggered the ActionEvent */
  64871. sourceEvent?: any;
  64872. /** additional data for the event */
  64873. additionalData?: any;
  64874. }
  64875. /**
  64876. * ActionEvent is the event being sent when an action is triggered.
  64877. */
  64878. export class ActionEvent implements IActionEvent {
  64879. /** The mesh or sprite that triggered the action */
  64880. source: any;
  64881. /** The X mouse cursor position at the time of the event */
  64882. pointerX: number;
  64883. /** The Y mouse cursor position at the time of the event */
  64884. pointerY: number;
  64885. /** The mesh that is currently pointed at (can be null) */
  64886. meshUnderPointer: Nullable<AbstractMesh>;
  64887. /** the original (browser) event that triggered the ActionEvent */
  64888. sourceEvent?: any;
  64889. /** additional data for the event */
  64890. additionalData?: any;
  64891. /**
  64892. * Creates a new ActionEvent
  64893. * @param source The mesh or sprite that triggered the action
  64894. * @param pointerX The X mouse cursor position at the time of the event
  64895. * @param pointerY The Y mouse cursor position at the time of the event
  64896. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  64897. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  64898. * @param additionalData additional data for the event
  64899. */
  64900. constructor(
  64901. /** The mesh or sprite that triggered the action */
  64902. source: any,
  64903. /** The X mouse cursor position at the time of the event */
  64904. pointerX: number,
  64905. /** The Y mouse cursor position at the time of the event */
  64906. pointerY: number,
  64907. /** The mesh that is currently pointed at (can be null) */
  64908. meshUnderPointer: Nullable<AbstractMesh>,
  64909. /** the original (browser) event that triggered the ActionEvent */
  64910. sourceEvent?: any,
  64911. /** additional data for the event */
  64912. additionalData?: any);
  64913. /**
  64914. * Helper function to auto-create an ActionEvent from a source mesh.
  64915. * @param source The source mesh that triggered the event
  64916. * @param evt The original (browser) event
  64917. * @param additionalData additional data for the event
  64918. * @returns the new ActionEvent
  64919. */
  64920. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  64921. /**
  64922. * Helper function to auto-create an ActionEvent from a source sprite
  64923. * @param source The source sprite that triggered the event
  64924. * @param scene Scene associated with the sprite
  64925. * @param evt The original (browser) event
  64926. * @param additionalData additional data for the event
  64927. * @returns the new ActionEvent
  64928. */
  64929. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  64930. /**
  64931. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  64932. * @param scene the scene where the event occurred
  64933. * @param evt The original (browser) event
  64934. * @returns the new ActionEvent
  64935. */
  64936. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  64937. /**
  64938. * Helper function to auto-create an ActionEvent from a primitive
  64939. * @param prim defines the target primitive
  64940. * @param pointerPos defines the pointer position
  64941. * @param evt The original (browser) event
  64942. * @param additionalData additional data for the event
  64943. * @returns the new ActionEvent
  64944. */
  64945. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  64946. }
  64947. }
  64948. declare module BABYLON {
  64949. /**
  64950. * Interface describing all the common properties and methods a shadow light needs to implement.
  64951. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  64952. * as well as binding the different shadow properties to the effects.
  64953. */
  64954. export interface IShadowLight extends Light {
  64955. /**
  64956. * The light id in the scene (used in scene.findLighById for instance)
  64957. */
  64958. id: string;
  64959. /**
  64960. * The position the shdow will be casted from.
  64961. */
  64962. position: Vector3;
  64963. /**
  64964. * In 2d mode (needCube being false), the direction used to cast the shadow.
  64965. */
  64966. direction: Vector3;
  64967. /**
  64968. * The transformed position. Position of the light in world space taking parenting in account.
  64969. */
  64970. transformedPosition: Vector3;
  64971. /**
  64972. * The transformed direction. Direction of the light in world space taking parenting in account.
  64973. */
  64974. transformedDirection: Vector3;
  64975. /**
  64976. * The friendly name of the light in the scene.
  64977. */
  64978. name: string;
  64979. /**
  64980. * Defines the shadow projection clipping minimum z value.
  64981. */
  64982. shadowMinZ: number;
  64983. /**
  64984. * Defines the shadow projection clipping maximum z value.
  64985. */
  64986. shadowMaxZ: number;
  64987. /**
  64988. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  64989. * @returns true if the information has been computed, false if it does not need to (no parenting)
  64990. */
  64991. computeTransformedInformation(): boolean;
  64992. /**
  64993. * Gets the scene the light belongs to.
  64994. * @returns The scene
  64995. */
  64996. getScene(): Scene;
  64997. /**
  64998. * Callback defining a custom Projection Matrix Builder.
  64999. * This can be used to override the default projection matrix computation.
  65000. */
  65001. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  65002. /**
  65003. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  65004. * @param matrix The materix to updated with the projection information
  65005. * @param viewMatrix The transform matrix of the light
  65006. * @param renderList The list of mesh to render in the map
  65007. * @returns The current light
  65008. */
  65009. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  65010. /**
  65011. * Gets the current depth scale used in ESM.
  65012. * @returns The scale
  65013. */
  65014. getDepthScale(): number;
  65015. /**
  65016. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  65017. * @returns true if a cube texture needs to be use
  65018. */
  65019. needCube(): boolean;
  65020. /**
  65021. * Detects if the projection matrix requires to be recomputed this frame.
  65022. * @returns true if it requires to be recomputed otherwise, false.
  65023. */
  65024. needProjectionMatrixCompute(): boolean;
  65025. /**
  65026. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  65027. */
  65028. forceProjectionMatrixCompute(): void;
  65029. /**
  65030. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  65031. * @param faceIndex The index of the face we are computed the direction to generate shadow
  65032. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  65033. */
  65034. getShadowDirection(faceIndex?: number): Vector3;
  65035. /**
  65036. * Gets the minZ used for shadow according to both the scene and the light.
  65037. * @param activeCamera The camera we are returning the min for
  65038. * @returns the depth min z
  65039. */
  65040. getDepthMinZ(activeCamera: Camera): number;
  65041. /**
  65042. * Gets the maxZ used for shadow according to both the scene and the light.
  65043. * @param activeCamera The camera we are returning the max for
  65044. * @returns the depth max z
  65045. */
  65046. getDepthMaxZ(activeCamera: Camera): number;
  65047. }
  65048. /**
  65049. * Base implementation IShadowLight
  65050. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  65051. */
  65052. export abstract class ShadowLight extends Light implements IShadowLight {
  65053. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  65054. protected _position: Vector3;
  65055. protected _setPosition(value: Vector3): void;
  65056. /**
  65057. * Sets the position the shadow will be casted from. Also use as the light position for both
  65058. * point and spot lights.
  65059. */
  65060. /**
  65061. * Sets the position the shadow will be casted from. Also use as the light position for both
  65062. * point and spot lights.
  65063. */
  65064. position: Vector3;
  65065. protected _direction: Vector3;
  65066. protected _setDirection(value: Vector3): void;
  65067. /**
  65068. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  65069. * Also use as the light direction on spot and directional lights.
  65070. */
  65071. /**
  65072. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  65073. * Also use as the light direction on spot and directional lights.
  65074. */
  65075. direction: Vector3;
  65076. private _shadowMinZ;
  65077. /**
  65078. * Gets the shadow projection clipping minimum z value.
  65079. */
  65080. /**
  65081. * Sets the shadow projection clipping minimum z value.
  65082. */
  65083. shadowMinZ: number;
  65084. private _shadowMaxZ;
  65085. /**
  65086. * Sets the shadow projection clipping maximum z value.
  65087. */
  65088. /**
  65089. * Gets the shadow projection clipping maximum z value.
  65090. */
  65091. shadowMaxZ: number;
  65092. /**
  65093. * Callback defining a custom Projection Matrix Builder.
  65094. * This can be used to override the default projection matrix computation.
  65095. */
  65096. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  65097. /**
  65098. * The transformed position. Position of the light in world space taking parenting in account.
  65099. */
  65100. transformedPosition: Vector3;
  65101. /**
  65102. * The transformed direction. Direction of the light in world space taking parenting in account.
  65103. */
  65104. transformedDirection: Vector3;
  65105. private _needProjectionMatrixCompute;
  65106. /**
  65107. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  65108. * @returns true if the information has been computed, false if it does not need to (no parenting)
  65109. */
  65110. computeTransformedInformation(): boolean;
  65111. /**
  65112. * Return the depth scale used for the shadow map.
  65113. * @returns the depth scale.
  65114. */
  65115. getDepthScale(): number;
  65116. /**
  65117. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  65118. * @param faceIndex The index of the face we are computed the direction to generate shadow
  65119. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  65120. */
  65121. getShadowDirection(faceIndex?: number): Vector3;
  65122. /**
  65123. * Returns the ShadowLight absolute position in the World.
  65124. * @returns the position vector in world space
  65125. */
  65126. getAbsolutePosition(): Vector3;
  65127. /**
  65128. * Sets the ShadowLight direction toward the passed target.
  65129. * @param target The point tot target in local space
  65130. * @returns the updated ShadowLight direction
  65131. */
  65132. setDirectionToTarget(target: Vector3): Vector3;
  65133. /**
  65134. * Returns the light rotation in euler definition.
  65135. * @returns the x y z rotation in local space.
  65136. */
  65137. getRotation(): Vector3;
  65138. /**
  65139. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  65140. * @returns true if a cube texture needs to be use
  65141. */
  65142. needCube(): boolean;
  65143. /**
  65144. * Detects if the projection matrix requires to be recomputed this frame.
  65145. * @returns true if it requires to be recomputed otherwise, false.
  65146. */
  65147. needProjectionMatrixCompute(): boolean;
  65148. /**
  65149. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  65150. */
  65151. forceProjectionMatrixCompute(): void;
  65152. /** @hidden */
  65153. _initCache(): void;
  65154. /** @hidden */
  65155. _isSynchronized(): boolean;
  65156. /**
  65157. * Computes the world matrix of the node
  65158. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65159. * @returns the world matrix
  65160. */
  65161. computeWorldMatrix(force?: boolean): Matrix;
  65162. /**
  65163. * Gets the minZ used for shadow according to both the scene and the light.
  65164. * @param activeCamera The camera we are returning the min for
  65165. * @returns the depth min z
  65166. */
  65167. getDepthMinZ(activeCamera: Camera): number;
  65168. /**
  65169. * Gets the maxZ used for shadow according to both the scene and the light.
  65170. * @param activeCamera The camera we are returning the max for
  65171. * @returns the depth max z
  65172. */
  65173. getDepthMaxZ(activeCamera: Camera): number;
  65174. /**
  65175. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  65176. * @param matrix The materix to updated with the projection information
  65177. * @param viewMatrix The transform matrix of the light
  65178. * @param renderList The list of mesh to render in the map
  65179. * @returns The current light
  65180. */
  65181. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  65182. }
  65183. }
  65184. declare module BABYLON {
  65185. /**
  65186. * "Static Class" containing the most commonly used helper while dealing with material for
  65187. * rendering purpose.
  65188. *
  65189. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  65190. *
  65191. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  65192. */
  65193. export class MaterialHelper {
  65194. /**
  65195. * Bind the current view position to an effect.
  65196. * @param effect The effect to be bound
  65197. * @param scene The scene the eyes position is used from
  65198. */
  65199. static BindEyePosition(effect: Effect, scene: Scene): void;
  65200. /**
  65201. * Helps preparing the defines values about the UVs in used in the effect.
  65202. * UVs are shared as much as we can accross channels in the shaders.
  65203. * @param texture The texture we are preparing the UVs for
  65204. * @param defines The defines to update
  65205. * @param key The channel key "diffuse", "specular"... used in the shader
  65206. */
  65207. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  65208. /**
  65209. * Binds a texture matrix value to its corrsponding uniform
  65210. * @param texture The texture to bind the matrix for
  65211. * @param uniformBuffer The uniform buffer receivin the data
  65212. * @param key The channel key "diffuse", "specular"... used in the shader
  65213. */
  65214. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  65215. /**
  65216. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  65217. * @param mesh defines the current mesh
  65218. * @param scene defines the current scene
  65219. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  65220. * @param pointsCloud defines if point cloud rendering has to be turned on
  65221. * @param fogEnabled defines if fog has to be turned on
  65222. * @param alphaTest defines if alpha testing has to be turned on
  65223. * @param defines defines the current list of defines
  65224. */
  65225. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  65226. /**
  65227. * Helper used to prepare the list of defines associated with frame values for shader compilation
  65228. * @param scene defines the current scene
  65229. * @param engine defines the current engine
  65230. * @param defines specifies the list of active defines
  65231. * @param useInstances defines if instances have to be turned on
  65232. * @param useClipPlane defines if clip plane have to be turned on
  65233. */
  65234. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  65235. /**
  65236. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  65237. * @param mesh The mesh containing the geometry data we will draw
  65238. * @param defines The defines to update
  65239. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  65240. * @param useBones Precise whether bones should be used or not (override mesh info)
  65241. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  65242. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  65243. * @returns false if defines are considered not dirty and have not been checked
  65244. */
  65245. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  65246. /**
  65247. * Prepares the defines related to the light information passed in parameter
  65248. * @param scene The scene we are intending to draw
  65249. * @param mesh The mesh the effect is compiling for
  65250. * @param defines The defines to update
  65251. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  65252. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  65253. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  65254. * @returns true if normals will be required for the rest of the effect
  65255. */
  65256. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  65257. /**
  65258. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  65259. * that won t be acctive due to defines being turned off.
  65260. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  65261. * @param samplersList The samplers list
  65262. * @param defines The defines helping in the list generation
  65263. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  65264. */
  65265. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  65266. /**
  65267. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  65268. * @param defines The defines to update while falling back
  65269. * @param fallbacks The authorized effect fallbacks
  65270. * @param maxSimultaneousLights The maximum number of lights allowed
  65271. * @param rank the current rank of the Effect
  65272. * @returns The newly affected rank
  65273. */
  65274. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  65275. /**
  65276. * Prepares the list of attributes required for morph targets according to the effect defines.
  65277. * @param attribs The current list of supported attribs
  65278. * @param mesh The mesh to prepare the morph targets attributes for
  65279. * @param defines The current Defines of the effect
  65280. */
  65281. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  65282. /**
  65283. * Prepares the list of attributes required for bones according to the effect defines.
  65284. * @param attribs The current list of supported attribs
  65285. * @param mesh The mesh to prepare the bones attributes for
  65286. * @param defines The current Defines of the effect
  65287. * @param fallbacks The current efffect fallback strategy
  65288. */
  65289. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  65290. /**
  65291. * Prepares the list of attributes required for instances according to the effect defines.
  65292. * @param attribs The current list of supported attribs
  65293. * @param defines The current Defines of the effect
  65294. */
  65295. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  65296. /**
  65297. * Binds the light shadow information to the effect for the given mesh.
  65298. * @param light The light containing the generator
  65299. * @param scene The scene the lights belongs to
  65300. * @param mesh The mesh we are binding the information to render
  65301. * @param lightIndex The light index in the effect used to render the mesh
  65302. * @param effect The effect we are binding the data to
  65303. */
  65304. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  65305. /**
  65306. * Binds the light information to the effect.
  65307. * @param light The light containing the generator
  65308. * @param effect The effect we are binding the data to
  65309. * @param lightIndex The light index in the effect used to render
  65310. */
  65311. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  65312. /**
  65313. * Binds the lights information from the scene to the effect for the given mesh.
  65314. * @param scene The scene the lights belongs to
  65315. * @param mesh The mesh we are binding the information to render
  65316. * @param effect The effect we are binding the data to
  65317. * @param defines The generated defines for the effect
  65318. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  65319. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  65320. */
  65321. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  65322. private static _tempFogColor;
  65323. /**
  65324. * Binds the fog information from the scene to the effect for the given mesh.
  65325. * @param scene The scene the lights belongs to
  65326. * @param mesh The mesh we are binding the information to render
  65327. * @param effect The effect we are binding the data to
  65328. * @param linearSpace Defines if the fog effect is applied in linear space
  65329. */
  65330. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  65331. /**
  65332. * Binds the bones information from the mesh to the effect.
  65333. * @param mesh The mesh we are binding the information to render
  65334. * @param effect The effect we are binding the data to
  65335. */
  65336. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  65337. /**
  65338. * Binds the morph targets information from the mesh to the effect.
  65339. * @param abstractMesh The mesh we are binding the information to render
  65340. * @param effect The effect we are binding the data to
  65341. */
  65342. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  65343. /**
  65344. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  65345. * @param defines The generated defines used in the effect
  65346. * @param effect The effect we are binding the data to
  65347. * @param scene The scene we are willing to render with logarithmic scale for
  65348. */
  65349. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  65350. /**
  65351. * Binds the clip plane information from the scene to the effect.
  65352. * @param scene The scene the clip plane information are extracted from
  65353. * @param effect The effect we are binding the data to
  65354. */
  65355. static BindClipPlane(effect: Effect, scene: Scene): void;
  65356. }
  65357. }
  65358. declare module BABYLON {
  65359. /** @hidden */
  65360. export var kernelBlurVaryingDeclaration: {
  65361. name: string;
  65362. shader: string;
  65363. };
  65364. }
  65365. declare module BABYLON {
  65366. /** @hidden */
  65367. export var kernelBlurFragment: {
  65368. name: string;
  65369. shader: string;
  65370. };
  65371. }
  65372. declare module BABYLON {
  65373. /** @hidden */
  65374. export var kernelBlurFragment2: {
  65375. name: string;
  65376. shader: string;
  65377. };
  65378. }
  65379. declare module BABYLON {
  65380. /** @hidden */
  65381. export var kernelBlurPixelShader: {
  65382. name: string;
  65383. shader: string;
  65384. };
  65385. }
  65386. declare module BABYLON {
  65387. /** @hidden */
  65388. export var kernelBlurVertex: {
  65389. name: string;
  65390. shader: string;
  65391. };
  65392. }
  65393. declare module BABYLON {
  65394. /** @hidden */
  65395. export var kernelBlurVertexShader: {
  65396. name: string;
  65397. shader: string;
  65398. };
  65399. }
  65400. declare module BABYLON {
  65401. /**
  65402. * The Blur Post Process which blurs an image based on a kernel and direction.
  65403. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  65404. */
  65405. export class BlurPostProcess extends PostProcess {
  65406. /** The direction in which to blur the image. */
  65407. direction: Vector2;
  65408. private blockCompilation;
  65409. protected _kernel: number;
  65410. protected _idealKernel: number;
  65411. protected _packedFloat: boolean;
  65412. private _staticDefines;
  65413. /**
  65414. * Sets the length in pixels of the blur sample region
  65415. */
  65416. /**
  65417. * Gets the length in pixels of the blur sample region
  65418. */
  65419. kernel: number;
  65420. /**
  65421. * Sets wether or not the blur needs to unpack/repack floats
  65422. */
  65423. /**
  65424. * Gets wether or not the blur is unpacking/repacking floats
  65425. */
  65426. packedFloat: boolean;
  65427. /**
  65428. * Creates a new instance BlurPostProcess
  65429. * @param name The name of the effect.
  65430. * @param direction The direction in which to blur the image.
  65431. * @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.
  65432. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  65433. * @param camera The camera to apply the render pass to.
  65434. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65435. * @param engine The engine which the post process will be applied. (default: current engine)
  65436. * @param reusable If the post process can be reused on the same frame. (default: false)
  65437. * @param textureType Type of textures used when performing the post process. (default: 0)
  65438. * @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)
  65439. */
  65440. constructor(name: string,
  65441. /** The direction in which to blur the image. */
  65442. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  65443. /**
  65444. * Updates the effect with the current post process compile time values and recompiles the shader.
  65445. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65446. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65447. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65448. * @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
  65449. * @param onCompiled Called when the shader has been compiled.
  65450. * @param onError Called if there is an error when compiling a shader.
  65451. */
  65452. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65453. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65454. /**
  65455. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  65456. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  65457. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  65458. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  65459. * The gaps between physical kernels are compensated for in the weighting of the samples
  65460. * @param idealKernel Ideal blur kernel.
  65461. * @return Nearest best kernel.
  65462. */
  65463. protected _nearestBestKernel(idealKernel: number): number;
  65464. /**
  65465. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  65466. * @param x The point on the Gaussian distribution to sample.
  65467. * @return the value of the Gaussian function at x.
  65468. */
  65469. protected _gaussianWeight(x: number): number;
  65470. /**
  65471. * Generates a string that can be used as a floating point number in GLSL.
  65472. * @param x Value to print.
  65473. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  65474. * @return GLSL float string.
  65475. */
  65476. protected _glslFloat(x: number, decimalFigures?: number): string;
  65477. }
  65478. }
  65479. declare module BABYLON {
  65480. /** @hidden */
  65481. export var shadowMapPixelShader: {
  65482. name: string;
  65483. shader: string;
  65484. };
  65485. }
  65486. declare module BABYLON {
  65487. /** @hidden */
  65488. export var bonesDeclaration: {
  65489. name: string;
  65490. shader: string;
  65491. };
  65492. }
  65493. declare module BABYLON {
  65494. /** @hidden */
  65495. export var morphTargetsVertexGlobalDeclaration: {
  65496. name: string;
  65497. shader: string;
  65498. };
  65499. }
  65500. declare module BABYLON {
  65501. /** @hidden */
  65502. export var morphTargetsVertexDeclaration: {
  65503. name: string;
  65504. shader: string;
  65505. };
  65506. }
  65507. declare module BABYLON {
  65508. /** @hidden */
  65509. export var instancesDeclaration: {
  65510. name: string;
  65511. shader: string;
  65512. };
  65513. }
  65514. declare module BABYLON {
  65515. /** @hidden */
  65516. export var helperFunctions: {
  65517. name: string;
  65518. shader: string;
  65519. };
  65520. }
  65521. declare module BABYLON {
  65522. /** @hidden */
  65523. export var morphTargetsVertex: {
  65524. name: string;
  65525. shader: string;
  65526. };
  65527. }
  65528. declare module BABYLON {
  65529. /** @hidden */
  65530. export var instancesVertex: {
  65531. name: string;
  65532. shader: string;
  65533. };
  65534. }
  65535. declare module BABYLON {
  65536. /** @hidden */
  65537. export var bonesVertex: {
  65538. name: string;
  65539. shader: string;
  65540. };
  65541. }
  65542. declare module BABYLON {
  65543. /** @hidden */
  65544. export var shadowMapVertexShader: {
  65545. name: string;
  65546. shader: string;
  65547. };
  65548. }
  65549. declare module BABYLON {
  65550. /** @hidden */
  65551. export var depthBoxBlurPixelShader: {
  65552. name: string;
  65553. shader: string;
  65554. };
  65555. }
  65556. declare module BABYLON {
  65557. /**
  65558. * Defines the options associated with the creation of a custom shader for a shadow generator.
  65559. */
  65560. export interface ICustomShaderOptions {
  65561. /**
  65562. * Gets or sets the custom shader name to use
  65563. */
  65564. shaderName: string;
  65565. /**
  65566. * The list of attribute names used in the shader
  65567. */
  65568. attributes?: string[];
  65569. /**
  65570. * The list of unifrom names used in the shader
  65571. */
  65572. uniforms?: string[];
  65573. /**
  65574. * The list of sampler names used in the shader
  65575. */
  65576. samplers?: string[];
  65577. /**
  65578. * The list of defines used in the shader
  65579. */
  65580. defines?: string[];
  65581. }
  65582. /**
  65583. * Interface to implement to create a shadow generator compatible with BJS.
  65584. */
  65585. export interface IShadowGenerator {
  65586. /**
  65587. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  65588. * @returns The render target texture if present otherwise, null
  65589. */
  65590. getShadowMap(): Nullable<RenderTargetTexture>;
  65591. /**
  65592. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  65593. * @returns The render target texture if the shadow map is present otherwise, null
  65594. */
  65595. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  65596. /**
  65597. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  65598. * @param subMesh The submesh we want to render in the shadow map
  65599. * @param useInstances Defines wether will draw in the map using instances
  65600. * @returns true if ready otherwise, false
  65601. */
  65602. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65603. /**
  65604. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  65605. * @param defines Defines of the material we want to update
  65606. * @param lightIndex Index of the light in the enabled light list of the material
  65607. */
  65608. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  65609. /**
  65610. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  65611. * defined in the generator but impacting the effect).
  65612. * It implies the unifroms available on the materials are the standard BJS ones.
  65613. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  65614. * @param effect The effect we are binfing the information for
  65615. */
  65616. bindShadowLight(lightIndex: string, effect: Effect): void;
  65617. /**
  65618. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  65619. * (eq to shadow prjection matrix * light transform matrix)
  65620. * @returns The transform matrix used to create the shadow map
  65621. */
  65622. getTransformMatrix(): Matrix;
  65623. /**
  65624. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  65625. * Cube and 2D textures for instance.
  65626. */
  65627. recreateShadowMap(): void;
  65628. /**
  65629. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  65630. * @param onCompiled Callback triggered at the and of the effects compilation
  65631. * @param options Sets of optional options forcing the compilation with different modes
  65632. */
  65633. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  65634. useInstances: boolean;
  65635. }>): void;
  65636. /**
  65637. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  65638. * @param options Sets of optional options forcing the compilation with different modes
  65639. * @returns A promise that resolves when the compilation completes
  65640. */
  65641. forceCompilationAsync(options?: Partial<{
  65642. useInstances: boolean;
  65643. }>): Promise<void>;
  65644. /**
  65645. * Serializes the shadow generator setup to a json object.
  65646. * @returns The serialized JSON object
  65647. */
  65648. serialize(): any;
  65649. /**
  65650. * Disposes the Shadow map and related Textures and effects.
  65651. */
  65652. dispose(): void;
  65653. }
  65654. /**
  65655. * Default implementation IShadowGenerator.
  65656. * This is the main object responsible of generating shadows in the framework.
  65657. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  65658. */
  65659. export class ShadowGenerator implements IShadowGenerator {
  65660. /**
  65661. * Shadow generator mode None: no filtering applied.
  65662. */
  65663. static readonly FILTER_NONE: number;
  65664. /**
  65665. * Shadow generator mode ESM: Exponential Shadow Mapping.
  65666. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  65667. */
  65668. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  65669. /**
  65670. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  65671. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  65672. */
  65673. static readonly FILTER_POISSONSAMPLING: number;
  65674. /**
  65675. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  65676. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  65677. */
  65678. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  65679. /**
  65680. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  65681. * edge artifacts on steep falloff.
  65682. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  65683. */
  65684. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  65685. /**
  65686. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  65687. * edge artifacts on steep falloff.
  65688. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  65689. */
  65690. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  65691. /**
  65692. * Shadow generator mode PCF: Percentage Closer Filtering
  65693. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  65694. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  65695. */
  65696. static readonly FILTER_PCF: number;
  65697. /**
  65698. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  65699. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  65700. * Contact Hardening
  65701. */
  65702. static readonly FILTER_PCSS: number;
  65703. /**
  65704. * Reserved for PCF and PCSS
  65705. * Highest Quality.
  65706. *
  65707. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  65708. *
  65709. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  65710. */
  65711. static readonly QUALITY_HIGH: number;
  65712. /**
  65713. * Reserved for PCF and PCSS
  65714. * Good tradeoff for quality/perf cross devices
  65715. *
  65716. * Execute PCF on a 3*3 kernel.
  65717. *
  65718. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  65719. */
  65720. static readonly QUALITY_MEDIUM: number;
  65721. /**
  65722. * Reserved for PCF and PCSS
  65723. * The lowest quality but the fastest.
  65724. *
  65725. * Execute PCF on a 1*1 kernel.
  65726. *
  65727. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  65728. */
  65729. static readonly QUALITY_LOW: number;
  65730. /** Gets or sets the custom shader name to use */
  65731. customShaderOptions: ICustomShaderOptions;
  65732. /**
  65733. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  65734. */
  65735. onBeforeShadowMapRenderObservable: Observable<Effect>;
  65736. private _bias;
  65737. /**
  65738. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  65739. */
  65740. /**
  65741. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  65742. */
  65743. bias: number;
  65744. private _normalBias;
  65745. /**
  65746. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  65747. */
  65748. /**
  65749. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  65750. */
  65751. normalBias: number;
  65752. private _blurBoxOffset;
  65753. /**
  65754. * Gets the blur box offset: offset applied during the blur pass.
  65755. * Only useful if useKernelBlur = false
  65756. */
  65757. /**
  65758. * Sets the blur box offset: offset applied during the blur pass.
  65759. * Only useful if useKernelBlur = false
  65760. */
  65761. blurBoxOffset: number;
  65762. private _blurScale;
  65763. /**
  65764. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  65765. * 2 means half of the size.
  65766. */
  65767. /**
  65768. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  65769. * 2 means half of the size.
  65770. */
  65771. blurScale: number;
  65772. private _blurKernel;
  65773. /**
  65774. * Gets the blur kernel: kernel size of the blur pass.
  65775. * Only useful if useKernelBlur = true
  65776. */
  65777. /**
  65778. * Sets the blur kernel: kernel size of the blur pass.
  65779. * Only useful if useKernelBlur = true
  65780. */
  65781. blurKernel: number;
  65782. private _useKernelBlur;
  65783. /**
  65784. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  65785. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  65786. */
  65787. /**
  65788. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  65789. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  65790. */
  65791. useKernelBlur: boolean;
  65792. private _depthScale;
  65793. /**
  65794. * Gets the depth scale used in ESM mode.
  65795. */
  65796. /**
  65797. * Sets the depth scale used in ESM mode.
  65798. * This can override the scale stored on the light.
  65799. */
  65800. depthScale: number;
  65801. private _filter;
  65802. /**
  65803. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  65804. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  65805. */
  65806. /**
  65807. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  65808. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  65809. */
  65810. filter: number;
  65811. /**
  65812. * Gets if the current filter is set to Poisson Sampling.
  65813. */
  65814. /**
  65815. * Sets the current filter to Poisson Sampling.
  65816. */
  65817. usePoissonSampling: boolean;
  65818. /**
  65819. * Gets if the current filter is set to ESM.
  65820. */
  65821. /**
  65822. * Sets the current filter is to ESM.
  65823. */
  65824. useExponentialShadowMap: boolean;
  65825. /**
  65826. * Gets if the current filter is set to filtered ESM.
  65827. */
  65828. /**
  65829. * Gets if the current filter is set to filtered ESM.
  65830. */
  65831. useBlurExponentialShadowMap: boolean;
  65832. /**
  65833. * Gets if the current filter is set to "close ESM" (using the inverse of the
  65834. * exponential to prevent steep falloff artifacts).
  65835. */
  65836. /**
  65837. * Sets the current filter to "close ESM" (using the inverse of the
  65838. * exponential to prevent steep falloff artifacts).
  65839. */
  65840. useCloseExponentialShadowMap: boolean;
  65841. /**
  65842. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  65843. * exponential to prevent steep falloff artifacts).
  65844. */
  65845. /**
  65846. * Sets the current filter to filtered "close ESM" (using the inverse of the
  65847. * exponential to prevent steep falloff artifacts).
  65848. */
  65849. useBlurCloseExponentialShadowMap: boolean;
  65850. /**
  65851. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  65852. */
  65853. /**
  65854. * Sets the current filter to "PCF" (percentage closer filtering).
  65855. */
  65856. usePercentageCloserFiltering: boolean;
  65857. private _filteringQuality;
  65858. /**
  65859. * Gets the PCF or PCSS Quality.
  65860. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  65861. */
  65862. /**
  65863. * Sets the PCF or PCSS Quality.
  65864. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  65865. */
  65866. filteringQuality: number;
  65867. /**
  65868. * Gets if the current filter is set to "PCSS" (contact hardening).
  65869. */
  65870. /**
  65871. * Sets the current filter to "PCSS" (contact hardening).
  65872. */
  65873. useContactHardeningShadow: boolean;
  65874. private _contactHardeningLightSizeUVRatio;
  65875. /**
  65876. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  65877. * Using a ratio helps keeping shape stability independently of the map size.
  65878. *
  65879. * It does not account for the light projection as it was having too much
  65880. * instability during the light setup or during light position changes.
  65881. *
  65882. * Only valid if useContactHardeningShadow is true.
  65883. */
  65884. /**
  65885. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  65886. * Using a ratio helps keeping shape stability independently of the map size.
  65887. *
  65888. * It does not account for the light projection as it was having too much
  65889. * instability during the light setup or during light position changes.
  65890. *
  65891. * Only valid if useContactHardeningShadow is true.
  65892. */
  65893. contactHardeningLightSizeUVRatio: number;
  65894. private _darkness;
  65895. /**
  65896. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  65897. * 0 means strongest and 1 would means no shadow.
  65898. * @returns the darkness.
  65899. */
  65900. getDarkness(): number;
  65901. /**
  65902. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  65903. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  65904. * @returns the shadow generator allowing fluent coding.
  65905. */
  65906. setDarkness(darkness: number): ShadowGenerator;
  65907. private _transparencyShadow;
  65908. /**
  65909. * Sets the ability to have transparent shadow (boolean).
  65910. * @param transparent True if transparent else False
  65911. * @returns the shadow generator allowing fluent coding
  65912. */
  65913. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  65914. private _shadowMap;
  65915. private _shadowMap2;
  65916. /**
  65917. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  65918. * @returns The render target texture if present otherwise, null
  65919. */
  65920. getShadowMap(): Nullable<RenderTargetTexture>;
  65921. /**
  65922. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  65923. * @returns The render target texture if the shadow map is present otherwise, null
  65924. */
  65925. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  65926. /**
  65927. * Helper function to add a mesh and its descendants to the list of shadow casters.
  65928. * @param mesh Mesh to add
  65929. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  65930. * @returns the Shadow Generator itself
  65931. */
  65932. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  65933. /**
  65934. * Helper function to remove a mesh and its descendants from the list of shadow casters
  65935. * @param mesh Mesh to remove
  65936. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  65937. * @returns the Shadow Generator itself
  65938. */
  65939. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  65940. /**
  65941. * Controls the extent to which the shadows fade out at the edge of the frustum
  65942. * Used only by directionals and spots
  65943. */
  65944. frustumEdgeFalloff: number;
  65945. private _light;
  65946. /**
  65947. * Returns the associated light object.
  65948. * @returns the light generating the shadow
  65949. */
  65950. getLight(): IShadowLight;
  65951. /**
  65952. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  65953. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  65954. * It might on the other hand introduce peter panning.
  65955. */
  65956. forceBackFacesOnly: boolean;
  65957. private _scene;
  65958. private _lightDirection;
  65959. private _effect;
  65960. private _viewMatrix;
  65961. private _projectionMatrix;
  65962. private _transformMatrix;
  65963. private _cachedPosition;
  65964. private _cachedDirection;
  65965. private _cachedDefines;
  65966. private _currentRenderID;
  65967. private _boxBlurPostprocess;
  65968. private _kernelBlurXPostprocess;
  65969. private _kernelBlurYPostprocess;
  65970. private _blurPostProcesses;
  65971. private _mapSize;
  65972. private _currentFaceIndex;
  65973. private _currentFaceIndexCache;
  65974. private _textureType;
  65975. private _defaultTextureMatrix;
  65976. /** @hidden */
  65977. static _SceneComponentInitialization: (scene: Scene) => void;
  65978. /**
  65979. * Creates a ShadowGenerator object.
  65980. * A ShadowGenerator is the required tool to use the shadows.
  65981. * Each light casting shadows needs to use its own ShadowGenerator.
  65982. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  65983. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  65984. * @param light The light object generating the shadows.
  65985. * @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.
  65986. */
  65987. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  65988. private _initializeGenerator;
  65989. private _initializeShadowMap;
  65990. private _initializeBlurRTTAndPostProcesses;
  65991. private _renderForShadowMap;
  65992. private _renderSubMeshForShadowMap;
  65993. private _applyFilterValues;
  65994. /**
  65995. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  65996. * @param onCompiled Callback triggered at the and of the effects compilation
  65997. * @param options Sets of optional options forcing the compilation with different modes
  65998. */
  65999. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  66000. useInstances: boolean;
  66001. }>): void;
  66002. /**
  66003. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66004. * @param options Sets of optional options forcing the compilation with different modes
  66005. * @returns A promise that resolves when the compilation completes
  66006. */
  66007. forceCompilationAsync(options?: Partial<{
  66008. useInstances: boolean;
  66009. }>): Promise<void>;
  66010. /**
  66011. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  66012. * @param subMesh The submesh we want to render in the shadow map
  66013. * @param useInstances Defines wether will draw in the map using instances
  66014. * @returns true if ready otherwise, false
  66015. */
  66016. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66017. /**
  66018. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  66019. * @param defines Defines of the material we want to update
  66020. * @param lightIndex Index of the light in the enabled light list of the material
  66021. */
  66022. prepareDefines(defines: any, lightIndex: number): void;
  66023. /**
  66024. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  66025. * defined in the generator but impacting the effect).
  66026. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  66027. * @param effect The effect we are binfing the information for
  66028. */
  66029. bindShadowLight(lightIndex: string, effect: Effect): void;
  66030. /**
  66031. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  66032. * (eq to shadow prjection matrix * light transform matrix)
  66033. * @returns The transform matrix used to create the shadow map
  66034. */
  66035. getTransformMatrix(): Matrix;
  66036. /**
  66037. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  66038. * Cube and 2D textures for instance.
  66039. */
  66040. recreateShadowMap(): void;
  66041. private _disposeBlurPostProcesses;
  66042. private _disposeRTTandPostProcesses;
  66043. /**
  66044. * Disposes the ShadowGenerator.
  66045. * Returns nothing.
  66046. */
  66047. dispose(): void;
  66048. /**
  66049. * Serializes the shadow generator setup to a json object.
  66050. * @returns The serialized JSON object
  66051. */
  66052. serialize(): any;
  66053. /**
  66054. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  66055. * @param parsedShadowGenerator The JSON object to parse
  66056. * @param scene The scene to create the shadow map for
  66057. * @returns The parsed shadow generator
  66058. */
  66059. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  66060. }
  66061. }
  66062. declare module BABYLON {
  66063. /**
  66064. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  66065. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  66066. * 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.
  66067. */
  66068. export abstract class Light extends Node {
  66069. /**
  66070. * Falloff Default: light is falling off following the material specification:
  66071. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  66072. */
  66073. static readonly FALLOFF_DEFAULT: number;
  66074. /**
  66075. * Falloff Physical: light is falling off following the inverse squared distance law.
  66076. */
  66077. static readonly FALLOFF_PHYSICAL: number;
  66078. /**
  66079. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  66080. * to enhance interoperability with other engines.
  66081. */
  66082. static readonly FALLOFF_GLTF: number;
  66083. /**
  66084. * Falloff Standard: light is falling off like in the standard material
  66085. * to enhance interoperability with other materials.
  66086. */
  66087. static readonly FALLOFF_STANDARD: number;
  66088. /**
  66089. * If every light affecting the material is in this lightmapMode,
  66090. * material.lightmapTexture adds or multiplies
  66091. * (depends on material.useLightmapAsShadowmap)
  66092. * after every other light calculations.
  66093. */
  66094. static readonly LIGHTMAP_DEFAULT: number;
  66095. /**
  66096. * material.lightmapTexture as only diffuse lighting from this light
  66097. * adds only specular lighting from this light
  66098. * adds dynamic shadows
  66099. */
  66100. static readonly LIGHTMAP_SPECULAR: number;
  66101. /**
  66102. * material.lightmapTexture as only lighting
  66103. * no light calculation from this light
  66104. * only adds dynamic shadows from this light
  66105. */
  66106. static readonly LIGHTMAP_SHADOWSONLY: number;
  66107. /**
  66108. * Each light type uses the default quantity according to its type:
  66109. * point/spot lights use luminous intensity
  66110. * directional lights use illuminance
  66111. */
  66112. static readonly INTENSITYMODE_AUTOMATIC: number;
  66113. /**
  66114. * lumen (lm)
  66115. */
  66116. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  66117. /**
  66118. * candela (lm/sr)
  66119. */
  66120. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  66121. /**
  66122. * lux (lm/m^2)
  66123. */
  66124. static readonly INTENSITYMODE_ILLUMINANCE: number;
  66125. /**
  66126. * nit (cd/m^2)
  66127. */
  66128. static readonly INTENSITYMODE_LUMINANCE: number;
  66129. /**
  66130. * Light type const id of the point light.
  66131. */
  66132. static readonly LIGHTTYPEID_POINTLIGHT: number;
  66133. /**
  66134. * Light type const id of the directional light.
  66135. */
  66136. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  66137. /**
  66138. * Light type const id of the spot light.
  66139. */
  66140. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  66141. /**
  66142. * Light type const id of the hemispheric light.
  66143. */
  66144. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  66145. /**
  66146. * Diffuse gives the basic color to an object.
  66147. */
  66148. diffuse: Color3;
  66149. /**
  66150. * Specular produces a highlight color on an object.
  66151. * Note: This is note affecting PBR materials.
  66152. */
  66153. specular: Color3;
  66154. /**
  66155. * Defines the falloff type for this light. This lets overrriding how punctual light are
  66156. * falling off base on range or angle.
  66157. * This can be set to any values in Light.FALLOFF_x.
  66158. *
  66159. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  66160. * other types of materials.
  66161. */
  66162. falloffType: number;
  66163. /**
  66164. * Strength of the light.
  66165. * Note: By default it is define in the framework own unit.
  66166. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  66167. */
  66168. intensity: number;
  66169. private _range;
  66170. protected _inverseSquaredRange: number;
  66171. /**
  66172. * Defines how far from the source the light is impacting in scene units.
  66173. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  66174. */
  66175. /**
  66176. * Defines how far from the source the light is impacting in scene units.
  66177. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  66178. */
  66179. range: number;
  66180. /**
  66181. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  66182. * of light.
  66183. */
  66184. private _photometricScale;
  66185. private _intensityMode;
  66186. /**
  66187. * Gets the photometric scale used to interpret the intensity.
  66188. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  66189. */
  66190. /**
  66191. * Sets the photometric scale used to interpret the intensity.
  66192. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  66193. */
  66194. intensityMode: number;
  66195. private _radius;
  66196. /**
  66197. * Gets the light radius used by PBR Materials to simulate soft area lights.
  66198. */
  66199. /**
  66200. * sets the light radius used by PBR Materials to simulate soft area lights.
  66201. */
  66202. radius: number;
  66203. private _renderPriority;
  66204. /**
  66205. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  66206. * exceeding the number allowed of the materials.
  66207. */
  66208. renderPriority: number;
  66209. private _shadowEnabled;
  66210. /**
  66211. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  66212. * the current shadow generator.
  66213. */
  66214. /**
  66215. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  66216. * the current shadow generator.
  66217. */
  66218. shadowEnabled: boolean;
  66219. private _includedOnlyMeshes;
  66220. /**
  66221. * Gets the only meshes impacted by this light.
  66222. */
  66223. /**
  66224. * Sets the only meshes impacted by this light.
  66225. */
  66226. includedOnlyMeshes: AbstractMesh[];
  66227. private _excludedMeshes;
  66228. /**
  66229. * Gets the meshes not impacted by this light.
  66230. */
  66231. /**
  66232. * Sets the meshes not impacted by this light.
  66233. */
  66234. excludedMeshes: AbstractMesh[];
  66235. private _excludeWithLayerMask;
  66236. /**
  66237. * Gets the layer id use to find what meshes are not impacted by the light.
  66238. * Inactive if 0
  66239. */
  66240. /**
  66241. * Sets the layer id use to find what meshes are not impacted by the light.
  66242. * Inactive if 0
  66243. */
  66244. excludeWithLayerMask: number;
  66245. private _includeOnlyWithLayerMask;
  66246. /**
  66247. * Gets the layer id use to find what meshes are impacted by the light.
  66248. * Inactive if 0
  66249. */
  66250. /**
  66251. * Sets the layer id use to find what meshes are impacted by the light.
  66252. * Inactive if 0
  66253. */
  66254. includeOnlyWithLayerMask: number;
  66255. private _lightmapMode;
  66256. /**
  66257. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  66258. */
  66259. /**
  66260. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  66261. */
  66262. lightmapMode: number;
  66263. /**
  66264. * Shadow generator associted to the light.
  66265. * @hidden Internal use only.
  66266. */
  66267. _shadowGenerator: Nullable<IShadowGenerator>;
  66268. /**
  66269. * @hidden Internal use only.
  66270. */
  66271. _excludedMeshesIds: string[];
  66272. /**
  66273. * @hidden Internal use only.
  66274. */
  66275. _includedOnlyMeshesIds: string[];
  66276. /**
  66277. * The current light unifom buffer.
  66278. * @hidden Internal use only.
  66279. */
  66280. _uniformBuffer: UniformBuffer;
  66281. /**
  66282. * Creates a Light object in the scene.
  66283. * Documentation : https://doc.babylonjs.com/babylon101/lights
  66284. * @param name The firendly name of the light
  66285. * @param scene The scene the light belongs too
  66286. */
  66287. constructor(name: string, scene: Scene);
  66288. protected abstract _buildUniformLayout(): void;
  66289. /**
  66290. * Sets the passed Effect "effect" with the Light information.
  66291. * @param effect The effect to update
  66292. * @param lightIndex The index of the light in the effect to update
  66293. * @returns The light
  66294. */
  66295. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  66296. /**
  66297. * Returns the string "Light".
  66298. * @returns the class name
  66299. */
  66300. getClassName(): string;
  66301. /** @hidden */
  66302. readonly _isLight: boolean;
  66303. /**
  66304. * Converts the light information to a readable string for debug purpose.
  66305. * @param fullDetails Supports for multiple levels of logging within scene loading
  66306. * @returns the human readable light info
  66307. */
  66308. toString(fullDetails?: boolean): string;
  66309. /** @hidden */
  66310. protected _syncParentEnabledState(): void;
  66311. /**
  66312. * Set the enabled state of this node.
  66313. * @param value - the new enabled state
  66314. */
  66315. setEnabled(value: boolean): void;
  66316. /**
  66317. * Returns the Light associated shadow generator if any.
  66318. * @return the associated shadow generator.
  66319. */
  66320. getShadowGenerator(): Nullable<IShadowGenerator>;
  66321. /**
  66322. * Returns a Vector3, the absolute light position in the World.
  66323. * @returns the world space position of the light
  66324. */
  66325. getAbsolutePosition(): Vector3;
  66326. /**
  66327. * Specifies if the light will affect the passed mesh.
  66328. * @param mesh The mesh to test against the light
  66329. * @return true the mesh is affected otherwise, false.
  66330. */
  66331. canAffectMesh(mesh: AbstractMesh): boolean;
  66332. /**
  66333. * Sort function to order lights for rendering.
  66334. * @param a First Light object to compare to second.
  66335. * @param b Second Light object to compare first.
  66336. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  66337. */
  66338. static CompareLightsPriority(a: Light, b: Light): number;
  66339. /**
  66340. * Releases resources associated with this node.
  66341. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  66342. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  66343. */
  66344. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  66345. /**
  66346. * Returns the light type ID (integer).
  66347. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  66348. */
  66349. getTypeID(): number;
  66350. /**
  66351. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  66352. * @returns the scaled intensity in intensity mode unit
  66353. */
  66354. getScaledIntensity(): number;
  66355. /**
  66356. * Returns a new Light object, named "name", from the current one.
  66357. * @param name The name of the cloned light
  66358. * @returns the new created light
  66359. */
  66360. clone(name: string): Nullable<Light>;
  66361. /**
  66362. * Serializes the current light into a Serialization object.
  66363. * @returns the serialized object.
  66364. */
  66365. serialize(): any;
  66366. /**
  66367. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  66368. * This new light is named "name" and added to the passed scene.
  66369. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  66370. * @param name The friendly name of the light
  66371. * @param scene The scene the new light will belong to
  66372. * @returns the constructor function
  66373. */
  66374. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  66375. /**
  66376. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  66377. * @param parsedLight The JSON representation of the light
  66378. * @param scene The scene to create the parsed light in
  66379. * @returns the created light after parsing
  66380. */
  66381. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  66382. private _hookArrayForExcluded;
  66383. private _hookArrayForIncludedOnly;
  66384. private _resyncMeshes;
  66385. /**
  66386. * Forces the meshes to update their light related information in their rendering used effects
  66387. * @hidden Internal Use Only
  66388. */
  66389. _markMeshesAsLightDirty(): void;
  66390. /**
  66391. * Recomputes the cached photometric scale if needed.
  66392. */
  66393. private _computePhotometricScale;
  66394. /**
  66395. * Returns the Photometric Scale according to the light type and intensity mode.
  66396. */
  66397. private _getPhotometricScale;
  66398. /**
  66399. * Reorder the light in the scene according to their defined priority.
  66400. * @hidden Internal Use Only
  66401. */
  66402. _reorderLightsInScene(): void;
  66403. /**
  66404. * Prepares the list of defines specific to the light type.
  66405. * @param defines the list of defines
  66406. * @param lightIndex defines the index of the light for the effect
  66407. */
  66408. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  66409. }
  66410. }
  66411. declare module BABYLON {
  66412. /**
  66413. * Interface used to define Action
  66414. */
  66415. export interface IAction {
  66416. /**
  66417. * Trigger for the action
  66418. */
  66419. trigger: number;
  66420. /** the trigger, with or without parameters, for the action */
  66421. triggerOptions: any;
  66422. /**
  66423. * Gets the trigger parameters
  66424. * @returns the trigger parameters
  66425. */
  66426. getTriggerParameter(): any;
  66427. /**
  66428. * Internal only - executes current action event
  66429. * @hidden
  66430. */
  66431. _executeCurrent(evt?: ActionEvent): void;
  66432. /**
  66433. * Serialize placeholder for child classes
  66434. * @param parent of child
  66435. * @returns the serialized object
  66436. */
  66437. serialize(parent: any): any;
  66438. }
  66439. /**
  66440. * The action to be carried out following a trigger
  66441. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  66442. */
  66443. export class Action implements IAction {
  66444. /** the trigger, with or without parameters, for the action */
  66445. triggerOptions: any;
  66446. /**
  66447. * Trigger for the action
  66448. */
  66449. trigger: number;
  66450. /**
  66451. * Internal only - manager for action
  66452. * @hidden
  66453. */
  66454. _actionManager: ActionManager;
  66455. private _nextActiveAction;
  66456. private _child;
  66457. private _condition?;
  66458. private _triggerParameter;
  66459. /**
  66460. * An event triggered prior to action being executed.
  66461. */
  66462. onBeforeExecuteObservable: Observable<Action>;
  66463. /**
  66464. * Creates a new Action
  66465. * @param triggerOptions the trigger, with or without parameters, for the action
  66466. * @param condition an optional determinant of action
  66467. */
  66468. constructor(
  66469. /** the trigger, with or without parameters, for the action */
  66470. triggerOptions: any, condition?: Condition);
  66471. /**
  66472. * Internal only
  66473. * @hidden
  66474. */
  66475. _prepare(): void;
  66476. /**
  66477. * Gets the trigger parameters
  66478. * @returns the trigger parameters
  66479. */
  66480. getTriggerParameter(): any;
  66481. /**
  66482. * Internal only - executes current action event
  66483. * @hidden
  66484. */
  66485. _executeCurrent(evt?: ActionEvent): void;
  66486. /**
  66487. * Execute placeholder for child classes
  66488. * @param evt optional action event
  66489. */
  66490. execute(evt?: ActionEvent): void;
  66491. /**
  66492. * Skips to next active action
  66493. */
  66494. skipToNextActiveAction(): void;
  66495. /**
  66496. * Adds action to chain of actions, may be a DoNothingAction
  66497. * @param action defines the next action to execute
  66498. * @returns The action passed in
  66499. * @see https://www.babylonjs-playground.com/#1T30HR#0
  66500. */
  66501. then(action: Action): Action;
  66502. /**
  66503. * Internal only
  66504. * @hidden
  66505. */
  66506. _getProperty(propertyPath: string): string;
  66507. /**
  66508. * Internal only
  66509. * @hidden
  66510. */
  66511. _getEffectiveTarget(target: any, propertyPath: string): any;
  66512. /**
  66513. * Serialize placeholder for child classes
  66514. * @param parent of child
  66515. * @returns the serialized object
  66516. */
  66517. serialize(parent: any): any;
  66518. /**
  66519. * Internal only called by serialize
  66520. * @hidden
  66521. */
  66522. protected _serialize(serializedAction: any, parent?: any): any;
  66523. /**
  66524. * Internal only
  66525. * @hidden
  66526. */
  66527. static _SerializeValueAsString: (value: any) => string;
  66528. /**
  66529. * Internal only
  66530. * @hidden
  66531. */
  66532. static _GetTargetProperty: (target: Scene | Node) => {
  66533. name: string;
  66534. targetType: string;
  66535. value: string;
  66536. };
  66537. }
  66538. }
  66539. declare module BABYLON {
  66540. /**
  66541. * A Condition applied to an Action
  66542. */
  66543. export class Condition {
  66544. /**
  66545. * Internal only - manager for action
  66546. * @hidden
  66547. */
  66548. _actionManager: ActionManager;
  66549. /**
  66550. * Internal only
  66551. * @hidden
  66552. */
  66553. _evaluationId: number;
  66554. /**
  66555. * Internal only
  66556. * @hidden
  66557. */
  66558. _currentResult: boolean;
  66559. /**
  66560. * Creates a new Condition
  66561. * @param actionManager the manager of the action the condition is applied to
  66562. */
  66563. constructor(actionManager: ActionManager);
  66564. /**
  66565. * Check if the current condition is valid
  66566. * @returns a boolean
  66567. */
  66568. isValid(): boolean;
  66569. /**
  66570. * Internal only
  66571. * @hidden
  66572. */
  66573. _getProperty(propertyPath: string): string;
  66574. /**
  66575. * Internal only
  66576. * @hidden
  66577. */
  66578. _getEffectiveTarget(target: any, propertyPath: string): any;
  66579. /**
  66580. * Serialize placeholder for child classes
  66581. * @returns the serialized object
  66582. */
  66583. serialize(): any;
  66584. /**
  66585. * Internal only
  66586. * @hidden
  66587. */
  66588. protected _serialize(serializedCondition: any): any;
  66589. }
  66590. /**
  66591. * Defines specific conditional operators as extensions of Condition
  66592. */
  66593. export class ValueCondition extends Condition {
  66594. /** path to specify the property of the target the conditional operator uses */
  66595. propertyPath: string;
  66596. /** the value compared by the conditional operator against the current value of the property */
  66597. value: any;
  66598. /** the conditional operator, default ValueCondition.IsEqual */
  66599. operator: number;
  66600. /**
  66601. * Internal only
  66602. * @hidden
  66603. */
  66604. private static _IsEqual;
  66605. /**
  66606. * Internal only
  66607. * @hidden
  66608. */
  66609. private static _IsDifferent;
  66610. /**
  66611. * Internal only
  66612. * @hidden
  66613. */
  66614. private static _IsGreater;
  66615. /**
  66616. * Internal only
  66617. * @hidden
  66618. */
  66619. private static _IsLesser;
  66620. /**
  66621. * returns the number for IsEqual
  66622. */
  66623. static readonly IsEqual: number;
  66624. /**
  66625. * Returns the number for IsDifferent
  66626. */
  66627. static readonly IsDifferent: number;
  66628. /**
  66629. * Returns the number for IsGreater
  66630. */
  66631. static readonly IsGreater: number;
  66632. /**
  66633. * Returns the number for IsLesser
  66634. */
  66635. static readonly IsLesser: number;
  66636. /**
  66637. * Internal only The action manager for the condition
  66638. * @hidden
  66639. */
  66640. _actionManager: ActionManager;
  66641. /**
  66642. * Internal only
  66643. * @hidden
  66644. */
  66645. private _target;
  66646. /**
  66647. * Internal only
  66648. * @hidden
  66649. */
  66650. private _effectiveTarget;
  66651. /**
  66652. * Internal only
  66653. * @hidden
  66654. */
  66655. private _property;
  66656. /**
  66657. * Creates a new ValueCondition
  66658. * @param actionManager manager for the action the condition applies to
  66659. * @param target for the action
  66660. * @param propertyPath path to specify the property of the target the conditional operator uses
  66661. * @param value the value compared by the conditional operator against the current value of the property
  66662. * @param operator the conditional operator, default ValueCondition.IsEqual
  66663. */
  66664. constructor(actionManager: ActionManager, target: any,
  66665. /** path to specify the property of the target the conditional operator uses */
  66666. propertyPath: string,
  66667. /** the value compared by the conditional operator against the current value of the property */
  66668. value: any,
  66669. /** the conditional operator, default ValueCondition.IsEqual */
  66670. operator?: number);
  66671. /**
  66672. * Compares the given value with the property value for the specified conditional operator
  66673. * @returns the result of the comparison
  66674. */
  66675. isValid(): boolean;
  66676. /**
  66677. * Serialize the ValueCondition into a JSON compatible object
  66678. * @returns serialization object
  66679. */
  66680. serialize(): any;
  66681. /**
  66682. * Gets the name of the conditional operator for the ValueCondition
  66683. * @param operator the conditional operator
  66684. * @returns the name
  66685. */
  66686. static GetOperatorName(operator: number): string;
  66687. }
  66688. /**
  66689. * Defines a predicate condition as an extension of Condition
  66690. */
  66691. export class PredicateCondition extends Condition {
  66692. /** defines the predicate function used to validate the condition */
  66693. predicate: () => boolean;
  66694. /**
  66695. * Internal only - manager for action
  66696. * @hidden
  66697. */
  66698. _actionManager: ActionManager;
  66699. /**
  66700. * Creates a new PredicateCondition
  66701. * @param actionManager manager for the action the condition applies to
  66702. * @param predicate defines the predicate function used to validate the condition
  66703. */
  66704. constructor(actionManager: ActionManager,
  66705. /** defines the predicate function used to validate the condition */
  66706. predicate: () => boolean);
  66707. /**
  66708. * @returns the validity of the predicate condition
  66709. */
  66710. isValid(): boolean;
  66711. }
  66712. /**
  66713. * Defines a state condition as an extension of Condition
  66714. */
  66715. export class StateCondition extends Condition {
  66716. /** Value to compare with target state */
  66717. value: string;
  66718. /**
  66719. * Internal only - manager for action
  66720. * @hidden
  66721. */
  66722. _actionManager: ActionManager;
  66723. /**
  66724. * Internal only
  66725. * @hidden
  66726. */
  66727. private _target;
  66728. /**
  66729. * Creates a new StateCondition
  66730. * @param actionManager manager for the action the condition applies to
  66731. * @param target of the condition
  66732. * @param value to compare with target state
  66733. */
  66734. constructor(actionManager: ActionManager, target: any,
  66735. /** Value to compare with target state */
  66736. value: string);
  66737. /**
  66738. * Gets a boolean indicating if the current condition is met
  66739. * @returns the validity of the state
  66740. */
  66741. isValid(): boolean;
  66742. /**
  66743. * Serialize the StateCondition into a JSON compatible object
  66744. * @returns serialization object
  66745. */
  66746. serialize(): any;
  66747. }
  66748. }
  66749. declare module BABYLON {
  66750. /**
  66751. * This defines an action responsible to toggle a boolean once triggered.
  66752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  66753. */
  66754. export class SwitchBooleanAction extends Action {
  66755. /**
  66756. * The path to the boolean property in the target object
  66757. */
  66758. propertyPath: string;
  66759. private _target;
  66760. private _effectiveTarget;
  66761. private _property;
  66762. /**
  66763. * Instantiate the action
  66764. * @param triggerOptions defines the trigger options
  66765. * @param target defines the object containing the boolean
  66766. * @param propertyPath defines the path to the boolean property in the target object
  66767. * @param condition defines the trigger related conditions
  66768. */
  66769. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  66770. /** @hidden */
  66771. _prepare(): void;
  66772. /**
  66773. * Execute the action toggle the boolean value.
  66774. */
  66775. execute(): void;
  66776. /**
  66777. * Serializes the actions and its related information.
  66778. * @param parent defines the object to serialize in
  66779. * @returns the serialized object
  66780. */
  66781. serialize(parent: any): any;
  66782. }
  66783. /**
  66784. * This defines an action responsible to set a the state field of the target
  66785. * to a desired value once triggered.
  66786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  66787. */
  66788. export class SetStateAction extends Action {
  66789. /**
  66790. * The value to store in the state field.
  66791. */
  66792. value: string;
  66793. private _target;
  66794. /**
  66795. * Instantiate the action
  66796. * @param triggerOptions defines the trigger options
  66797. * @param target defines the object containing the state property
  66798. * @param value defines the value to store in the state field
  66799. * @param condition defines the trigger related conditions
  66800. */
  66801. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  66802. /**
  66803. * Execute the action and store the value on the target state property.
  66804. */
  66805. execute(): void;
  66806. /**
  66807. * Serializes the actions and its related information.
  66808. * @param parent defines the object to serialize in
  66809. * @returns the serialized object
  66810. */
  66811. serialize(parent: any): any;
  66812. }
  66813. /**
  66814. * This defines an action responsible to set a property of the target
  66815. * to a desired value once triggered.
  66816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  66817. */
  66818. export class SetValueAction extends Action {
  66819. /**
  66820. * The path of the property to set in the target.
  66821. */
  66822. propertyPath: string;
  66823. /**
  66824. * The value to set in the property
  66825. */
  66826. value: any;
  66827. private _target;
  66828. private _effectiveTarget;
  66829. private _property;
  66830. /**
  66831. * Instantiate the action
  66832. * @param triggerOptions defines the trigger options
  66833. * @param target defines the object containing the property
  66834. * @param propertyPath defines the path of the property to set in the target
  66835. * @param value defines the value to set in the property
  66836. * @param condition defines the trigger related conditions
  66837. */
  66838. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  66839. /** @hidden */
  66840. _prepare(): void;
  66841. /**
  66842. * Execute the action and set the targetted property to the desired value.
  66843. */
  66844. execute(): void;
  66845. /**
  66846. * Serializes the actions and its related information.
  66847. * @param parent defines the object to serialize in
  66848. * @returns the serialized object
  66849. */
  66850. serialize(parent: any): any;
  66851. }
  66852. /**
  66853. * This defines an action responsible to increment the target value
  66854. * to a desired value once triggered.
  66855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  66856. */
  66857. export class IncrementValueAction extends Action {
  66858. /**
  66859. * The path of the property to increment in the target.
  66860. */
  66861. propertyPath: string;
  66862. /**
  66863. * The value we should increment the property by.
  66864. */
  66865. value: any;
  66866. private _target;
  66867. private _effectiveTarget;
  66868. private _property;
  66869. /**
  66870. * Instantiate the action
  66871. * @param triggerOptions defines the trigger options
  66872. * @param target defines the object containing the property
  66873. * @param propertyPath defines the path of the property to increment in the target
  66874. * @param value defines the value value we should increment the property by
  66875. * @param condition defines the trigger related conditions
  66876. */
  66877. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  66878. /** @hidden */
  66879. _prepare(): void;
  66880. /**
  66881. * Execute the action and increment the target of the value amount.
  66882. */
  66883. execute(): void;
  66884. /**
  66885. * Serializes the actions and its related information.
  66886. * @param parent defines the object to serialize in
  66887. * @returns the serialized object
  66888. */
  66889. serialize(parent: any): any;
  66890. }
  66891. /**
  66892. * This defines an action responsible to start an animation once triggered.
  66893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  66894. */
  66895. export class PlayAnimationAction extends Action {
  66896. /**
  66897. * Where the animation should start (animation frame)
  66898. */
  66899. from: number;
  66900. /**
  66901. * Where the animation should stop (animation frame)
  66902. */
  66903. to: number;
  66904. /**
  66905. * Define if the animation should loop or stop after the first play.
  66906. */
  66907. loop?: boolean;
  66908. private _target;
  66909. /**
  66910. * Instantiate the action
  66911. * @param triggerOptions defines the trigger options
  66912. * @param target defines the target animation or animation name
  66913. * @param from defines from where the animation should start (animation frame)
  66914. * @param end defines where the animation should stop (animation frame)
  66915. * @param loop defines if the animation should loop or stop after the first play
  66916. * @param condition defines the trigger related conditions
  66917. */
  66918. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  66919. /** @hidden */
  66920. _prepare(): void;
  66921. /**
  66922. * Execute the action and play the animation.
  66923. */
  66924. execute(): void;
  66925. /**
  66926. * Serializes the actions and its related information.
  66927. * @param parent defines the object to serialize in
  66928. * @returns the serialized object
  66929. */
  66930. serialize(parent: any): any;
  66931. }
  66932. /**
  66933. * This defines an action responsible to stop an animation once triggered.
  66934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  66935. */
  66936. export class StopAnimationAction extends Action {
  66937. private _target;
  66938. /**
  66939. * Instantiate the action
  66940. * @param triggerOptions defines the trigger options
  66941. * @param target defines the target animation or animation name
  66942. * @param condition defines the trigger related conditions
  66943. */
  66944. constructor(triggerOptions: any, target: any, condition?: Condition);
  66945. /** @hidden */
  66946. _prepare(): void;
  66947. /**
  66948. * Execute the action and stop the animation.
  66949. */
  66950. execute(): void;
  66951. /**
  66952. * Serializes the actions and its related information.
  66953. * @param parent defines the object to serialize in
  66954. * @returns the serialized object
  66955. */
  66956. serialize(parent: any): any;
  66957. }
  66958. /**
  66959. * This defines an action responsible that does nothing once triggered.
  66960. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  66961. */
  66962. export class DoNothingAction extends Action {
  66963. /**
  66964. * Instantiate the action
  66965. * @param triggerOptions defines the trigger options
  66966. * @param condition defines the trigger related conditions
  66967. */
  66968. constructor(triggerOptions?: any, condition?: Condition);
  66969. /**
  66970. * Execute the action and do nothing.
  66971. */
  66972. execute(): void;
  66973. /**
  66974. * Serializes the actions and its related information.
  66975. * @param parent defines the object to serialize in
  66976. * @returns the serialized object
  66977. */
  66978. serialize(parent: any): any;
  66979. }
  66980. /**
  66981. * This defines an action responsible to trigger several actions once triggered.
  66982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  66983. */
  66984. export class CombineAction extends Action {
  66985. /**
  66986. * The list of aggregated animations to run.
  66987. */
  66988. children: Action[];
  66989. /**
  66990. * Instantiate the action
  66991. * @param triggerOptions defines the trigger options
  66992. * @param children defines the list of aggregated animations to run
  66993. * @param condition defines the trigger related conditions
  66994. */
  66995. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  66996. /** @hidden */
  66997. _prepare(): void;
  66998. /**
  66999. * Execute the action and executes all the aggregated actions.
  67000. */
  67001. execute(evt: ActionEvent): void;
  67002. /**
  67003. * Serializes the actions and its related information.
  67004. * @param parent defines the object to serialize in
  67005. * @returns the serialized object
  67006. */
  67007. serialize(parent: any): any;
  67008. }
  67009. /**
  67010. * This defines an action responsible to run code (external event) once triggered.
  67011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67012. */
  67013. export class ExecuteCodeAction extends Action {
  67014. /**
  67015. * The callback function to run.
  67016. */
  67017. func: (evt: ActionEvent) => void;
  67018. /**
  67019. * Instantiate the action
  67020. * @param triggerOptions defines the trigger options
  67021. * @param func defines the callback function to run
  67022. * @param condition defines the trigger related conditions
  67023. */
  67024. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  67025. /**
  67026. * Execute the action and run the attached code.
  67027. */
  67028. execute(evt: ActionEvent): void;
  67029. }
  67030. /**
  67031. * This defines an action responsible to set the parent property of the target once triggered.
  67032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67033. */
  67034. export class SetParentAction extends Action {
  67035. private _parent;
  67036. private _target;
  67037. /**
  67038. * Instantiate the action
  67039. * @param triggerOptions defines the trigger options
  67040. * @param target defines the target containing the parent property
  67041. * @param parent defines from where the animation should start (animation frame)
  67042. * @param condition defines the trigger related conditions
  67043. */
  67044. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  67045. /** @hidden */
  67046. _prepare(): void;
  67047. /**
  67048. * Execute the action and set the parent property.
  67049. */
  67050. execute(): void;
  67051. /**
  67052. * Serializes the actions and its related information.
  67053. * @param parent defines the object to serialize in
  67054. * @returns the serialized object
  67055. */
  67056. serialize(parent: any): any;
  67057. }
  67058. }
  67059. declare module BABYLON {
  67060. /**
  67061. * Abstract class used to decouple action Manager from scene and meshes.
  67062. * Do not instantiate.
  67063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67064. */
  67065. export abstract class AbstractActionManager implements IDisposable {
  67066. /** Gets the list of active triggers */
  67067. static Triggers: {
  67068. [key: string]: number;
  67069. };
  67070. /** Gets the cursor to use when hovering items */
  67071. hoverCursor: string;
  67072. /** Gets the list of actions */
  67073. actions: IAction[];
  67074. /**
  67075. * Releases all associated resources
  67076. */
  67077. abstract dispose(): void;
  67078. /**
  67079. * Does this action manager has pointer triggers
  67080. */
  67081. abstract readonly hasPointerTriggers: boolean;
  67082. /**
  67083. * Does this action manager has pick triggers
  67084. */
  67085. abstract readonly hasPickTriggers: boolean;
  67086. /**
  67087. * Process a specific trigger
  67088. * @param trigger defines the trigger to process
  67089. * @param evt defines the event details to be processed
  67090. */
  67091. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  67092. /**
  67093. * Does this action manager handles actions of any of the given triggers
  67094. * @param triggers defines the triggers to be tested
  67095. * @return a boolean indicating whether one (or more) of the triggers is handled
  67096. */
  67097. abstract hasSpecificTriggers(triggers: number[]): boolean;
  67098. /**
  67099. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  67100. * speed.
  67101. * @param triggerA defines the trigger to be tested
  67102. * @param triggerB defines the trigger to be tested
  67103. * @return a boolean indicating whether one (or more) of the triggers is handled
  67104. */
  67105. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  67106. /**
  67107. * Does this action manager handles actions of a given trigger
  67108. * @param trigger defines the trigger to be tested
  67109. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  67110. * @return whether the trigger is handled
  67111. */
  67112. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  67113. /**
  67114. * Serialize this manager to a JSON object
  67115. * @param name defines the property name to store this manager
  67116. * @returns a JSON representation of this manager
  67117. */
  67118. abstract serialize(name: string): any;
  67119. /**
  67120. * Does exist one action manager with at least one trigger
  67121. **/
  67122. static readonly HasTriggers: boolean;
  67123. /**
  67124. * Does exist one action manager with at least one pick trigger
  67125. **/
  67126. static readonly HasPickTriggers: boolean;
  67127. /**
  67128. * Does exist one action manager that handles actions of a given trigger
  67129. * @param trigger defines the trigger to be tested
  67130. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  67131. **/
  67132. static HasSpecificTrigger(trigger: number): boolean;
  67133. }
  67134. }
  67135. declare module BABYLON {
  67136. /**
  67137. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  67138. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  67139. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67140. */
  67141. export class ActionManager extends AbstractActionManager {
  67142. /**
  67143. * Nothing
  67144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67145. */
  67146. static readonly NothingTrigger: number;
  67147. /**
  67148. * On pick
  67149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67150. */
  67151. static readonly OnPickTrigger: number;
  67152. /**
  67153. * On left pick
  67154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67155. */
  67156. static readonly OnLeftPickTrigger: number;
  67157. /**
  67158. * On right pick
  67159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67160. */
  67161. static readonly OnRightPickTrigger: number;
  67162. /**
  67163. * On center pick
  67164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67165. */
  67166. static readonly OnCenterPickTrigger: number;
  67167. /**
  67168. * On pick down
  67169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67170. */
  67171. static readonly OnPickDownTrigger: number;
  67172. /**
  67173. * On double pick
  67174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67175. */
  67176. static readonly OnDoublePickTrigger: number;
  67177. /**
  67178. * On pick up
  67179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67180. */
  67181. static readonly OnPickUpTrigger: number;
  67182. /**
  67183. * On pick out.
  67184. * This trigger will only be raised if you also declared a OnPickDown
  67185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67186. */
  67187. static readonly OnPickOutTrigger: number;
  67188. /**
  67189. * On long press
  67190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67191. */
  67192. static readonly OnLongPressTrigger: number;
  67193. /**
  67194. * On pointer over
  67195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67196. */
  67197. static readonly OnPointerOverTrigger: number;
  67198. /**
  67199. * On pointer out
  67200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67201. */
  67202. static readonly OnPointerOutTrigger: number;
  67203. /**
  67204. * On every frame
  67205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67206. */
  67207. static readonly OnEveryFrameTrigger: number;
  67208. /**
  67209. * On intersection enter
  67210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67211. */
  67212. static readonly OnIntersectionEnterTrigger: number;
  67213. /**
  67214. * On intersection exit
  67215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67216. */
  67217. static readonly OnIntersectionExitTrigger: number;
  67218. /**
  67219. * On key down
  67220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67221. */
  67222. static readonly OnKeyDownTrigger: number;
  67223. /**
  67224. * On key up
  67225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67226. */
  67227. static readonly OnKeyUpTrigger: number;
  67228. private _scene;
  67229. /**
  67230. * Creates a new action manager
  67231. * @param scene defines the hosting scene
  67232. */
  67233. constructor(scene: Scene);
  67234. /**
  67235. * Releases all associated resources
  67236. */
  67237. dispose(): void;
  67238. /**
  67239. * Gets hosting scene
  67240. * @returns the hosting scene
  67241. */
  67242. getScene(): Scene;
  67243. /**
  67244. * Does this action manager handles actions of any of the given triggers
  67245. * @param triggers defines the triggers to be tested
  67246. * @return a boolean indicating whether one (or more) of the triggers is handled
  67247. */
  67248. hasSpecificTriggers(triggers: number[]): boolean;
  67249. /**
  67250. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  67251. * speed.
  67252. * @param triggerA defines the trigger to be tested
  67253. * @param triggerB defines the trigger to be tested
  67254. * @return a boolean indicating whether one (or more) of the triggers is handled
  67255. */
  67256. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  67257. /**
  67258. * Does this action manager handles actions of a given trigger
  67259. * @param trigger defines the trigger to be tested
  67260. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  67261. * @return whether the trigger is handled
  67262. */
  67263. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  67264. /**
  67265. * Does this action manager has pointer triggers
  67266. */
  67267. readonly hasPointerTriggers: boolean;
  67268. /**
  67269. * Does this action manager has pick triggers
  67270. */
  67271. readonly hasPickTriggers: boolean;
  67272. /**
  67273. * Registers an action to this action manager
  67274. * @param action defines the action to be registered
  67275. * @return the action amended (prepared) after registration
  67276. */
  67277. registerAction(action: Action): Nullable<Action>;
  67278. /**
  67279. * Unregisters an action to this action manager
  67280. * @param action defines the action to be unregistered
  67281. * @return a boolean indicating whether the action has been unregistered
  67282. */
  67283. unregisterAction(action: Action): Boolean;
  67284. /**
  67285. * Process a specific trigger
  67286. * @param trigger defines the trigger to process
  67287. * @param evt defines the event details to be processed
  67288. */
  67289. processTrigger(trigger: number, evt?: IActionEvent): void;
  67290. /** @hidden */
  67291. _getEffectiveTarget(target: any, propertyPath: string): any;
  67292. /** @hidden */
  67293. _getProperty(propertyPath: string): string;
  67294. /**
  67295. * Serialize this manager to a JSON object
  67296. * @param name defines the property name to store this manager
  67297. * @returns a JSON representation of this manager
  67298. */
  67299. serialize(name: string): any;
  67300. /**
  67301. * Creates a new ActionManager from a JSON data
  67302. * @param parsedActions defines the JSON data to read from
  67303. * @param object defines the hosting mesh
  67304. * @param scene defines the hosting scene
  67305. */
  67306. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  67307. /**
  67308. * Get a trigger name by index
  67309. * @param trigger defines the trigger index
  67310. * @returns a trigger name
  67311. */
  67312. static GetTriggerName(trigger: number): string;
  67313. }
  67314. }
  67315. declare module BABYLON {
  67316. /**
  67317. * Class representing a ray with position and direction
  67318. */
  67319. export class Ray {
  67320. /** origin point */
  67321. origin: Vector3;
  67322. /** direction */
  67323. direction: Vector3;
  67324. /** length of the ray */
  67325. length: number;
  67326. private static readonly TmpVector3;
  67327. private _tmpRay;
  67328. /**
  67329. * Creates a new ray
  67330. * @param origin origin point
  67331. * @param direction direction
  67332. * @param length length of the ray
  67333. */
  67334. constructor(
  67335. /** origin point */
  67336. origin: Vector3,
  67337. /** direction */
  67338. direction: Vector3,
  67339. /** length of the ray */
  67340. length?: number);
  67341. /**
  67342. * Checks if the ray intersects a box
  67343. * @param minimum bound of the box
  67344. * @param maximum bound of the box
  67345. * @param intersectionTreshold extra extend to be added to the box in all direction
  67346. * @returns if the box was hit
  67347. */
  67348. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  67349. /**
  67350. * Checks if the ray intersects a box
  67351. * @param box the bounding box to check
  67352. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  67353. * @returns if the box was hit
  67354. */
  67355. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  67356. /**
  67357. * If the ray hits a sphere
  67358. * @param sphere the bounding sphere to check
  67359. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  67360. * @returns true if it hits the sphere
  67361. */
  67362. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  67363. /**
  67364. * If the ray hits a triange
  67365. * @param vertex0 triangle vertex
  67366. * @param vertex1 triangle vertex
  67367. * @param vertex2 triangle vertex
  67368. * @returns intersection information if hit
  67369. */
  67370. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  67371. /**
  67372. * Checks if ray intersects a plane
  67373. * @param plane the plane to check
  67374. * @returns the distance away it was hit
  67375. */
  67376. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  67377. /**
  67378. * Checks if ray intersects a mesh
  67379. * @param mesh the mesh to check
  67380. * @param fastCheck if only the bounding box should checked
  67381. * @returns picking info of the intersecton
  67382. */
  67383. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  67384. /**
  67385. * Checks if ray intersects a mesh
  67386. * @param meshes the meshes to check
  67387. * @param fastCheck if only the bounding box should checked
  67388. * @param results array to store result in
  67389. * @returns Array of picking infos
  67390. */
  67391. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  67392. private _comparePickingInfo;
  67393. private static smallnum;
  67394. private static rayl;
  67395. /**
  67396. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  67397. * @param sega the first point of the segment to test the intersection against
  67398. * @param segb the second point of the segment to test the intersection against
  67399. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  67400. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  67401. */
  67402. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  67403. /**
  67404. * Update the ray from viewport position
  67405. * @param x position
  67406. * @param y y position
  67407. * @param viewportWidth viewport width
  67408. * @param viewportHeight viewport height
  67409. * @param world world matrix
  67410. * @param view view matrix
  67411. * @param projection projection matrix
  67412. * @returns this ray updated
  67413. */
  67414. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  67415. /**
  67416. * Creates a ray with origin and direction of 0,0,0
  67417. * @returns the new ray
  67418. */
  67419. static Zero(): Ray;
  67420. /**
  67421. * Creates a new ray from screen space and viewport
  67422. * @param x position
  67423. * @param y y position
  67424. * @param viewportWidth viewport width
  67425. * @param viewportHeight viewport height
  67426. * @param world world matrix
  67427. * @param view view matrix
  67428. * @param projection projection matrix
  67429. * @returns new ray
  67430. */
  67431. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  67432. /**
  67433. * 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
  67434. * transformed to the given world matrix.
  67435. * @param origin The origin point
  67436. * @param end The end point
  67437. * @param world a matrix to transform the ray to. Default is the identity matrix.
  67438. * @returns the new ray
  67439. */
  67440. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  67441. /**
  67442. * Transforms a ray by a matrix
  67443. * @param ray ray to transform
  67444. * @param matrix matrix to apply
  67445. * @returns the resulting new ray
  67446. */
  67447. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  67448. /**
  67449. * Transforms a ray by a matrix
  67450. * @param ray ray to transform
  67451. * @param matrix matrix to apply
  67452. * @param result ray to store result in
  67453. */
  67454. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  67455. /**
  67456. * Unproject a ray from screen space to object space
  67457. * @param sourceX defines the screen space x coordinate to use
  67458. * @param sourceY defines the screen space y coordinate to use
  67459. * @param viewportWidth defines the current width of the viewport
  67460. * @param viewportHeight defines the current height of the viewport
  67461. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67462. * @param view defines the view matrix to use
  67463. * @param projection defines the projection matrix to use
  67464. */
  67465. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  67466. }
  67467. interface Scene {
  67468. /** @hidden */
  67469. _tempPickingRay: Nullable<Ray>;
  67470. /** @hidden */
  67471. _cachedRayForTransform: Ray;
  67472. /** @hidden */
  67473. _pickWithRayInverseMatrix: Matrix;
  67474. /** @hidden */
  67475. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  67476. /** @hidden */
  67477. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  67478. }
  67479. }
  67480. declare module BABYLON {
  67481. /**
  67482. * Groups all the scene component constants in one place to ease maintenance.
  67483. * @hidden
  67484. */
  67485. export class SceneComponentConstants {
  67486. static readonly NAME_EFFECTLAYER: string;
  67487. static readonly NAME_LAYER: string;
  67488. static readonly NAME_LENSFLARESYSTEM: string;
  67489. static readonly NAME_BOUNDINGBOXRENDERER: string;
  67490. static readonly NAME_PARTICLESYSTEM: string;
  67491. static readonly NAME_GAMEPAD: string;
  67492. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  67493. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  67494. static readonly NAME_DEPTHRENDERER: string;
  67495. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  67496. static readonly NAME_SPRITE: string;
  67497. static readonly NAME_OUTLINERENDERER: string;
  67498. static readonly NAME_PROCEDURALTEXTURE: string;
  67499. static readonly NAME_SHADOWGENERATOR: string;
  67500. static readonly NAME_OCTREE: string;
  67501. static readonly NAME_PHYSICSENGINE: string;
  67502. static readonly NAME_AUDIO: string;
  67503. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  67504. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  67505. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  67506. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  67507. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  67508. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  67509. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  67510. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  67511. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  67512. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  67513. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  67514. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  67515. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  67516. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  67517. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  67518. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  67519. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  67520. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  67521. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  67522. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  67523. static readonly STEP_AFTERRENDER_AUDIO: number;
  67524. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  67525. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  67526. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  67527. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  67528. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  67529. static readonly STEP_POINTERMOVE_SPRITE: number;
  67530. static readonly STEP_POINTERDOWN_SPRITE: number;
  67531. static readonly STEP_POINTERUP_SPRITE: number;
  67532. }
  67533. /**
  67534. * This represents a scene component.
  67535. *
  67536. * This is used to decouple the dependency the scene is having on the different workloads like
  67537. * layers, post processes...
  67538. */
  67539. export interface ISceneComponent {
  67540. /**
  67541. * The name of the component. Each component must have a unique name.
  67542. */
  67543. name: string;
  67544. /**
  67545. * The scene the component belongs to.
  67546. */
  67547. scene: Scene;
  67548. /**
  67549. * Register the component to one instance of a scene.
  67550. */
  67551. register(): void;
  67552. /**
  67553. * Rebuilds the elements related to this component in case of
  67554. * context lost for instance.
  67555. */
  67556. rebuild(): void;
  67557. /**
  67558. * Disposes the component and the associated ressources.
  67559. */
  67560. dispose(): void;
  67561. }
  67562. /**
  67563. * This represents a SERIALIZABLE scene component.
  67564. *
  67565. * This extends Scene Component to add Serialization methods on top.
  67566. */
  67567. export interface ISceneSerializableComponent extends ISceneComponent {
  67568. /**
  67569. * Adds all the element from the container to the scene
  67570. * @param container the container holding the elements
  67571. */
  67572. addFromContainer(container: AbstractScene): void;
  67573. /**
  67574. * Removes all the elements in the container from the scene
  67575. * @param container contains the elements to remove
  67576. */
  67577. removeFromContainer(container: AbstractScene): void;
  67578. /**
  67579. * Serializes the component data to the specified json object
  67580. * @param serializationObject The object to serialize to
  67581. */
  67582. serialize(serializationObject: any): void;
  67583. }
  67584. /**
  67585. * Strong typing of a Mesh related stage step action
  67586. */
  67587. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  67588. /**
  67589. * Strong typing of a Evaluate Sub Mesh related stage step action
  67590. */
  67591. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  67592. /**
  67593. * Strong typing of a Active Mesh related stage step action
  67594. */
  67595. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  67596. /**
  67597. * Strong typing of a Camera related stage step action
  67598. */
  67599. export type CameraStageAction = (camera: Camera) => void;
  67600. /**
  67601. * Strong typing of a Render Target related stage step action
  67602. */
  67603. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  67604. /**
  67605. * Strong typing of a RenderingGroup related stage step action
  67606. */
  67607. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  67608. /**
  67609. * Strong typing of a Mesh Render related stage step action
  67610. */
  67611. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  67612. /**
  67613. * Strong typing of a simple stage step action
  67614. */
  67615. export type SimpleStageAction = () => void;
  67616. /**
  67617. * Strong typing of a render target action.
  67618. */
  67619. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  67620. /**
  67621. * Strong typing of a pointer move action.
  67622. */
  67623. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  67624. /**
  67625. * Strong typing of a pointer up/down action.
  67626. */
  67627. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  67628. /**
  67629. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  67630. * @hidden
  67631. */
  67632. export class Stage<T extends Function> extends Array<{
  67633. index: number;
  67634. component: ISceneComponent;
  67635. action: T;
  67636. }> {
  67637. /**
  67638. * Hide ctor from the rest of the world.
  67639. * @param items The items to add.
  67640. */
  67641. private constructor();
  67642. /**
  67643. * Creates a new Stage.
  67644. * @returns A new instance of a Stage
  67645. */
  67646. static Create<T extends Function>(): Stage<T>;
  67647. /**
  67648. * Registers a step in an ordered way in the targeted stage.
  67649. * @param index Defines the position to register the step in
  67650. * @param component Defines the component attached to the step
  67651. * @param action Defines the action to launch during the step
  67652. */
  67653. registerStep(index: number, component: ISceneComponent, action: T): void;
  67654. /**
  67655. * Clears all the steps from the stage.
  67656. */
  67657. clear(): void;
  67658. }
  67659. }
  67660. declare module BABYLON {
  67661. interface Scene {
  67662. /** @hidden */
  67663. _pointerOverSprite: Nullable<Sprite>;
  67664. /** @hidden */
  67665. _pickedDownSprite: Nullable<Sprite>;
  67666. /** @hidden */
  67667. _tempSpritePickingRay: Nullable<Ray>;
  67668. /**
  67669. * All of the sprite managers added to this scene
  67670. * @see http://doc.babylonjs.com/babylon101/sprites
  67671. */
  67672. spriteManagers: Array<ISpriteManager>;
  67673. /**
  67674. * An event triggered when sprites rendering is about to start
  67675. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  67676. */
  67677. onBeforeSpritesRenderingObservable: Observable<Scene>;
  67678. /**
  67679. * An event triggered when sprites rendering is done
  67680. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  67681. */
  67682. onAfterSpritesRenderingObservable: Observable<Scene>;
  67683. /** @hidden */
  67684. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  67685. /** Launch a ray to try to pick a sprite in the scene
  67686. * @param x position on screen
  67687. * @param y position on screen
  67688. * @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
  67689. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  67690. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  67691. * @returns a PickingInfo
  67692. */
  67693. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  67694. /** Use the given ray to pick a sprite in the scene
  67695. * @param ray The ray (in world space) to use to pick meshes
  67696. * @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
  67697. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  67698. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  67699. * @returns a PickingInfo
  67700. */
  67701. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  67702. /**
  67703. * Force the sprite under the pointer
  67704. * @param sprite defines the sprite to use
  67705. */
  67706. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  67707. /**
  67708. * Gets the sprite under the pointer
  67709. * @returns a Sprite or null if no sprite is under the pointer
  67710. */
  67711. getPointerOverSprite(): Nullable<Sprite>;
  67712. }
  67713. /**
  67714. * Defines the sprite scene component responsible to manage sprites
  67715. * in a given scene.
  67716. */
  67717. export class SpriteSceneComponent implements ISceneComponent {
  67718. /**
  67719. * The component name helpfull to identify the component in the list of scene components.
  67720. */
  67721. readonly name: string;
  67722. /**
  67723. * The scene the component belongs to.
  67724. */
  67725. scene: Scene;
  67726. /** @hidden */
  67727. private _spritePredicate;
  67728. /**
  67729. * Creates a new instance of the component for the given scene
  67730. * @param scene Defines the scene to register the component in
  67731. */
  67732. constructor(scene: Scene);
  67733. /**
  67734. * Registers the component in a given scene
  67735. */
  67736. register(): void;
  67737. /**
  67738. * Rebuilds the elements related to this component in case of
  67739. * context lost for instance.
  67740. */
  67741. rebuild(): void;
  67742. /**
  67743. * Disposes the component and the associated ressources.
  67744. */
  67745. dispose(): void;
  67746. private _pickSpriteButKeepRay;
  67747. private _pointerMove;
  67748. private _pointerDown;
  67749. private _pointerUp;
  67750. }
  67751. }
  67752. declare module BABYLON {
  67753. /** @hidden */
  67754. export var fogFragmentDeclaration: {
  67755. name: string;
  67756. shader: string;
  67757. };
  67758. }
  67759. declare module BABYLON {
  67760. /** @hidden */
  67761. export var fogFragment: {
  67762. name: string;
  67763. shader: string;
  67764. };
  67765. }
  67766. declare module BABYLON {
  67767. /** @hidden */
  67768. export var spritesPixelShader: {
  67769. name: string;
  67770. shader: string;
  67771. };
  67772. }
  67773. declare module BABYLON {
  67774. /** @hidden */
  67775. export var fogVertexDeclaration: {
  67776. name: string;
  67777. shader: string;
  67778. };
  67779. }
  67780. declare module BABYLON {
  67781. /** @hidden */
  67782. export var spritesVertexShader: {
  67783. name: string;
  67784. shader: string;
  67785. };
  67786. }
  67787. declare module BABYLON {
  67788. /**
  67789. * Defines the minimum interface to fullfil in order to be a sprite manager.
  67790. */
  67791. export interface ISpriteManager extends IDisposable {
  67792. /**
  67793. * Restricts the camera to viewing objects with the same layerMask.
  67794. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  67795. */
  67796. layerMask: number;
  67797. /**
  67798. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  67799. */
  67800. isPickable: boolean;
  67801. /**
  67802. * Specifies the rendering group id for this mesh (0 by default)
  67803. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  67804. */
  67805. renderingGroupId: number;
  67806. /**
  67807. * Defines the list of sprites managed by the manager.
  67808. */
  67809. sprites: Array<Sprite>;
  67810. /**
  67811. * Tests the intersection of a sprite with a specific ray.
  67812. * @param ray The ray we are sending to test the collision
  67813. * @param camera The camera space we are sending rays in
  67814. * @param predicate A predicate allowing excluding sprites from the list of object to test
  67815. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  67816. * @returns picking info or null.
  67817. */
  67818. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  67819. /**
  67820. * Renders the list of sprites on screen.
  67821. */
  67822. render(): void;
  67823. }
  67824. /**
  67825. * Class used to manage multiple sprites on the same spritesheet
  67826. * @see http://doc.babylonjs.com/babylon101/sprites
  67827. */
  67828. export class SpriteManager implements ISpriteManager {
  67829. /** defines the manager's name */
  67830. name: string;
  67831. /** Gets the list of sprites */
  67832. sprites: Sprite[];
  67833. /** Gets or sets the rendering group id (0 by default) */
  67834. renderingGroupId: number;
  67835. /** Gets or sets camera layer mask */
  67836. layerMask: number;
  67837. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  67838. fogEnabled: boolean;
  67839. /** Gets or sets a boolean indicating if the sprites are pickable */
  67840. isPickable: boolean;
  67841. /** Defines the default width of a cell in the spritesheet */
  67842. cellWidth: number;
  67843. /** Defines the default height of a cell in the spritesheet */
  67844. cellHeight: number;
  67845. /**
  67846. * An event triggered when the manager is disposed.
  67847. */
  67848. onDisposeObservable: Observable<SpriteManager>;
  67849. private _onDisposeObserver;
  67850. /**
  67851. * Callback called when the manager is disposed
  67852. */
  67853. onDispose: () => void;
  67854. private _capacity;
  67855. private _spriteTexture;
  67856. private _epsilon;
  67857. private _scene;
  67858. private _vertexData;
  67859. private _buffer;
  67860. private _vertexBuffers;
  67861. private _indexBuffer;
  67862. private _effectBase;
  67863. private _effectFog;
  67864. /**
  67865. * Gets or sets the spritesheet texture
  67866. */
  67867. texture: Texture;
  67868. /**
  67869. * Creates a new sprite manager
  67870. * @param name defines the manager's name
  67871. * @param imgUrl defines the sprite sheet url
  67872. * @param capacity defines the maximum allowed number of sprites
  67873. * @param cellSize defines the size of a sprite cell
  67874. * @param scene defines the hosting scene
  67875. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67876. * @param samplingMode defines the smapling mode to use with spritesheet
  67877. */
  67878. constructor(
  67879. /** defines the manager's name */
  67880. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  67881. private _appendSpriteVertex;
  67882. /**
  67883. * Intersects the sprites with a ray
  67884. * @param ray defines the ray to intersect with
  67885. * @param camera defines the current active camera
  67886. * @param predicate defines a predicate used to select candidate sprites
  67887. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  67888. * @returns null if no hit or a PickingInfo
  67889. */
  67890. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  67891. /**
  67892. * Render all child sprites
  67893. */
  67894. render(): void;
  67895. /**
  67896. * Release associated resources
  67897. */
  67898. dispose(): void;
  67899. }
  67900. }
  67901. declare module BABYLON {
  67902. /**
  67903. * Class used to represent a sprite
  67904. * @see http://doc.babylonjs.com/babylon101/sprites
  67905. */
  67906. export class Sprite {
  67907. /** defines the name */
  67908. name: string;
  67909. /** Gets or sets the current world position */
  67910. position: Vector3;
  67911. /** Gets or sets the main color */
  67912. color: Color4;
  67913. /** Gets or sets the width */
  67914. width: number;
  67915. /** Gets or sets the height */
  67916. height: number;
  67917. /** Gets or sets rotation angle */
  67918. angle: number;
  67919. /** Gets or sets the cell index in the sprite sheet */
  67920. cellIndex: number;
  67921. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  67922. invertU: number;
  67923. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  67924. invertV: number;
  67925. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  67926. disposeWhenFinishedAnimating: boolean;
  67927. /** Gets the list of attached animations */
  67928. animations: Animation[];
  67929. /** Gets or sets a boolean indicating if the sprite can be picked */
  67930. isPickable: boolean;
  67931. /**
  67932. * Gets or sets the associated action manager
  67933. */
  67934. actionManager: Nullable<ActionManager>;
  67935. private _animationStarted;
  67936. private _loopAnimation;
  67937. private _fromIndex;
  67938. private _toIndex;
  67939. private _delay;
  67940. private _direction;
  67941. private _manager;
  67942. private _time;
  67943. private _onAnimationEnd;
  67944. /**
  67945. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  67946. */
  67947. isVisible: boolean;
  67948. /**
  67949. * Gets or sets the sprite size
  67950. */
  67951. size: number;
  67952. /**
  67953. * Creates a new Sprite
  67954. * @param name defines the name
  67955. * @param manager defines the manager
  67956. */
  67957. constructor(
  67958. /** defines the name */
  67959. name: string, manager: ISpriteManager);
  67960. /**
  67961. * Starts an animation
  67962. * @param from defines the initial key
  67963. * @param to defines the end key
  67964. * @param loop defines if the animation must loop
  67965. * @param delay defines the start delay (in ms)
  67966. * @param onAnimationEnd defines a callback to call when animation ends
  67967. */
  67968. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  67969. /** Stops current animation (if any) */
  67970. stopAnimation(): void;
  67971. /** @hidden */
  67972. _animate(deltaTime: number): void;
  67973. /** Release associated resources */
  67974. dispose(): void;
  67975. }
  67976. }
  67977. declare module BABYLON {
  67978. /**
  67979. * Information about the result of picking within a scene
  67980. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  67981. */
  67982. export class PickingInfo {
  67983. /** @hidden */
  67984. _pickingUnavailable: boolean;
  67985. /**
  67986. * If the pick collided with an object
  67987. */
  67988. hit: boolean;
  67989. /**
  67990. * Distance away where the pick collided
  67991. */
  67992. distance: number;
  67993. /**
  67994. * The location of pick collision
  67995. */
  67996. pickedPoint: Nullable<Vector3>;
  67997. /**
  67998. * The mesh corresponding the the pick collision
  67999. */
  68000. pickedMesh: Nullable<AbstractMesh>;
  68001. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  68002. bu: number;
  68003. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  68004. bv: number;
  68005. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  68006. faceId: number;
  68007. /** Id of the the submesh that was picked */
  68008. subMeshId: number;
  68009. /** If a sprite was picked, this will be the sprite the pick collided with */
  68010. pickedSprite: Nullable<Sprite>;
  68011. /**
  68012. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  68013. */
  68014. originMesh: Nullable<AbstractMesh>;
  68015. /**
  68016. * The ray that was used to perform the picking.
  68017. */
  68018. ray: Nullable<Ray>;
  68019. /**
  68020. * Gets the normal correspodning to the face the pick collided with
  68021. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  68022. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  68023. * @returns The normal correspodning to the face the pick collided with
  68024. */
  68025. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  68026. /**
  68027. * Gets the texture coordinates of where the pick occured
  68028. * @returns the vector containing the coordnates of the texture
  68029. */
  68030. getTextureCoordinates(): Nullable<Vector2>;
  68031. }
  68032. }
  68033. declare module BABYLON {
  68034. /**
  68035. * Gather the list of pointer event types as constants.
  68036. */
  68037. export class PointerEventTypes {
  68038. /**
  68039. * 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.
  68040. */
  68041. static readonly POINTERDOWN: number;
  68042. /**
  68043. * The pointerup event is fired when a pointer is no longer active.
  68044. */
  68045. static readonly POINTERUP: number;
  68046. /**
  68047. * The pointermove event is fired when a pointer changes coordinates.
  68048. */
  68049. static readonly POINTERMOVE: number;
  68050. /**
  68051. * The pointerwheel event is fired when a mouse wheel has been rotated.
  68052. */
  68053. static readonly POINTERWHEEL: number;
  68054. /**
  68055. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  68056. */
  68057. static readonly POINTERPICK: number;
  68058. /**
  68059. * The pointertap event is fired when a the object has been touched and released without drag.
  68060. */
  68061. static readonly POINTERTAP: number;
  68062. /**
  68063. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  68064. */
  68065. static readonly POINTERDOUBLETAP: number;
  68066. }
  68067. /**
  68068. * Base class of pointer info types.
  68069. */
  68070. export class PointerInfoBase {
  68071. /**
  68072. * Defines the type of event (PointerEventTypes)
  68073. */
  68074. type: number;
  68075. /**
  68076. * Defines the related dom event
  68077. */
  68078. event: PointerEvent | MouseWheelEvent;
  68079. /**
  68080. * Instantiates the base class of pointers info.
  68081. * @param type Defines the type of event (PointerEventTypes)
  68082. * @param event Defines the related dom event
  68083. */
  68084. constructor(
  68085. /**
  68086. * Defines the type of event (PointerEventTypes)
  68087. */
  68088. type: number,
  68089. /**
  68090. * Defines the related dom event
  68091. */
  68092. event: PointerEvent | MouseWheelEvent);
  68093. }
  68094. /**
  68095. * This class is used to store pointer related info for the onPrePointerObservable event.
  68096. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  68097. */
  68098. export class PointerInfoPre extends PointerInfoBase {
  68099. /**
  68100. * Ray from a pointer if availible (eg. 6dof controller)
  68101. */
  68102. ray: Nullable<Ray>;
  68103. /**
  68104. * Defines the local position of the pointer on the canvas.
  68105. */
  68106. localPosition: Vector2;
  68107. /**
  68108. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  68109. */
  68110. skipOnPointerObservable: boolean;
  68111. /**
  68112. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  68113. * @param type Defines the type of event (PointerEventTypes)
  68114. * @param event Defines the related dom event
  68115. * @param localX Defines the local x coordinates of the pointer when the event occured
  68116. * @param localY Defines the local y coordinates of the pointer when the event occured
  68117. */
  68118. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  68119. }
  68120. /**
  68121. * This type contains all the data related to a pointer event in Babylon.js.
  68122. * 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.
  68123. */
  68124. export class PointerInfo extends PointerInfoBase {
  68125. /**
  68126. * Defines the picking info associated to the info (if any)\
  68127. */
  68128. pickInfo: Nullable<PickingInfo>;
  68129. /**
  68130. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  68131. * @param type Defines the type of event (PointerEventTypes)
  68132. * @param event Defines the related dom event
  68133. * @param pickInfo Defines the picking info associated to the info (if any)\
  68134. */
  68135. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  68136. /**
  68137. * Defines the picking info associated to the info (if any)\
  68138. */
  68139. pickInfo: Nullable<PickingInfo>);
  68140. }
  68141. }
  68142. declare module BABYLON {
  68143. /**
  68144. * Manage the mouse inputs to control the movement of a free camera.
  68145. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68146. */
  68147. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  68148. /**
  68149. * Define if touch is enabled in the mouse input
  68150. */
  68151. touchEnabled: boolean;
  68152. /**
  68153. * Defines the camera the input is attached to.
  68154. */
  68155. camera: FreeCamera;
  68156. /**
  68157. * Defines the buttons associated with the input to handle camera move.
  68158. */
  68159. buttons: number[];
  68160. /**
  68161. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  68162. */
  68163. angularSensibility: number;
  68164. private _pointerInput;
  68165. private _onMouseMove;
  68166. private _observer;
  68167. private previousPosition;
  68168. /**
  68169. * Manage the mouse inputs to control the movement of a free camera.
  68170. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68171. * @param touchEnabled Defines if touch is enabled or not
  68172. */
  68173. constructor(
  68174. /**
  68175. * Define if touch is enabled in the mouse input
  68176. */
  68177. touchEnabled?: boolean);
  68178. /**
  68179. * Attach the input controls to a specific dom element to get the input from.
  68180. * @param element Defines the element the controls should be listened from
  68181. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68182. */
  68183. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68184. /**
  68185. * Detach the current controls from the specified dom element.
  68186. * @param element Defines the element to stop listening the inputs from
  68187. */
  68188. detachControl(element: Nullable<HTMLElement>): void;
  68189. /**
  68190. * Gets the class name of the current intput.
  68191. * @returns the class name
  68192. */
  68193. getClassName(): string;
  68194. /**
  68195. * Get the friendly name associated with the input class.
  68196. * @returns the input friendly name
  68197. */
  68198. getSimpleName(): string;
  68199. }
  68200. }
  68201. declare module BABYLON {
  68202. /**
  68203. * Manage the touch inputs to control the movement of a free camera.
  68204. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68205. */
  68206. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  68207. /**
  68208. * Defines the camera the input is attached to.
  68209. */
  68210. camera: FreeCamera;
  68211. /**
  68212. * Defines the touch sensibility for rotation.
  68213. * The higher the faster.
  68214. */
  68215. touchAngularSensibility: number;
  68216. /**
  68217. * Defines the touch sensibility for move.
  68218. * The higher the faster.
  68219. */
  68220. touchMoveSensibility: number;
  68221. private _offsetX;
  68222. private _offsetY;
  68223. private _pointerPressed;
  68224. private _pointerInput;
  68225. private _observer;
  68226. private _onLostFocus;
  68227. /**
  68228. * Attach the input controls to a specific dom element to get the input from.
  68229. * @param element Defines the element the controls should be listened from
  68230. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68231. */
  68232. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68233. /**
  68234. * Detach the current controls from the specified dom element.
  68235. * @param element Defines the element to stop listening the inputs from
  68236. */
  68237. detachControl(element: Nullable<HTMLElement>): void;
  68238. /**
  68239. * Update the current camera state depending on the inputs that have been used this frame.
  68240. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68241. */
  68242. checkInputs(): void;
  68243. /**
  68244. * Gets the class name of the current intput.
  68245. * @returns the class name
  68246. */
  68247. getClassName(): string;
  68248. /**
  68249. * Get the friendly name associated with the input class.
  68250. * @returns the input friendly name
  68251. */
  68252. getSimpleName(): string;
  68253. }
  68254. }
  68255. declare module BABYLON {
  68256. /**
  68257. * Default Inputs manager for the FreeCamera.
  68258. * It groups all the default supported inputs for ease of use.
  68259. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68260. */
  68261. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  68262. /**
  68263. * Instantiates a new FreeCameraInputsManager.
  68264. * @param camera Defines the camera the inputs belong to
  68265. */
  68266. constructor(camera: FreeCamera);
  68267. /**
  68268. * Add keyboard input support to the input manager.
  68269. * @returns the current input manager
  68270. */
  68271. addKeyboard(): FreeCameraInputsManager;
  68272. /**
  68273. * Add mouse input support to the input manager.
  68274. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  68275. * @returns the current input manager
  68276. */
  68277. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  68278. /**
  68279. * Add touch input support to the input manager.
  68280. * @returns the current input manager
  68281. */
  68282. addTouch(): FreeCameraInputsManager;
  68283. }
  68284. }
  68285. declare module BABYLON {
  68286. /**
  68287. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  68288. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  68289. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  68290. */
  68291. export class FreeCamera extends TargetCamera {
  68292. /**
  68293. * Define the collision ellipsoid of the camera.
  68294. * This is helpful to simulate a camera body like the player body around the camera
  68295. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  68296. */
  68297. ellipsoid: Vector3;
  68298. /**
  68299. * Define an offset for the position of the ellipsoid around the camera.
  68300. * This can be helpful to determine the center of the body near the gravity center of the body
  68301. * instead of its head.
  68302. */
  68303. ellipsoidOffset: Vector3;
  68304. /**
  68305. * Enable or disable collisions of the camera with the rest of the scene objects.
  68306. */
  68307. checkCollisions: boolean;
  68308. /**
  68309. * Enable or disable gravity on the camera.
  68310. */
  68311. applyGravity: boolean;
  68312. /**
  68313. * Define the input manager associated to the camera.
  68314. */
  68315. inputs: FreeCameraInputsManager;
  68316. /**
  68317. * Gets the input sensibility for a mouse input. (default is 2000.0)
  68318. * Higher values reduce sensitivity.
  68319. */
  68320. /**
  68321. * Sets the input sensibility for a mouse input. (default is 2000.0)
  68322. * Higher values reduce sensitivity.
  68323. */
  68324. angularSensibility: number;
  68325. /**
  68326. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68327. */
  68328. keysUp: number[];
  68329. /**
  68330. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68331. */
  68332. keysDown: number[];
  68333. /**
  68334. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68335. */
  68336. keysLeft: number[];
  68337. /**
  68338. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68339. */
  68340. keysRight: number[];
  68341. /**
  68342. * Event raised when the camera collide with a mesh in the scene.
  68343. */
  68344. onCollide: (collidedMesh: AbstractMesh) => void;
  68345. private _collider;
  68346. private _needMoveForGravity;
  68347. private _oldPosition;
  68348. private _diffPosition;
  68349. private _newPosition;
  68350. /** @hidden */
  68351. _localDirection: Vector3;
  68352. /** @hidden */
  68353. _transformedDirection: Vector3;
  68354. /**
  68355. * Instantiates a Free Camera.
  68356. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  68357. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  68358. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  68359. * @param name Define the name of the camera in the scene
  68360. * @param position Define the start position of the camera in the scene
  68361. * @param scene Define the scene the camera belongs to
  68362. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  68363. */
  68364. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  68365. /**
  68366. * Attached controls to the current camera.
  68367. * @param element Defines the element the controls should be listened from
  68368. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68369. */
  68370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68371. /**
  68372. * Detach the current controls from the camera.
  68373. * The camera will stop reacting to inputs.
  68374. * @param element Defines the element to stop listening the inputs from
  68375. */
  68376. detachControl(element: HTMLElement): void;
  68377. private _collisionMask;
  68378. /**
  68379. * Define a collision mask to limit the list of object the camera can collide with
  68380. */
  68381. collisionMask: number;
  68382. /** @hidden */
  68383. _collideWithWorld(displacement: Vector3): void;
  68384. private _onCollisionPositionChange;
  68385. /** @hidden */
  68386. _checkInputs(): void;
  68387. /** @hidden */
  68388. _decideIfNeedsToMove(): boolean;
  68389. /** @hidden */
  68390. _updatePosition(): void;
  68391. /**
  68392. * Destroy the camera and release the current resources hold by it.
  68393. */
  68394. dispose(): void;
  68395. /**
  68396. * Gets the current object class name.
  68397. * @return the class name
  68398. */
  68399. getClassName(): string;
  68400. }
  68401. }
  68402. declare module BABYLON {
  68403. /**
  68404. * Represents a gamepad control stick position
  68405. */
  68406. export class StickValues {
  68407. /**
  68408. * The x component of the control stick
  68409. */
  68410. x: number;
  68411. /**
  68412. * The y component of the control stick
  68413. */
  68414. y: number;
  68415. /**
  68416. * Initializes the gamepad x and y control stick values
  68417. * @param x The x component of the gamepad control stick value
  68418. * @param y The y component of the gamepad control stick value
  68419. */
  68420. constructor(
  68421. /**
  68422. * The x component of the control stick
  68423. */
  68424. x: number,
  68425. /**
  68426. * The y component of the control stick
  68427. */
  68428. y: number);
  68429. }
  68430. /**
  68431. * An interface which manages callbacks for gamepad button changes
  68432. */
  68433. export interface GamepadButtonChanges {
  68434. /**
  68435. * Called when a gamepad has been changed
  68436. */
  68437. changed: boolean;
  68438. /**
  68439. * Called when a gamepad press event has been triggered
  68440. */
  68441. pressChanged: boolean;
  68442. /**
  68443. * Called when a touch event has been triggered
  68444. */
  68445. touchChanged: boolean;
  68446. /**
  68447. * Called when a value has changed
  68448. */
  68449. valueChanged: boolean;
  68450. }
  68451. /**
  68452. * Represents a gamepad
  68453. */
  68454. export class Gamepad {
  68455. /**
  68456. * The id of the gamepad
  68457. */
  68458. id: string;
  68459. /**
  68460. * The index of the gamepad
  68461. */
  68462. index: number;
  68463. /**
  68464. * The browser gamepad
  68465. */
  68466. browserGamepad: any;
  68467. /**
  68468. * Specifies what type of gamepad this represents
  68469. */
  68470. type: number;
  68471. private _leftStick;
  68472. private _rightStick;
  68473. /** @hidden */
  68474. _isConnected: boolean;
  68475. private _leftStickAxisX;
  68476. private _leftStickAxisY;
  68477. private _rightStickAxisX;
  68478. private _rightStickAxisY;
  68479. /**
  68480. * Triggered when the left control stick has been changed
  68481. */
  68482. private _onleftstickchanged;
  68483. /**
  68484. * Triggered when the right control stick has been changed
  68485. */
  68486. private _onrightstickchanged;
  68487. /**
  68488. * Represents a gamepad controller
  68489. */
  68490. static GAMEPAD: number;
  68491. /**
  68492. * Represents a generic controller
  68493. */
  68494. static GENERIC: number;
  68495. /**
  68496. * Represents an XBox controller
  68497. */
  68498. static XBOX: number;
  68499. /**
  68500. * Represents a pose-enabled controller
  68501. */
  68502. static POSE_ENABLED: number;
  68503. /**
  68504. * Specifies whether the left control stick should be Y-inverted
  68505. */
  68506. protected _invertLeftStickY: boolean;
  68507. /**
  68508. * Specifies if the gamepad has been connected
  68509. */
  68510. readonly isConnected: boolean;
  68511. /**
  68512. * Initializes the gamepad
  68513. * @param id The id of the gamepad
  68514. * @param index The index of the gamepad
  68515. * @param browserGamepad The browser gamepad
  68516. * @param leftStickX The x component of the left joystick
  68517. * @param leftStickY The y component of the left joystick
  68518. * @param rightStickX The x component of the right joystick
  68519. * @param rightStickY The y component of the right joystick
  68520. */
  68521. constructor(
  68522. /**
  68523. * The id of the gamepad
  68524. */
  68525. id: string,
  68526. /**
  68527. * The index of the gamepad
  68528. */
  68529. index: number,
  68530. /**
  68531. * The browser gamepad
  68532. */
  68533. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  68534. /**
  68535. * Callback triggered when the left joystick has changed
  68536. * @param callback
  68537. */
  68538. onleftstickchanged(callback: (values: StickValues) => void): void;
  68539. /**
  68540. * Callback triggered when the right joystick has changed
  68541. * @param callback
  68542. */
  68543. onrightstickchanged(callback: (values: StickValues) => void): void;
  68544. /**
  68545. * Gets the left joystick
  68546. */
  68547. /**
  68548. * Sets the left joystick values
  68549. */
  68550. leftStick: StickValues;
  68551. /**
  68552. * Gets the right joystick
  68553. */
  68554. /**
  68555. * Sets the right joystick value
  68556. */
  68557. rightStick: StickValues;
  68558. /**
  68559. * Updates the gamepad joystick positions
  68560. */
  68561. update(): void;
  68562. /**
  68563. * Disposes the gamepad
  68564. */
  68565. dispose(): void;
  68566. }
  68567. /**
  68568. * Represents a generic gamepad
  68569. */
  68570. export class GenericPad extends Gamepad {
  68571. private _buttons;
  68572. private _onbuttondown;
  68573. private _onbuttonup;
  68574. /**
  68575. * Observable triggered when a button has been pressed
  68576. */
  68577. onButtonDownObservable: Observable<number>;
  68578. /**
  68579. * Observable triggered when a button has been released
  68580. */
  68581. onButtonUpObservable: Observable<number>;
  68582. /**
  68583. * Callback triggered when a button has been pressed
  68584. * @param callback Called when a button has been pressed
  68585. */
  68586. onbuttondown(callback: (buttonPressed: number) => void): void;
  68587. /**
  68588. * Callback triggered when a button has been released
  68589. * @param callback Called when a button has been released
  68590. */
  68591. onbuttonup(callback: (buttonReleased: number) => void): void;
  68592. /**
  68593. * Initializes the generic gamepad
  68594. * @param id The id of the generic gamepad
  68595. * @param index The index of the generic gamepad
  68596. * @param browserGamepad The browser gamepad
  68597. */
  68598. constructor(id: string, index: number, browserGamepad: any);
  68599. private _setButtonValue;
  68600. /**
  68601. * Updates the generic gamepad
  68602. */
  68603. update(): void;
  68604. /**
  68605. * Disposes the generic gamepad
  68606. */
  68607. dispose(): void;
  68608. }
  68609. }
  68610. declare module BABYLON {
  68611. /**
  68612. * 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.
  68613. * @see https://doc.babylonjs.com/how_to/transformnode
  68614. */
  68615. export class TransformNode extends Node {
  68616. /**
  68617. * Object will not rotate to face the camera
  68618. */
  68619. static BILLBOARDMODE_NONE: number;
  68620. /**
  68621. * Object will rotate to face the camera but only on the x axis
  68622. */
  68623. static BILLBOARDMODE_X: number;
  68624. /**
  68625. * Object will rotate to face the camera but only on the y axis
  68626. */
  68627. static BILLBOARDMODE_Y: number;
  68628. /**
  68629. * Object will rotate to face the camera but only on the z axis
  68630. */
  68631. static BILLBOARDMODE_Z: number;
  68632. /**
  68633. * Object will rotate to face the camera
  68634. */
  68635. static BILLBOARDMODE_ALL: number;
  68636. private _forward;
  68637. private _forwardInverted;
  68638. private _up;
  68639. private _right;
  68640. private _rightInverted;
  68641. private _position;
  68642. private _rotation;
  68643. private _rotationQuaternion;
  68644. protected _scaling: Vector3;
  68645. protected _isDirty: boolean;
  68646. private _transformToBoneReferal;
  68647. /**
  68648. * Set the billboard mode. Default is 0.
  68649. *
  68650. * | Value | Type | Description |
  68651. * | --- | --- | --- |
  68652. * | 0 | BILLBOARDMODE_NONE | |
  68653. * | 1 | BILLBOARDMODE_X | |
  68654. * | 2 | BILLBOARDMODE_Y | |
  68655. * | 4 | BILLBOARDMODE_Z | |
  68656. * | 7 | BILLBOARDMODE_ALL | |
  68657. *
  68658. */
  68659. billboardMode: number;
  68660. /**
  68661. * 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
  68662. */
  68663. scalingDeterminant: number;
  68664. /**
  68665. * Sets the distance of the object to max, often used by skybox
  68666. */
  68667. infiniteDistance: boolean;
  68668. /**
  68669. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  68670. * By default the system will update normals to compensate
  68671. */
  68672. ignoreNonUniformScaling: boolean;
  68673. /** @hidden */
  68674. _poseMatrix: Matrix;
  68675. /** @hidden */
  68676. _localMatrix: Matrix;
  68677. private _absolutePosition;
  68678. private _pivotMatrix;
  68679. private _pivotMatrixInverse;
  68680. protected _postMultiplyPivotMatrix: boolean;
  68681. protected _isWorldMatrixFrozen: boolean;
  68682. /** @hidden */
  68683. _indexInSceneTransformNodesArray: number;
  68684. /**
  68685. * An event triggered after the world matrix is updated
  68686. */
  68687. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  68688. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  68689. /**
  68690. * Gets a string identifying the name of the class
  68691. * @returns "TransformNode" string
  68692. */
  68693. getClassName(): string;
  68694. /**
  68695. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  68696. */
  68697. position: Vector3;
  68698. /**
  68699. * 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)).
  68700. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  68701. */
  68702. rotation: Vector3;
  68703. /**
  68704. * 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)).
  68705. */
  68706. scaling: Vector3;
  68707. /**
  68708. * 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).
  68709. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  68710. */
  68711. rotationQuaternion: Nullable<Quaternion>;
  68712. /**
  68713. * The forward direction of that transform in world space.
  68714. */
  68715. readonly forward: Vector3;
  68716. /**
  68717. * The up direction of that transform in world space.
  68718. */
  68719. readonly up: Vector3;
  68720. /**
  68721. * The right direction of that transform in world space.
  68722. */
  68723. readonly right: Vector3;
  68724. /**
  68725. * Copies the parameter passed Matrix into the mesh Pose matrix.
  68726. * @param matrix the matrix to copy the pose from
  68727. * @returns this TransformNode.
  68728. */
  68729. updatePoseMatrix(matrix: Matrix): TransformNode;
  68730. /**
  68731. * Returns the mesh Pose matrix.
  68732. * @returns the pose matrix
  68733. */
  68734. getPoseMatrix(): Matrix;
  68735. /** @hidden */
  68736. _isSynchronized(): boolean;
  68737. /** @hidden */
  68738. _initCache(): void;
  68739. /**
  68740. * Flag the transform node as dirty (Forcing it to update everything)
  68741. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  68742. * @returns this transform node
  68743. */
  68744. markAsDirty(property: string): TransformNode;
  68745. /**
  68746. * Returns the current mesh absolute position.
  68747. * Returns a Vector3.
  68748. */
  68749. readonly absolutePosition: Vector3;
  68750. /**
  68751. * Sets a new matrix to apply before all other transformation
  68752. * @param matrix defines the transform matrix
  68753. * @returns the current TransformNode
  68754. */
  68755. setPreTransformMatrix(matrix: Matrix): TransformNode;
  68756. /**
  68757. * Sets a new pivot matrix to the current node
  68758. * @param matrix defines the new pivot matrix to use
  68759. * @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
  68760. * @returns the current TransformNode
  68761. */
  68762. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  68763. /**
  68764. * Returns the mesh pivot matrix.
  68765. * Default : Identity.
  68766. * @returns the matrix
  68767. */
  68768. getPivotMatrix(): Matrix;
  68769. /**
  68770. * Prevents the World matrix to be computed any longer.
  68771. * @returns the TransformNode.
  68772. */
  68773. freezeWorldMatrix(): TransformNode;
  68774. /**
  68775. * Allows back the World matrix computation.
  68776. * @returns the TransformNode.
  68777. */
  68778. unfreezeWorldMatrix(): this;
  68779. /**
  68780. * True if the World matrix has been frozen.
  68781. */
  68782. readonly isWorldMatrixFrozen: boolean;
  68783. /**
  68784. * Retuns the mesh absolute position in the World.
  68785. * @returns a Vector3.
  68786. */
  68787. getAbsolutePosition(): Vector3;
  68788. /**
  68789. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  68790. * @param absolutePosition the absolute position to set
  68791. * @returns the TransformNode.
  68792. */
  68793. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  68794. /**
  68795. * Sets the mesh position in its local space.
  68796. * @param vector3 the position to set in localspace
  68797. * @returns the TransformNode.
  68798. */
  68799. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  68800. /**
  68801. * Returns the mesh position in the local space from the current World matrix values.
  68802. * @returns a new Vector3.
  68803. */
  68804. getPositionExpressedInLocalSpace(): Vector3;
  68805. /**
  68806. * Translates the mesh along the passed Vector3 in its local space.
  68807. * @param vector3 the distance to translate in localspace
  68808. * @returns the TransformNode.
  68809. */
  68810. locallyTranslate(vector3: Vector3): TransformNode;
  68811. private static _lookAtVectorCache;
  68812. /**
  68813. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  68814. * @param targetPoint the position (must be in same space as current mesh) to look at
  68815. * @param yawCor optional yaw (y-axis) correction in radians
  68816. * @param pitchCor optional pitch (x-axis) correction in radians
  68817. * @param rollCor optional roll (z-axis) correction in radians
  68818. * @param space the choosen space of the target
  68819. * @returns the TransformNode.
  68820. */
  68821. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  68822. /**
  68823. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  68824. * This Vector3 is expressed in the World space.
  68825. * @param localAxis axis to rotate
  68826. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  68827. */
  68828. getDirection(localAxis: Vector3): Vector3;
  68829. /**
  68830. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  68831. * localAxis is expressed in the mesh local space.
  68832. * result is computed in the Wordl space from the mesh World matrix.
  68833. * @param localAxis axis to rotate
  68834. * @param result the resulting transformnode
  68835. * @returns this TransformNode.
  68836. */
  68837. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  68838. /**
  68839. * Sets this transform node rotation to the given local axis.
  68840. * @param localAxis the axis in local space
  68841. * @param yawCor optional yaw (y-axis) correction in radians
  68842. * @param pitchCor optional pitch (x-axis) correction in radians
  68843. * @param rollCor optional roll (z-axis) correction in radians
  68844. * @returns this TransformNode
  68845. */
  68846. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  68847. /**
  68848. * Sets a new pivot point to the current node
  68849. * @param point defines the new pivot point to use
  68850. * @param space defines if the point is in world or local space (local by default)
  68851. * @returns the current TransformNode
  68852. */
  68853. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  68854. /**
  68855. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  68856. * @returns the pivot point
  68857. */
  68858. getPivotPoint(): Vector3;
  68859. /**
  68860. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  68861. * @param result the vector3 to store the result
  68862. * @returns this TransformNode.
  68863. */
  68864. getPivotPointToRef(result: Vector3): TransformNode;
  68865. /**
  68866. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  68867. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  68868. */
  68869. getAbsolutePivotPoint(): Vector3;
  68870. /**
  68871. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  68872. * @param result vector3 to store the result
  68873. * @returns this TransformNode.
  68874. */
  68875. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  68876. /**
  68877. * Defines the passed node as the parent of the current node.
  68878. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  68879. * @param node the node ot set as the parent
  68880. * @returns this TransformNode.
  68881. */
  68882. setParent(node: Nullable<Node>): TransformNode;
  68883. private _nonUniformScaling;
  68884. /**
  68885. * True if the scaling property of this object is non uniform eg. (1,2,1)
  68886. */
  68887. readonly nonUniformScaling: boolean;
  68888. /** @hidden */
  68889. _updateNonUniformScalingState(value: boolean): boolean;
  68890. /**
  68891. * Attach the current TransformNode to another TransformNode associated with a bone
  68892. * @param bone Bone affecting the TransformNode
  68893. * @param affectedTransformNode TransformNode associated with the bone
  68894. * @returns this object
  68895. */
  68896. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  68897. /**
  68898. * Detach the transform node if its associated with a bone
  68899. * @returns this object
  68900. */
  68901. detachFromBone(): TransformNode;
  68902. private static _rotationAxisCache;
  68903. /**
  68904. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  68905. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  68906. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  68907. * The passed axis is also normalized.
  68908. * @param axis the axis to rotate around
  68909. * @param amount the amount to rotate in radians
  68910. * @param space Space to rotate in (Default: local)
  68911. * @returns the TransformNode.
  68912. */
  68913. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  68914. /**
  68915. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  68916. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  68917. * The passed axis is also normalized. .
  68918. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  68919. * @param point the point to rotate around
  68920. * @param axis the axis to rotate around
  68921. * @param amount the amount to rotate in radians
  68922. * @returns the TransformNode
  68923. */
  68924. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  68925. /**
  68926. * Translates the mesh along the axis vector for the passed distance in the given space.
  68927. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  68928. * @param axis the axis to translate in
  68929. * @param distance the distance to translate
  68930. * @param space Space to rotate in (Default: local)
  68931. * @returns the TransformNode.
  68932. */
  68933. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  68934. /**
  68935. * Adds a rotation step to the mesh current rotation.
  68936. * x, y, z are Euler angles expressed in radians.
  68937. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  68938. * This means this rotation is made in the mesh local space only.
  68939. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  68940. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  68941. * ```javascript
  68942. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  68943. * ```
  68944. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  68945. * 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.
  68946. * @param x Rotation to add
  68947. * @param y Rotation to add
  68948. * @param z Rotation to add
  68949. * @returns the TransformNode.
  68950. */
  68951. addRotation(x: number, y: number, z: number): TransformNode;
  68952. /**
  68953. * Computes the world matrix of the node
  68954. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  68955. * @returns the world matrix
  68956. */
  68957. computeWorldMatrix(force?: boolean): Matrix;
  68958. protected _afterComputeWorldMatrix(): void;
  68959. /**
  68960. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  68961. * @param func callback function to add
  68962. *
  68963. * @returns the TransformNode.
  68964. */
  68965. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  68966. /**
  68967. * Removes a registered callback function.
  68968. * @param func callback function to remove
  68969. * @returns the TransformNode.
  68970. */
  68971. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  68972. /**
  68973. * Gets the position of the current mesh in camera space
  68974. * @param camera defines the camera to use
  68975. * @returns a position
  68976. */
  68977. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  68978. /**
  68979. * Returns the distance from the mesh to the active camera
  68980. * @param camera defines the camera to use
  68981. * @returns the distance
  68982. */
  68983. getDistanceToCamera(camera?: Nullable<Camera>): number;
  68984. /**
  68985. * Clone the current transform node
  68986. * @param name Name of the new clone
  68987. * @param newParent New parent for the clone
  68988. * @param doNotCloneChildren Do not clone children hierarchy
  68989. * @returns the new transform node
  68990. */
  68991. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  68992. /**
  68993. * Serializes the objects information.
  68994. * @param currentSerializationObject defines the object to serialize in
  68995. * @returns the serialized object
  68996. */
  68997. serialize(currentSerializationObject?: any): any;
  68998. /**
  68999. * Returns a new TransformNode object parsed from the source provided.
  69000. * @param parsedTransformNode is the source.
  69001. * @param scene the scne the object belongs to
  69002. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  69003. * @returns a new TransformNode object parsed from the source provided.
  69004. */
  69005. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  69006. /**
  69007. * Get all child-transformNodes of this node
  69008. * @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
  69009. * @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
  69010. * @returns an array of TransformNode
  69011. */
  69012. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  69013. /**
  69014. * Releases resources associated with this transform node.
  69015. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  69016. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  69017. */
  69018. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  69019. }
  69020. }
  69021. declare module BABYLON {
  69022. /**
  69023. * Defines the types of pose enabled controllers that are supported
  69024. */
  69025. export enum PoseEnabledControllerType {
  69026. /**
  69027. * HTC Vive
  69028. */
  69029. VIVE = 0,
  69030. /**
  69031. * Oculus Rift
  69032. */
  69033. OCULUS = 1,
  69034. /**
  69035. * Windows mixed reality
  69036. */
  69037. WINDOWS = 2,
  69038. /**
  69039. * Samsung gear VR
  69040. */
  69041. GEAR_VR = 3,
  69042. /**
  69043. * Google Daydream
  69044. */
  69045. DAYDREAM = 4,
  69046. /**
  69047. * Generic
  69048. */
  69049. GENERIC = 5
  69050. }
  69051. /**
  69052. * Defines the MutableGamepadButton interface for the state of a gamepad button
  69053. */
  69054. export interface MutableGamepadButton {
  69055. /**
  69056. * Value of the button/trigger
  69057. */
  69058. value: number;
  69059. /**
  69060. * If the button/trigger is currently touched
  69061. */
  69062. touched: boolean;
  69063. /**
  69064. * If the button/trigger is currently pressed
  69065. */
  69066. pressed: boolean;
  69067. }
  69068. /**
  69069. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  69070. * @hidden
  69071. */
  69072. export interface ExtendedGamepadButton extends GamepadButton {
  69073. /**
  69074. * If the button/trigger is currently pressed
  69075. */
  69076. readonly pressed: boolean;
  69077. /**
  69078. * If the button/trigger is currently touched
  69079. */
  69080. readonly touched: boolean;
  69081. /**
  69082. * Value of the button/trigger
  69083. */
  69084. readonly value: number;
  69085. }
  69086. /** @hidden */
  69087. export interface _GamePadFactory {
  69088. /**
  69089. * Returns wether or not the current gamepad can be created for this type of controller.
  69090. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69091. * @returns true if it can be created, otherwise false
  69092. */
  69093. canCreate(gamepadInfo: any): boolean;
  69094. /**
  69095. * Creates a new instance of the Gamepad.
  69096. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69097. * @returns the new gamepad instance
  69098. */
  69099. create(gamepadInfo: any): Gamepad;
  69100. }
  69101. /**
  69102. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69103. */
  69104. export class PoseEnabledControllerHelper {
  69105. /** @hidden */
  69106. static _ControllerFactories: _GamePadFactory[];
  69107. /** @hidden */
  69108. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  69109. /**
  69110. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69111. * @param vrGamepad the gamepad to initialized
  69112. * @returns a vr controller of the type the gamepad identified as
  69113. */
  69114. static InitiateController(vrGamepad: any): Gamepad;
  69115. }
  69116. /**
  69117. * Defines the PoseEnabledController object that contains state of a vr capable controller
  69118. */
  69119. export class PoseEnabledController extends Gamepad implements PoseControlled {
  69120. private _deviceRoomPosition;
  69121. private _deviceRoomRotationQuaternion;
  69122. /**
  69123. * The device position in babylon space
  69124. */
  69125. devicePosition: Vector3;
  69126. /**
  69127. * The device rotation in babylon space
  69128. */
  69129. deviceRotationQuaternion: Quaternion;
  69130. /**
  69131. * The scale factor of the device in babylon space
  69132. */
  69133. deviceScaleFactor: number;
  69134. /**
  69135. * (Likely devicePosition should be used instead) The device position in its room space
  69136. */
  69137. position: Vector3;
  69138. /**
  69139. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  69140. */
  69141. rotationQuaternion: Quaternion;
  69142. /**
  69143. * The type of controller (Eg. Windows mixed reality)
  69144. */
  69145. controllerType: PoseEnabledControllerType;
  69146. protected _calculatedPosition: Vector3;
  69147. private _calculatedRotation;
  69148. /**
  69149. * The raw pose from the device
  69150. */
  69151. rawPose: DevicePose;
  69152. private _trackPosition;
  69153. private _maxRotationDistFromHeadset;
  69154. private _draggedRoomRotation;
  69155. /**
  69156. * @hidden
  69157. */
  69158. _disableTrackPosition(fixedPosition: Vector3): void;
  69159. /**
  69160. * Internal, the mesh attached to the controller
  69161. * @hidden
  69162. */
  69163. _mesh: Nullable<AbstractMesh>;
  69164. private _poseControlledCamera;
  69165. private _leftHandSystemQuaternion;
  69166. /**
  69167. * Internal, matrix used to convert room space to babylon space
  69168. * @hidden
  69169. */
  69170. _deviceToWorld: Matrix;
  69171. /**
  69172. * Node to be used when casting a ray from the controller
  69173. * @hidden
  69174. */
  69175. _pointingPoseNode: Nullable<TransformNode>;
  69176. /**
  69177. * Name of the child mesh that can be used to cast a ray from the controller
  69178. */
  69179. static readonly POINTING_POSE: string;
  69180. /**
  69181. * Creates a new PoseEnabledController from a gamepad
  69182. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  69183. */
  69184. constructor(browserGamepad: any);
  69185. private _workingMatrix;
  69186. /**
  69187. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  69188. */
  69189. update(): void;
  69190. /**
  69191. * Updates only the pose device and mesh without doing any button event checking
  69192. */
  69193. protected _updatePoseAndMesh(): void;
  69194. /**
  69195. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  69196. * @param poseData raw pose fromthe device
  69197. */
  69198. updateFromDevice(poseData: DevicePose): void;
  69199. /**
  69200. * @hidden
  69201. */
  69202. _meshAttachedObservable: Observable<AbstractMesh>;
  69203. /**
  69204. * Attaches a mesh to the controller
  69205. * @param mesh the mesh to be attached
  69206. */
  69207. attachToMesh(mesh: AbstractMesh): void;
  69208. /**
  69209. * Attaches the controllers mesh to a camera
  69210. * @param camera the camera the mesh should be attached to
  69211. */
  69212. attachToPoseControlledCamera(camera: TargetCamera): void;
  69213. /**
  69214. * Disposes of the controller
  69215. */
  69216. dispose(): void;
  69217. /**
  69218. * The mesh that is attached to the controller
  69219. */
  69220. readonly mesh: Nullable<AbstractMesh>;
  69221. /**
  69222. * Gets the ray of the controller in the direction the controller is pointing
  69223. * @param length the length the resulting ray should be
  69224. * @returns a ray in the direction the controller is pointing
  69225. */
  69226. getForwardRay(length?: number): Ray;
  69227. }
  69228. }
  69229. declare module BABYLON {
  69230. /**
  69231. * Defines the WebVRController object that represents controllers tracked in 3D space
  69232. */
  69233. export abstract class WebVRController extends PoseEnabledController {
  69234. /**
  69235. * Internal, the default controller model for the controller
  69236. */
  69237. protected _defaultModel: AbstractMesh;
  69238. /**
  69239. * Fired when the trigger state has changed
  69240. */
  69241. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  69242. /**
  69243. * Fired when the main button state has changed
  69244. */
  69245. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  69246. /**
  69247. * Fired when the secondary button state has changed
  69248. */
  69249. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  69250. /**
  69251. * Fired when the pad state has changed
  69252. */
  69253. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  69254. /**
  69255. * Fired when controllers stick values have changed
  69256. */
  69257. onPadValuesChangedObservable: Observable<StickValues>;
  69258. /**
  69259. * Array of button availible on the controller
  69260. */
  69261. protected _buttons: Array<MutableGamepadButton>;
  69262. private _onButtonStateChange;
  69263. /**
  69264. * Fired when a controller button's state has changed
  69265. * @param callback the callback containing the button that was modified
  69266. */
  69267. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  69268. /**
  69269. * X and Y axis corrisponding to the controllers joystick
  69270. */
  69271. pad: StickValues;
  69272. /**
  69273. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  69274. */
  69275. hand: string;
  69276. /**
  69277. * The default controller model for the controller
  69278. */
  69279. readonly defaultModel: AbstractMesh;
  69280. /**
  69281. * Creates a new WebVRController from a gamepad
  69282. * @param vrGamepad the gamepad that the WebVRController should be created from
  69283. */
  69284. constructor(vrGamepad: any);
  69285. /**
  69286. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  69287. */
  69288. update(): void;
  69289. /**
  69290. * Function to be called when a button is modified
  69291. */
  69292. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  69293. /**
  69294. * Loads a mesh and attaches it to the controller
  69295. * @param scene the scene the mesh should be added to
  69296. * @param meshLoaded callback for when the mesh has been loaded
  69297. */
  69298. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  69299. private _setButtonValue;
  69300. private _changes;
  69301. private _checkChanges;
  69302. /**
  69303. * Disposes of th webVRCOntroller
  69304. */
  69305. dispose(): void;
  69306. }
  69307. }
  69308. declare module BABYLON {
  69309. /**
  69310. * The HemisphericLight simulates the ambient environment light,
  69311. * so the passed direction is the light reflection direction, not the incoming direction.
  69312. */
  69313. export class HemisphericLight extends Light {
  69314. /**
  69315. * The groundColor is the light in the opposite direction to the one specified during creation.
  69316. * 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.
  69317. */
  69318. groundColor: Color3;
  69319. /**
  69320. * The light reflection direction, not the incoming direction.
  69321. */
  69322. direction: Vector3;
  69323. /**
  69324. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  69325. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  69326. * The HemisphericLight can't cast shadows.
  69327. * Documentation : https://doc.babylonjs.com/babylon101/lights
  69328. * @param name The friendly name of the light
  69329. * @param direction The direction of the light reflection
  69330. * @param scene The scene the light belongs to
  69331. */
  69332. constructor(name: string, direction: Vector3, scene: Scene);
  69333. protected _buildUniformLayout(): void;
  69334. /**
  69335. * Returns the string "HemisphericLight".
  69336. * @return The class name
  69337. */
  69338. getClassName(): string;
  69339. /**
  69340. * Sets the HemisphericLight direction towards the passed target (Vector3).
  69341. * Returns the updated direction.
  69342. * @param target The target the direction should point to
  69343. * @return The computed direction
  69344. */
  69345. setDirectionToTarget(target: Vector3): Vector3;
  69346. /**
  69347. * Returns the shadow generator associated to the light.
  69348. * @returns Always null for hemispheric lights because it does not support shadows.
  69349. */
  69350. getShadowGenerator(): Nullable<IShadowGenerator>;
  69351. /**
  69352. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  69353. * @param effect The effect to update
  69354. * @param lightIndex The index of the light in the effect to update
  69355. * @returns The hemispheric light
  69356. */
  69357. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  69358. /**
  69359. * Computes the world matrix of the node
  69360. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69361. * @param useWasUpdatedFlag defines a reserved property
  69362. * @returns the world matrix
  69363. */
  69364. computeWorldMatrix(): Matrix;
  69365. /**
  69366. * Returns the integer 3.
  69367. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  69368. */
  69369. getTypeID(): number;
  69370. /**
  69371. * Prepares the list of defines specific to the light type.
  69372. * @param defines the list of defines
  69373. * @param lightIndex defines the index of the light for the effect
  69374. */
  69375. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  69376. }
  69377. }
  69378. declare module BABYLON {
  69379. /**
  69380. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  69381. * IMPORTANT!! The data is right-hand data.
  69382. * @export
  69383. * @interface DevicePose
  69384. */
  69385. export interface DevicePose {
  69386. /**
  69387. * The position of the device, values in array are [x,y,z].
  69388. */
  69389. readonly position: Nullable<Float32Array>;
  69390. /**
  69391. * The linearVelocity of the device, values in array are [x,y,z].
  69392. */
  69393. readonly linearVelocity: Nullable<Float32Array>;
  69394. /**
  69395. * The linearAcceleration of the device, values in array are [x,y,z].
  69396. */
  69397. readonly linearAcceleration: Nullable<Float32Array>;
  69398. /**
  69399. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  69400. */
  69401. readonly orientation: Nullable<Float32Array>;
  69402. /**
  69403. * The angularVelocity of the device, values in array are [x,y,z].
  69404. */
  69405. readonly angularVelocity: Nullable<Float32Array>;
  69406. /**
  69407. * The angularAcceleration of the device, values in array are [x,y,z].
  69408. */
  69409. readonly angularAcceleration: Nullable<Float32Array>;
  69410. }
  69411. /**
  69412. * Interface representing a pose controlled object in Babylon.
  69413. * A pose controlled object has both regular pose values as well as pose values
  69414. * from an external device such as a VR head mounted display
  69415. */
  69416. export interface PoseControlled {
  69417. /**
  69418. * The position of the object in babylon space.
  69419. */
  69420. position: Vector3;
  69421. /**
  69422. * The rotation quaternion of the object in babylon space.
  69423. */
  69424. rotationQuaternion: Quaternion;
  69425. /**
  69426. * The position of the device in babylon space.
  69427. */
  69428. devicePosition?: Vector3;
  69429. /**
  69430. * The rotation quaternion of the device in babylon space.
  69431. */
  69432. deviceRotationQuaternion: Quaternion;
  69433. /**
  69434. * The raw pose coming from the device.
  69435. */
  69436. rawPose: Nullable<DevicePose>;
  69437. /**
  69438. * The scale of the device to be used when translating from device space to babylon space.
  69439. */
  69440. deviceScaleFactor: number;
  69441. /**
  69442. * Updates the poseControlled values based on the input device pose.
  69443. * @param poseData the pose data to update the object with
  69444. */
  69445. updateFromDevice(poseData: DevicePose): void;
  69446. }
  69447. /**
  69448. * Set of options to customize the webVRCamera
  69449. */
  69450. export interface WebVROptions {
  69451. /**
  69452. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  69453. */
  69454. trackPosition?: boolean;
  69455. /**
  69456. * Sets the scale of the vrDevice in babylon space. (default: 1)
  69457. */
  69458. positionScale?: number;
  69459. /**
  69460. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  69461. */
  69462. displayName?: string;
  69463. /**
  69464. * Should the native controller meshes be initialized. (default: true)
  69465. */
  69466. controllerMeshes?: boolean;
  69467. /**
  69468. * Creating a default HemiLight only on controllers. (default: true)
  69469. */
  69470. defaultLightingOnControllers?: boolean;
  69471. /**
  69472. * If you don't want to use the default VR button of the helper. (default: false)
  69473. */
  69474. useCustomVRButton?: boolean;
  69475. /**
  69476. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  69477. */
  69478. customVRButton?: HTMLButtonElement;
  69479. /**
  69480. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  69481. */
  69482. rayLength?: number;
  69483. /**
  69484. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  69485. */
  69486. defaultHeight?: number;
  69487. }
  69488. /**
  69489. * This represents a WebVR camera.
  69490. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  69491. * @example http://doc.babylonjs.com/how_to/webvr_camera
  69492. */
  69493. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  69494. private webVROptions;
  69495. /**
  69496. * @hidden
  69497. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  69498. */
  69499. _vrDevice: any;
  69500. /**
  69501. * The rawPose of the vrDevice.
  69502. */
  69503. rawPose: Nullable<DevicePose>;
  69504. private _onVREnabled;
  69505. private _specsVersion;
  69506. private _attached;
  69507. private _frameData;
  69508. protected _descendants: Array<Node>;
  69509. private _deviceRoomPosition;
  69510. /** @hidden */
  69511. _deviceRoomRotationQuaternion: Quaternion;
  69512. private _standingMatrix;
  69513. /**
  69514. * Represents device position in babylon space.
  69515. */
  69516. devicePosition: Vector3;
  69517. /**
  69518. * Represents device rotation in babylon space.
  69519. */
  69520. deviceRotationQuaternion: Quaternion;
  69521. /**
  69522. * The scale of the device to be used when translating from device space to babylon space.
  69523. */
  69524. deviceScaleFactor: number;
  69525. private _deviceToWorld;
  69526. private _worldToDevice;
  69527. /**
  69528. * References to the webVR controllers for the vrDevice.
  69529. */
  69530. controllers: Array<WebVRController>;
  69531. /**
  69532. * Emits an event when a controller is attached.
  69533. */
  69534. onControllersAttachedObservable: Observable<WebVRController[]>;
  69535. /**
  69536. * Emits an event when a controller's mesh has been loaded;
  69537. */
  69538. onControllerMeshLoadedObservable: Observable<WebVRController>;
  69539. /**
  69540. * Emits an event when the HMD's pose has been updated.
  69541. */
  69542. onPoseUpdatedFromDeviceObservable: Observable<any>;
  69543. private _poseSet;
  69544. /**
  69545. * If the rig cameras be used as parent instead of this camera.
  69546. */
  69547. rigParenting: boolean;
  69548. private _lightOnControllers;
  69549. private _defaultHeight?;
  69550. /**
  69551. * Instantiates a WebVRFreeCamera.
  69552. * @param name The name of the WebVRFreeCamera
  69553. * @param position The starting anchor position for the camera
  69554. * @param scene The scene the camera belongs to
  69555. * @param webVROptions a set of customizable options for the webVRCamera
  69556. */
  69557. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  69558. /**
  69559. * Gets the device distance from the ground in meters.
  69560. * @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.
  69561. */
  69562. deviceDistanceToRoomGround(): number;
  69563. /**
  69564. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  69565. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  69566. */
  69567. useStandingMatrix(callback?: (bool: boolean) => void): void;
  69568. /**
  69569. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  69570. * @returns A promise with a boolean set to if the standing matrix is supported.
  69571. */
  69572. useStandingMatrixAsync(): Promise<boolean>;
  69573. /**
  69574. * Disposes the camera
  69575. */
  69576. dispose(): void;
  69577. /**
  69578. * Gets a vrController by name.
  69579. * @param name The name of the controller to retreive
  69580. * @returns the controller matching the name specified or null if not found
  69581. */
  69582. getControllerByName(name: string): Nullable<WebVRController>;
  69583. private _leftController;
  69584. /**
  69585. * The controller corrisponding to the users left hand.
  69586. */
  69587. readonly leftController: Nullable<WebVRController>;
  69588. private _rightController;
  69589. /**
  69590. * The controller corrisponding to the users right hand.
  69591. */
  69592. readonly rightController: Nullable<WebVRController>;
  69593. /**
  69594. * Casts a ray forward from the vrCamera's gaze.
  69595. * @param length Length of the ray (default: 100)
  69596. * @returns the ray corrisponding to the gaze
  69597. */
  69598. getForwardRay(length?: number): Ray;
  69599. /**
  69600. * @hidden
  69601. * Updates the camera based on device's frame data
  69602. */
  69603. _checkInputs(): void;
  69604. /**
  69605. * Updates the poseControlled values based on the input device pose.
  69606. * @param poseData Pose coming from the device
  69607. */
  69608. updateFromDevice(poseData: DevicePose): void;
  69609. private _htmlElementAttached;
  69610. private _detachIfAttached;
  69611. /**
  69612. * WebVR's attach control will start broadcasting frames to the device.
  69613. * Note that in certain browsers (chrome for example) this function must be called
  69614. * within a user-interaction callback. Example:
  69615. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  69616. *
  69617. * @param element html element to attach the vrDevice to
  69618. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  69619. */
  69620. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69621. /**
  69622. * Detaches the camera from the html element and disables VR
  69623. *
  69624. * @param element html element to detach from
  69625. */
  69626. detachControl(element: HTMLElement): void;
  69627. /**
  69628. * @returns the name of this class
  69629. */
  69630. getClassName(): string;
  69631. /**
  69632. * Calls resetPose on the vrDisplay
  69633. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  69634. */
  69635. resetToCurrentRotation(): void;
  69636. /**
  69637. * @hidden
  69638. * Updates the rig cameras (left and right eye)
  69639. */
  69640. _updateRigCameras(): void;
  69641. private _workingVector;
  69642. private _oneVector;
  69643. private _workingMatrix;
  69644. private updateCacheCalled;
  69645. private _correctPositionIfNotTrackPosition;
  69646. /**
  69647. * @hidden
  69648. * Updates the cached values of the camera
  69649. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  69650. */
  69651. _updateCache(ignoreParentClass?: boolean): void;
  69652. /**
  69653. * @hidden
  69654. * Get current device position in babylon world
  69655. */
  69656. _computeDevicePosition(): void;
  69657. /**
  69658. * Updates the current device position and rotation in the babylon world
  69659. */
  69660. update(): void;
  69661. /**
  69662. * @hidden
  69663. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  69664. * @returns an identity matrix
  69665. */
  69666. _getViewMatrix(): Matrix;
  69667. private _tmpMatrix;
  69668. /**
  69669. * This function is called by the two RIG cameras.
  69670. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  69671. * @hidden
  69672. */
  69673. _getWebVRViewMatrix(): Matrix;
  69674. /** @hidden */
  69675. _getWebVRProjectionMatrix(): Matrix;
  69676. private _onGamepadConnectedObserver;
  69677. private _onGamepadDisconnectedObserver;
  69678. private _updateCacheWhenTrackingDisabledObserver;
  69679. /**
  69680. * Initializes the controllers and their meshes
  69681. */
  69682. initControllers(): void;
  69683. }
  69684. }
  69685. declare module BABYLON {
  69686. /**
  69687. * Size options for a post process
  69688. */
  69689. export type PostProcessOptions = {
  69690. width: number;
  69691. height: number;
  69692. };
  69693. /**
  69694. * PostProcess can be used to apply a shader to a texture after it has been rendered
  69695. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69696. */
  69697. export class PostProcess {
  69698. /** Name of the PostProcess. */
  69699. name: string;
  69700. /**
  69701. * Width of the texture to apply the post process on
  69702. */
  69703. width: number;
  69704. /**
  69705. * Height of the texture to apply the post process on
  69706. */
  69707. height: number;
  69708. /**
  69709. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  69710. * @hidden
  69711. */
  69712. _outputTexture: Nullable<InternalTexture>;
  69713. /**
  69714. * Sampling mode used by the shader
  69715. * See https://doc.babylonjs.com/classes/3.1/texture
  69716. */
  69717. renderTargetSamplingMode: number;
  69718. /**
  69719. * Clear color to use when screen clearing
  69720. */
  69721. clearColor: Color4;
  69722. /**
  69723. * If the buffer needs to be cleared before applying the post process. (default: true)
  69724. * Should be set to false if shader will overwrite all previous pixels.
  69725. */
  69726. autoClear: boolean;
  69727. /**
  69728. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  69729. */
  69730. alphaMode: number;
  69731. /**
  69732. * Sets the setAlphaBlendConstants of the babylon engine
  69733. */
  69734. alphaConstants: Color4;
  69735. /**
  69736. * Animations to be used for the post processing
  69737. */
  69738. animations: Animation[];
  69739. /**
  69740. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  69741. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  69742. */
  69743. enablePixelPerfectMode: boolean;
  69744. /**
  69745. * Force the postprocess to be applied without taking in account viewport
  69746. */
  69747. forceFullscreenViewport: boolean;
  69748. /**
  69749. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  69750. *
  69751. * | Value | Type | Description |
  69752. * | ----- | ----------------------------------- | ----------- |
  69753. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  69754. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  69755. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  69756. *
  69757. */
  69758. scaleMode: number;
  69759. /**
  69760. * Force textures to be a power of two (default: false)
  69761. */
  69762. alwaysForcePOT: boolean;
  69763. private _samples;
  69764. /**
  69765. * Number of sample textures (default: 1)
  69766. */
  69767. samples: number;
  69768. /**
  69769. * Modify the scale of the post process to be the same as the viewport (default: false)
  69770. */
  69771. adaptScaleToCurrentViewport: boolean;
  69772. private _camera;
  69773. private _scene;
  69774. private _engine;
  69775. private _options;
  69776. private _reusable;
  69777. private _textureType;
  69778. /**
  69779. * Smart array of input and output textures for the post process.
  69780. * @hidden
  69781. */
  69782. _textures: SmartArray<InternalTexture>;
  69783. /**
  69784. * The index in _textures that corresponds to the output texture.
  69785. * @hidden
  69786. */
  69787. _currentRenderTextureInd: number;
  69788. private _effect;
  69789. private _samplers;
  69790. private _fragmentUrl;
  69791. private _vertexUrl;
  69792. private _parameters;
  69793. private _scaleRatio;
  69794. protected _indexParameters: any;
  69795. private _shareOutputWithPostProcess;
  69796. private _texelSize;
  69797. private _forcedOutputTexture;
  69798. /**
  69799. * Returns the fragment url or shader name used in the post process.
  69800. * @returns the fragment url or name in the shader store.
  69801. */
  69802. getEffectName(): string;
  69803. /**
  69804. * An event triggered when the postprocess is activated.
  69805. */
  69806. onActivateObservable: Observable<Camera>;
  69807. private _onActivateObserver;
  69808. /**
  69809. * A function that is added to the onActivateObservable
  69810. */
  69811. onActivate: Nullable<(camera: Camera) => void>;
  69812. /**
  69813. * An event triggered when the postprocess changes its size.
  69814. */
  69815. onSizeChangedObservable: Observable<PostProcess>;
  69816. private _onSizeChangedObserver;
  69817. /**
  69818. * A function that is added to the onSizeChangedObservable
  69819. */
  69820. onSizeChanged: (postProcess: PostProcess) => void;
  69821. /**
  69822. * An event triggered when the postprocess applies its effect.
  69823. */
  69824. onApplyObservable: Observable<Effect>;
  69825. private _onApplyObserver;
  69826. /**
  69827. * A function that is added to the onApplyObservable
  69828. */
  69829. onApply: (effect: Effect) => void;
  69830. /**
  69831. * An event triggered before rendering the postprocess
  69832. */
  69833. onBeforeRenderObservable: Observable<Effect>;
  69834. private _onBeforeRenderObserver;
  69835. /**
  69836. * A function that is added to the onBeforeRenderObservable
  69837. */
  69838. onBeforeRender: (effect: Effect) => void;
  69839. /**
  69840. * An event triggered after rendering the postprocess
  69841. */
  69842. onAfterRenderObservable: Observable<Effect>;
  69843. private _onAfterRenderObserver;
  69844. /**
  69845. * A function that is added to the onAfterRenderObservable
  69846. */
  69847. onAfterRender: (efect: Effect) => void;
  69848. /**
  69849. * 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
  69850. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  69851. */
  69852. inputTexture: InternalTexture;
  69853. /**
  69854. * Gets the camera which post process is applied to.
  69855. * @returns The camera the post process is applied to.
  69856. */
  69857. getCamera(): Camera;
  69858. /**
  69859. * Gets the texel size of the postprocess.
  69860. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  69861. */
  69862. readonly texelSize: Vector2;
  69863. /**
  69864. * Creates a new instance PostProcess
  69865. * @param name The name of the PostProcess.
  69866. * @param fragmentUrl The url of the fragment shader to be used.
  69867. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  69868. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  69869. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  69870. * @param camera The camera to apply the render pass to.
  69871. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69872. * @param engine The engine which the post process will be applied. (default: current engine)
  69873. * @param reusable If the post process can be reused on the same frame. (default: false)
  69874. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  69875. * @param textureType Type of textures used when performing the post process. (default: 0)
  69876. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  69877. * @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
  69878. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  69879. */
  69880. constructor(
  69881. /** Name of the PostProcess. */
  69882. 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);
  69883. /**
  69884. * Gets the engine which this post process belongs to.
  69885. * @returns The engine the post process was enabled with.
  69886. */
  69887. getEngine(): Engine;
  69888. /**
  69889. * The effect that is created when initializing the post process.
  69890. * @returns The created effect corrisponding the the postprocess.
  69891. */
  69892. getEffect(): Effect;
  69893. /**
  69894. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  69895. * @param postProcess The post process to share the output with.
  69896. * @returns This post process.
  69897. */
  69898. shareOutputWith(postProcess: PostProcess): PostProcess;
  69899. /**
  69900. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  69901. * This should be called if the post process that shares output with this post process is disabled/disposed.
  69902. */
  69903. useOwnOutput(): void;
  69904. /**
  69905. * Updates the effect with the current post process compile time values and recompiles the shader.
  69906. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69907. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69908. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69909. * @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
  69910. * @param onCompiled Called when the shader has been compiled.
  69911. * @param onError Called if there is an error when compiling a shader.
  69912. */
  69913. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69914. /**
  69915. * The post process is reusable if it can be used multiple times within one frame.
  69916. * @returns If the post process is reusable
  69917. */
  69918. isReusable(): boolean;
  69919. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  69920. markTextureDirty(): void;
  69921. /**
  69922. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  69923. * 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.
  69924. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  69925. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  69926. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  69927. * @returns The target texture that was bound to be written to.
  69928. */
  69929. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  69930. /**
  69931. * If the post process is supported.
  69932. */
  69933. readonly isSupported: boolean;
  69934. /**
  69935. * The aspect ratio of the output texture.
  69936. */
  69937. readonly aspectRatio: number;
  69938. /**
  69939. * Get a value indicating if the post-process is ready to be used
  69940. * @returns true if the post-process is ready (shader is compiled)
  69941. */
  69942. isReady(): boolean;
  69943. /**
  69944. * Binds all textures and uniforms to the shader, this will be run on every pass.
  69945. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  69946. */
  69947. apply(): Nullable<Effect>;
  69948. private _disposeTextures;
  69949. /**
  69950. * Disposes the post process.
  69951. * @param camera The camera to dispose the post process on.
  69952. */
  69953. dispose(camera?: Camera): void;
  69954. }
  69955. }
  69956. declare module BABYLON {
  69957. /**
  69958. * PostProcessManager is used to manage one or more post processes or post process pipelines
  69959. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69960. */
  69961. export class PostProcessManager {
  69962. private _scene;
  69963. private _indexBuffer;
  69964. private _vertexBuffers;
  69965. /**
  69966. * Creates a new instance PostProcess
  69967. * @param scene The scene that the post process is associated with.
  69968. */
  69969. constructor(scene: Scene);
  69970. private _prepareBuffers;
  69971. private _buildIndexBuffer;
  69972. /**
  69973. * Rebuilds the vertex buffers of the manager.
  69974. * @hidden
  69975. */
  69976. _rebuild(): void;
  69977. /**
  69978. * Prepares a frame to be run through a post process.
  69979. * @param sourceTexture The input texture to the post procesess. (default: null)
  69980. * @param postProcesses An array of post processes to be run. (default: null)
  69981. * @returns True if the post processes were able to be run.
  69982. * @hidden
  69983. */
  69984. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  69985. /**
  69986. * Manually render a set of post processes to a texture.
  69987. * @param postProcesses An array of post processes to be run.
  69988. * @param targetTexture The target texture to render to.
  69989. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  69990. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  69991. * @param lodLevel defines which lod of the texture to render to
  69992. */
  69993. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  69994. /**
  69995. * Finalize the result of the output of the postprocesses.
  69996. * @param doNotPresent If true the result will not be displayed to the screen.
  69997. * @param targetTexture The target texture to render to.
  69998. * @param faceIndex The index of the face to bind the target texture to.
  69999. * @param postProcesses The array of post processes to render.
  70000. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  70001. * @hidden
  70002. */
  70003. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  70004. /**
  70005. * Disposes of the post process manager.
  70006. */
  70007. dispose(): void;
  70008. }
  70009. }
  70010. declare module BABYLON {
  70011. /**
  70012. * Raw texture can help creating a texture directly from an array of data.
  70013. * This can be super useful if you either get the data from an uncompressed source or
  70014. * if you wish to create your texture pixel by pixel.
  70015. */
  70016. export class RawTexture extends Texture {
  70017. /**
  70018. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  70019. */
  70020. format: number;
  70021. private _engine;
  70022. /**
  70023. * Instantiates a new RawTexture.
  70024. * Raw texture can help creating a texture directly from an array of data.
  70025. * This can be super useful if you either get the data from an uncompressed source or
  70026. * if you wish to create your texture pixel by pixel.
  70027. * @param data define the array of data to use to create the texture
  70028. * @param width define the width of the texture
  70029. * @param height define the height of the texture
  70030. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  70031. * @param scene define the scene the texture belongs to
  70032. * @param generateMipMaps define whether mip maps should be generated or not
  70033. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70034. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70035. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  70036. */
  70037. constructor(data: ArrayBufferView, width: number, height: number,
  70038. /**
  70039. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  70040. */
  70041. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  70042. /**
  70043. * Updates the texture underlying data.
  70044. * @param data Define the new data of the texture
  70045. */
  70046. update(data: ArrayBufferView): void;
  70047. /**
  70048. * Creates a luminance texture from some data.
  70049. * @param data Define the texture data
  70050. * @param width Define the width of the texture
  70051. * @param height Define the height of the texture
  70052. * @param scene Define the scene the texture belongs to
  70053. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70054. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70055. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70056. * @returns the luminance texture
  70057. */
  70058. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  70059. /**
  70060. * Creates a luminance alpha texture from some data.
  70061. * @param data Define the texture data
  70062. * @param width Define the width of the texture
  70063. * @param height Define the height of the texture
  70064. * @param scene Define the scene the texture belongs to
  70065. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70066. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70067. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70068. * @returns the luminance alpha texture
  70069. */
  70070. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  70071. /**
  70072. * Creates an alpha texture from some data.
  70073. * @param data Define the texture data
  70074. * @param width Define the width of the texture
  70075. * @param height Define the height of the texture
  70076. * @param scene Define the scene the texture belongs to
  70077. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70078. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70079. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70080. * @returns the alpha texture
  70081. */
  70082. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  70083. /**
  70084. * Creates a RGB texture from some data.
  70085. * @param data Define the texture data
  70086. * @param width Define the width of the texture
  70087. * @param height Define the height of the texture
  70088. * @param scene Define the scene the texture belongs to
  70089. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70090. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70091. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70092. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  70093. * @returns the RGB alpha texture
  70094. */
  70095. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  70096. /**
  70097. * Creates a RGBA texture from some data.
  70098. * @param data Define the texture data
  70099. * @param width Define the width of the texture
  70100. * @param height Define the height of the texture
  70101. * @param scene Define the scene the texture belongs to
  70102. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70103. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70104. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70105. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  70106. * @returns the RGBA texture
  70107. */
  70108. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  70109. /**
  70110. * Creates a R texture from some data.
  70111. * @param data Define the texture data
  70112. * @param width Define the width of the texture
  70113. * @param height Define the height of the texture
  70114. * @param scene Define the scene the texture belongs to
  70115. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70116. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70117. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70118. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  70119. * @returns the R texture
  70120. */
  70121. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  70122. }
  70123. }
  70124. declare module BABYLON {
  70125. interface AbstractScene {
  70126. /**
  70127. * The list of layers (background and foreground) of the scene
  70128. */
  70129. layers: Array<Layer>;
  70130. }
  70131. /**
  70132. * Defines the layer scene component responsible to manage any layers
  70133. * in a given scene.
  70134. */
  70135. export class LayerSceneComponent implements ISceneComponent {
  70136. /**
  70137. * The component name helpfull to identify the component in the list of scene components.
  70138. */
  70139. readonly name: string;
  70140. /**
  70141. * The scene the component belongs to.
  70142. */
  70143. scene: Scene;
  70144. private _engine;
  70145. /**
  70146. * Creates a new instance of the component for the given scene
  70147. * @param scene Defines the scene to register the component in
  70148. */
  70149. constructor(scene: Scene);
  70150. /**
  70151. * Registers the component in a given scene
  70152. */
  70153. register(): void;
  70154. /**
  70155. * Rebuilds the elements related to this component in case of
  70156. * context lost for instance.
  70157. */
  70158. rebuild(): void;
  70159. /**
  70160. * Disposes the component and the associated ressources.
  70161. */
  70162. dispose(): void;
  70163. private _draw;
  70164. private _drawCameraPredicate;
  70165. private _drawCameraBackground;
  70166. private _drawCameraForeground;
  70167. private _drawRenderTargetPredicate;
  70168. private _drawRenderTargetBackground;
  70169. private _drawRenderTargetForeground;
  70170. }
  70171. }
  70172. declare module BABYLON {
  70173. /** @hidden */
  70174. export var layerPixelShader: {
  70175. name: string;
  70176. shader: string;
  70177. };
  70178. }
  70179. declare module BABYLON {
  70180. /** @hidden */
  70181. export var layerVertexShader: {
  70182. name: string;
  70183. shader: string;
  70184. };
  70185. }
  70186. declare module BABYLON {
  70187. /**
  70188. * This represents a full screen 2d layer.
  70189. * This can be useful to display a picture in the background of your scene for instance.
  70190. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70191. */
  70192. export class Layer {
  70193. /**
  70194. * Define the name of the layer.
  70195. */
  70196. name: string;
  70197. /**
  70198. * Define the texture the layer should display.
  70199. */
  70200. texture: Nullable<Texture>;
  70201. /**
  70202. * Is the layer in background or foreground.
  70203. */
  70204. isBackground: boolean;
  70205. /**
  70206. * Define the color of the layer (instead of texture).
  70207. */
  70208. color: Color4;
  70209. /**
  70210. * Define the scale of the layer in order to zoom in out of the texture.
  70211. */
  70212. scale: Vector2;
  70213. /**
  70214. * Define an offset for the layer in order to shift the texture.
  70215. */
  70216. offset: Vector2;
  70217. /**
  70218. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  70219. */
  70220. alphaBlendingMode: number;
  70221. /**
  70222. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  70223. * Alpha test will not mix with the background color in case of transparency.
  70224. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  70225. */
  70226. alphaTest: boolean;
  70227. /**
  70228. * Define a mask to restrict the layer to only some of the scene cameras.
  70229. */
  70230. layerMask: number;
  70231. /**
  70232. * Define the list of render target the layer is visible into.
  70233. */
  70234. renderTargetTextures: RenderTargetTexture[];
  70235. /**
  70236. * Define if the layer is only used in renderTarget or if it also
  70237. * renders in the main frame buffer of the canvas.
  70238. */
  70239. renderOnlyInRenderTargetTextures: boolean;
  70240. private _scene;
  70241. private _vertexBuffers;
  70242. private _indexBuffer;
  70243. private _effect;
  70244. private _alphaTestEffect;
  70245. /**
  70246. * An event triggered when the layer is disposed.
  70247. */
  70248. onDisposeObservable: Observable<Layer>;
  70249. private _onDisposeObserver;
  70250. /**
  70251. * Back compatibility with callback before the onDisposeObservable existed.
  70252. * The set callback will be triggered when the layer has been disposed.
  70253. */
  70254. onDispose: () => void;
  70255. /**
  70256. * An event triggered before rendering the scene
  70257. */
  70258. onBeforeRenderObservable: Observable<Layer>;
  70259. private _onBeforeRenderObserver;
  70260. /**
  70261. * Back compatibility with callback before the onBeforeRenderObservable existed.
  70262. * The set callback will be triggered just before rendering the layer.
  70263. */
  70264. onBeforeRender: () => void;
  70265. /**
  70266. * An event triggered after rendering the scene
  70267. */
  70268. onAfterRenderObservable: Observable<Layer>;
  70269. private _onAfterRenderObserver;
  70270. /**
  70271. * Back compatibility with callback before the onAfterRenderObservable existed.
  70272. * The set callback will be triggered just after rendering the layer.
  70273. */
  70274. onAfterRender: () => void;
  70275. /**
  70276. * Instantiates a new layer.
  70277. * This represents a full screen 2d layer.
  70278. * This can be useful to display a picture in the background of your scene for instance.
  70279. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70280. * @param name Define the name of the layer in the scene
  70281. * @param imgUrl Define the url of the texture to display in the layer
  70282. * @param scene Define the scene the layer belongs to
  70283. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  70284. * @param color Defines a color for the layer
  70285. */
  70286. constructor(
  70287. /**
  70288. * Define the name of the layer.
  70289. */
  70290. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  70291. private _createIndexBuffer;
  70292. /** @hidden */
  70293. _rebuild(): void;
  70294. /**
  70295. * Renders the layer in the scene.
  70296. */
  70297. render(): void;
  70298. /**
  70299. * Disposes and releases the associated ressources.
  70300. */
  70301. dispose(): void;
  70302. }
  70303. }
  70304. declare module BABYLON {
  70305. interface AbstractScene {
  70306. /**
  70307. * The list of procedural textures added to the scene
  70308. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70309. */
  70310. proceduralTextures: Array<ProceduralTexture>;
  70311. }
  70312. /**
  70313. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  70314. * in a given scene.
  70315. */
  70316. export class ProceduralTextureSceneComponent implements ISceneComponent {
  70317. /**
  70318. * The component name helpfull to identify the component in the list of scene components.
  70319. */
  70320. readonly name: string;
  70321. /**
  70322. * The scene the component belongs to.
  70323. */
  70324. scene: Scene;
  70325. /**
  70326. * Creates a new instance of the component for the given scene
  70327. * @param scene Defines the scene to register the component in
  70328. */
  70329. constructor(scene: Scene);
  70330. /**
  70331. * Registers the component in a given scene
  70332. */
  70333. register(): void;
  70334. /**
  70335. * Rebuilds the elements related to this component in case of
  70336. * context lost for instance.
  70337. */
  70338. rebuild(): void;
  70339. /**
  70340. * Disposes the component and the associated ressources.
  70341. */
  70342. dispose(): void;
  70343. private _beforeClear;
  70344. }
  70345. }
  70346. declare module BABYLON {
  70347. /** @hidden */
  70348. export var proceduralVertexShader: {
  70349. name: string;
  70350. shader: string;
  70351. };
  70352. }
  70353. declare module BABYLON {
  70354. /**
  70355. * 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.
  70356. * This is the base class of any Procedural texture and contains most of the shareable code.
  70357. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70358. */
  70359. export class ProceduralTexture extends Texture {
  70360. isCube: boolean;
  70361. /**
  70362. * Define if the texture is enabled or not (disabled texture will not render)
  70363. */
  70364. isEnabled: boolean;
  70365. /**
  70366. * Define if the texture must be cleared before rendering (default is true)
  70367. */
  70368. autoClear: boolean;
  70369. /**
  70370. * Callback called when the texture is generated
  70371. */
  70372. onGenerated: () => void;
  70373. /**
  70374. * Event raised when the texture is generated
  70375. */
  70376. onGeneratedObservable: Observable<ProceduralTexture>;
  70377. /** @hidden */
  70378. _generateMipMaps: boolean;
  70379. /** @hidden **/
  70380. _effect: Effect;
  70381. /** @hidden */
  70382. _textures: {
  70383. [key: string]: Texture;
  70384. };
  70385. private _size;
  70386. private _currentRefreshId;
  70387. private _refreshRate;
  70388. private _vertexBuffers;
  70389. private _indexBuffer;
  70390. private _uniforms;
  70391. private _samplers;
  70392. private _fragment;
  70393. private _floats;
  70394. private _ints;
  70395. private _floatsArrays;
  70396. private _colors3;
  70397. private _colors4;
  70398. private _vectors2;
  70399. private _vectors3;
  70400. private _matrices;
  70401. private _fallbackTexture;
  70402. private _fallbackTextureUsed;
  70403. private _engine;
  70404. private _cachedDefines;
  70405. private _contentUpdateId;
  70406. private _contentData;
  70407. /**
  70408. * Instantiates a new procedural texture.
  70409. * 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.
  70410. * This is the base class of any Procedural texture and contains most of the shareable code.
  70411. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70412. * @param name Define the name of the texture
  70413. * @param size Define the size of the texture to create
  70414. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  70415. * @param scene Define the scene the texture belongs to
  70416. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  70417. * @param generateMipMaps Define if the texture should creates mip maps or not
  70418. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  70419. */
  70420. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  70421. /**
  70422. * The effect that is created when initializing the post process.
  70423. * @returns The created effect corrisponding the the postprocess.
  70424. */
  70425. getEffect(): Effect;
  70426. /**
  70427. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  70428. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  70429. */
  70430. getContent(): Nullable<ArrayBufferView>;
  70431. private _createIndexBuffer;
  70432. /** @hidden */
  70433. _rebuild(): void;
  70434. /**
  70435. * Resets the texture in order to recreate its associated resources.
  70436. * This can be called in case of context loss
  70437. */
  70438. reset(): void;
  70439. protected _getDefines(): string;
  70440. /**
  70441. * Is the texture ready to be used ? (rendered at least once)
  70442. * @returns true if ready, otherwise, false.
  70443. */
  70444. isReady(): boolean;
  70445. /**
  70446. * Resets the refresh counter of the texture and start bak from scratch.
  70447. * Could be useful to regenerate the texture if it is setup to render only once.
  70448. */
  70449. resetRefreshCounter(): void;
  70450. /**
  70451. * Set the fragment shader to use in order to render the texture.
  70452. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  70453. */
  70454. setFragment(fragment: any): void;
  70455. /**
  70456. * Define the refresh rate of the texture or the rendering frequency.
  70457. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  70458. */
  70459. refreshRate: number;
  70460. /** @hidden */
  70461. _shouldRender(): boolean;
  70462. /**
  70463. * Get the size the texture is rendering at.
  70464. * @returns the size (texture is always squared)
  70465. */
  70466. getRenderSize(): number;
  70467. /**
  70468. * Resize the texture to new value.
  70469. * @param size Define the new size the texture should have
  70470. * @param generateMipMaps Define whether the new texture should create mip maps
  70471. */
  70472. resize(size: number, generateMipMaps: boolean): void;
  70473. private _checkUniform;
  70474. /**
  70475. * Set a texture in the shader program used to render.
  70476. * @param name Define the name of the uniform samplers as defined in the shader
  70477. * @param texture Define the texture to bind to this sampler
  70478. * @return the texture itself allowing "fluent" like uniform updates
  70479. */
  70480. setTexture(name: string, texture: Texture): ProceduralTexture;
  70481. /**
  70482. * Set a float in the shader.
  70483. * @param name Define the name of the uniform as defined in the shader
  70484. * @param value Define the value to give to the uniform
  70485. * @return the texture itself allowing "fluent" like uniform updates
  70486. */
  70487. setFloat(name: string, value: number): ProceduralTexture;
  70488. /**
  70489. * Set a int in the shader.
  70490. * @param name Define the name of the uniform as defined in the shader
  70491. * @param value Define the value to give to the uniform
  70492. * @return the texture itself allowing "fluent" like uniform updates
  70493. */
  70494. setInt(name: string, value: number): ProceduralTexture;
  70495. /**
  70496. * Set an array of floats in the shader.
  70497. * @param name Define the name of the uniform as defined in the shader
  70498. * @param value Define the value to give to the uniform
  70499. * @return the texture itself allowing "fluent" like uniform updates
  70500. */
  70501. setFloats(name: string, value: number[]): ProceduralTexture;
  70502. /**
  70503. * Set a vec3 in the shader from a Color3.
  70504. * @param name Define the name of the uniform as defined in the shader
  70505. * @param value Define the value to give to the uniform
  70506. * @return the texture itself allowing "fluent" like uniform updates
  70507. */
  70508. setColor3(name: string, value: Color3): ProceduralTexture;
  70509. /**
  70510. * Set a vec4 in the shader from a Color4.
  70511. * @param name Define the name of the uniform as defined in the shader
  70512. * @param value Define the value to give to the uniform
  70513. * @return the texture itself allowing "fluent" like uniform updates
  70514. */
  70515. setColor4(name: string, value: Color4): ProceduralTexture;
  70516. /**
  70517. * Set a vec2 in the shader from a Vector2.
  70518. * @param name Define the name of the uniform as defined in the shader
  70519. * @param value Define the value to give to the uniform
  70520. * @return the texture itself allowing "fluent" like uniform updates
  70521. */
  70522. setVector2(name: string, value: Vector2): ProceduralTexture;
  70523. /**
  70524. * Set a vec3 in the shader from a Vector3.
  70525. * @param name Define the name of the uniform as defined in the shader
  70526. * @param value Define the value to give to the uniform
  70527. * @return the texture itself allowing "fluent" like uniform updates
  70528. */
  70529. setVector3(name: string, value: Vector3): ProceduralTexture;
  70530. /**
  70531. * Set a mat4 in the shader from a MAtrix.
  70532. * @param name Define the name of the uniform as defined in the shader
  70533. * @param value Define the value to give to the uniform
  70534. * @return the texture itself allowing "fluent" like uniform updates
  70535. */
  70536. setMatrix(name: string, value: Matrix): ProceduralTexture;
  70537. /**
  70538. * Render the texture to its associated render target.
  70539. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  70540. */
  70541. render(useCameraPostProcess?: boolean): void;
  70542. /**
  70543. * Clone the texture.
  70544. * @returns the cloned texture
  70545. */
  70546. clone(): ProceduralTexture;
  70547. /**
  70548. * Dispose the texture and release its asoociated resources.
  70549. */
  70550. dispose(): void;
  70551. }
  70552. }
  70553. declare module BABYLON {
  70554. /**
  70555. * This represents the base class for particle system in Babylon.
  70556. * 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.
  70557. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  70558. * @example https://doc.babylonjs.com/babylon101/particles
  70559. */
  70560. export class BaseParticleSystem {
  70561. /**
  70562. * Source color is added to the destination color without alpha affecting the result
  70563. */
  70564. static BLENDMODE_ONEONE: number;
  70565. /**
  70566. * Blend current color and particle color using particle’s alpha
  70567. */
  70568. static BLENDMODE_STANDARD: number;
  70569. /**
  70570. * Add current color and particle color multiplied by particle’s alpha
  70571. */
  70572. static BLENDMODE_ADD: number;
  70573. /**
  70574. * Multiply current color with particle color
  70575. */
  70576. static BLENDMODE_MULTIPLY: number;
  70577. /**
  70578. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  70579. */
  70580. static BLENDMODE_MULTIPLYADD: number;
  70581. /**
  70582. * List of animations used by the particle system.
  70583. */
  70584. animations: Animation[];
  70585. /**
  70586. * The id of the Particle system.
  70587. */
  70588. id: string;
  70589. /**
  70590. * The friendly name of the Particle system.
  70591. */
  70592. name: string;
  70593. /**
  70594. * The rendering group used by the Particle system to chose when to render.
  70595. */
  70596. renderingGroupId: number;
  70597. /**
  70598. * The emitter represents the Mesh or position we are attaching the particle system to.
  70599. */
  70600. emitter: Nullable<AbstractMesh | Vector3>;
  70601. /**
  70602. * The maximum number of particles to emit per frame
  70603. */
  70604. emitRate: number;
  70605. /**
  70606. * If you want to launch only a few particles at once, that can be done, as well.
  70607. */
  70608. manualEmitCount: number;
  70609. /**
  70610. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  70611. */
  70612. updateSpeed: number;
  70613. /**
  70614. * The amount of time the particle system is running (depends of the overall update speed).
  70615. */
  70616. targetStopDuration: number;
  70617. /**
  70618. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  70619. */
  70620. disposeOnStop: boolean;
  70621. /**
  70622. * Minimum power of emitting particles.
  70623. */
  70624. minEmitPower: number;
  70625. /**
  70626. * Maximum power of emitting particles.
  70627. */
  70628. maxEmitPower: number;
  70629. /**
  70630. * Minimum life time of emitting particles.
  70631. */
  70632. minLifeTime: number;
  70633. /**
  70634. * Maximum life time of emitting particles.
  70635. */
  70636. maxLifeTime: number;
  70637. /**
  70638. * Minimum Size of emitting particles.
  70639. */
  70640. minSize: number;
  70641. /**
  70642. * Maximum Size of emitting particles.
  70643. */
  70644. maxSize: number;
  70645. /**
  70646. * Minimum scale of emitting particles on X axis.
  70647. */
  70648. minScaleX: number;
  70649. /**
  70650. * Maximum scale of emitting particles on X axis.
  70651. */
  70652. maxScaleX: number;
  70653. /**
  70654. * Minimum scale of emitting particles on Y axis.
  70655. */
  70656. minScaleY: number;
  70657. /**
  70658. * Maximum scale of emitting particles on Y axis.
  70659. */
  70660. maxScaleY: number;
  70661. /**
  70662. * Gets or sets the minimal initial rotation in radians.
  70663. */
  70664. minInitialRotation: number;
  70665. /**
  70666. * Gets or sets the maximal initial rotation in radians.
  70667. */
  70668. maxInitialRotation: number;
  70669. /**
  70670. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  70671. */
  70672. minAngularSpeed: number;
  70673. /**
  70674. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  70675. */
  70676. maxAngularSpeed: number;
  70677. /**
  70678. * The texture used to render each particle. (this can be a spritesheet)
  70679. */
  70680. particleTexture: Nullable<Texture>;
  70681. /**
  70682. * The layer mask we are rendering the particles through.
  70683. */
  70684. layerMask: number;
  70685. /**
  70686. * This can help using your own shader to render the particle system.
  70687. * The according effect will be created
  70688. */
  70689. customShader: any;
  70690. /**
  70691. * By default particle system starts as soon as they are created. This prevents the
  70692. * automatic start to happen and let you decide when to start emitting particles.
  70693. */
  70694. preventAutoStart: boolean;
  70695. private _noiseTexture;
  70696. /**
  70697. * Gets or sets a texture used to add random noise to particle positions
  70698. */
  70699. noiseTexture: Nullable<ProceduralTexture>;
  70700. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  70701. noiseStrength: Vector3;
  70702. /**
  70703. * Callback triggered when the particle animation is ending.
  70704. */
  70705. onAnimationEnd: Nullable<() => void>;
  70706. /**
  70707. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  70708. */
  70709. blendMode: number;
  70710. /**
  70711. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  70712. * to override the particles.
  70713. */
  70714. forceDepthWrite: boolean;
  70715. /** 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 */
  70716. preWarmCycles: number;
  70717. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  70718. preWarmStepOffset: number;
  70719. /**
  70720. * 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)
  70721. */
  70722. spriteCellChangeSpeed: number;
  70723. /**
  70724. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  70725. */
  70726. startSpriteCellID: number;
  70727. /**
  70728. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  70729. */
  70730. endSpriteCellID: number;
  70731. /**
  70732. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  70733. */
  70734. spriteCellWidth: number;
  70735. /**
  70736. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  70737. */
  70738. spriteCellHeight: number;
  70739. /**
  70740. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  70741. */
  70742. spriteRandomStartCell: boolean;
  70743. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  70744. translationPivot: Vector2;
  70745. /** @hidden */
  70746. protected _isAnimationSheetEnabled: boolean;
  70747. /**
  70748. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  70749. */
  70750. beginAnimationOnStart: boolean;
  70751. /**
  70752. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  70753. */
  70754. beginAnimationFrom: number;
  70755. /**
  70756. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  70757. */
  70758. beginAnimationTo: number;
  70759. /**
  70760. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  70761. */
  70762. beginAnimationLoop: boolean;
  70763. /**
  70764. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  70765. */
  70766. isAnimationSheetEnabled: boolean;
  70767. /**
  70768. * Get hosting scene
  70769. * @returns the scene
  70770. */
  70771. getScene(): Scene;
  70772. /**
  70773. * You can use gravity if you want to give an orientation to your particles.
  70774. */
  70775. gravity: Vector3;
  70776. protected _colorGradients: Nullable<Array<ColorGradient>>;
  70777. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  70778. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  70779. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  70780. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  70781. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  70782. protected _dragGradients: Nullable<Array<FactorGradient>>;
  70783. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  70784. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  70785. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  70786. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  70787. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  70788. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  70789. /**
  70790. * Defines the delay in milliseconds before starting the system (0 by default)
  70791. */
  70792. startDelay: number;
  70793. /**
  70794. * Gets the current list of drag gradients.
  70795. * You must use addDragGradient and removeDragGradient to udpate this list
  70796. * @returns the list of drag gradients
  70797. */
  70798. getDragGradients(): Nullable<Array<FactorGradient>>;
  70799. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  70800. limitVelocityDamping: number;
  70801. /**
  70802. * Gets the current list of limit velocity gradients.
  70803. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  70804. * @returns the list of limit velocity gradients
  70805. */
  70806. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  70807. /**
  70808. * Gets the current list of color gradients.
  70809. * You must use addColorGradient and removeColorGradient to udpate this list
  70810. * @returns the list of color gradients
  70811. */
  70812. getColorGradients(): Nullable<Array<ColorGradient>>;
  70813. /**
  70814. * Gets the current list of size gradients.
  70815. * You must use addSizeGradient and removeSizeGradient to udpate this list
  70816. * @returns the list of size gradients
  70817. */
  70818. getSizeGradients(): Nullable<Array<FactorGradient>>;
  70819. /**
  70820. * Gets the current list of color remap gradients.
  70821. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  70822. * @returns the list of color remap gradients
  70823. */
  70824. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  70825. /**
  70826. * Gets the current list of alpha remap gradients.
  70827. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  70828. * @returns the list of alpha remap gradients
  70829. */
  70830. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  70831. /**
  70832. * Gets the current list of life time gradients.
  70833. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  70834. * @returns the list of life time gradients
  70835. */
  70836. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  70837. /**
  70838. * Gets the current list of angular speed gradients.
  70839. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  70840. * @returns the list of angular speed gradients
  70841. */
  70842. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  70843. /**
  70844. * Gets the current list of velocity gradients.
  70845. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  70846. * @returns the list of velocity gradients
  70847. */
  70848. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  70849. /**
  70850. * Gets the current list of start size gradients.
  70851. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  70852. * @returns the list of start size gradients
  70853. */
  70854. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  70855. /**
  70856. * Gets the current list of emit rate gradients.
  70857. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  70858. * @returns the list of emit rate gradients
  70859. */
  70860. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  70861. /**
  70862. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  70863. * This only works when particleEmitterTyps is a BoxParticleEmitter
  70864. */
  70865. direction1: Vector3;
  70866. /**
  70867. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  70868. * This only works when particleEmitterTyps is a BoxParticleEmitter
  70869. */
  70870. direction2: Vector3;
  70871. /**
  70872. * 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.
  70873. * This only works when particleEmitterTyps is a BoxParticleEmitter
  70874. */
  70875. minEmitBox: Vector3;
  70876. /**
  70877. * 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.
  70878. * This only works when particleEmitterTyps is a BoxParticleEmitter
  70879. */
  70880. maxEmitBox: Vector3;
  70881. /**
  70882. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  70883. */
  70884. color1: Color4;
  70885. /**
  70886. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  70887. */
  70888. color2: Color4;
  70889. /**
  70890. * Color the particle will have at the end of its lifetime
  70891. */
  70892. colorDead: Color4;
  70893. /**
  70894. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  70895. */
  70896. textureMask: Color4;
  70897. /**
  70898. * The particle emitter type defines the emitter used by the particle system.
  70899. * It can be for example box, sphere, or cone...
  70900. */
  70901. particleEmitterType: IParticleEmitterType;
  70902. /** @hidden */
  70903. _isSubEmitter: boolean;
  70904. /**
  70905. * Gets or sets the billboard mode to use when isBillboardBased = true.
  70906. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  70907. */
  70908. billboardMode: number;
  70909. protected _isBillboardBased: boolean;
  70910. /**
  70911. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  70912. */
  70913. isBillboardBased: boolean;
  70914. /**
  70915. * The scene the particle system belongs to.
  70916. */
  70917. protected _scene: Scene;
  70918. /**
  70919. * Local cache of defines for image processing.
  70920. */
  70921. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  70922. /**
  70923. * Default configuration related to image processing available in the standard Material.
  70924. */
  70925. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  70926. /**
  70927. * Gets the image processing configuration used either in this material.
  70928. */
  70929. /**
  70930. * Sets the Default image processing configuration used either in the this material.
  70931. *
  70932. * If sets to null, the scene one is in use.
  70933. */
  70934. imageProcessingConfiguration: ImageProcessingConfiguration;
  70935. /**
  70936. * Attaches a new image processing configuration to the Standard Material.
  70937. * @param configuration
  70938. */
  70939. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  70940. /** @hidden */
  70941. protected _reset(): void;
  70942. /** @hidden */
  70943. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  70944. /**
  70945. * Instantiates a particle system.
  70946. * 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.
  70947. * @param name The name of the particle system
  70948. */
  70949. constructor(name: string);
  70950. /**
  70951. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  70952. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  70953. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  70954. * @returns the emitter
  70955. */
  70956. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  70957. /**
  70958. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  70959. * @param radius The radius of the hemisphere to emit from
  70960. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  70961. * @returns the emitter
  70962. */
  70963. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  70964. /**
  70965. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  70966. * @param radius The radius of the sphere to emit from
  70967. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  70968. * @returns the emitter
  70969. */
  70970. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  70971. /**
  70972. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  70973. * @param radius The radius of the sphere to emit from
  70974. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  70975. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  70976. * @returns the emitter
  70977. */
  70978. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  70979. /**
  70980. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  70981. * @param radius The radius of the emission cylinder
  70982. * @param height The height of the emission cylinder
  70983. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  70984. * @param directionRandomizer How much to randomize the particle direction [0-1]
  70985. * @returns the emitter
  70986. */
  70987. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  70988. /**
  70989. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  70990. * @param radius The radius of the cylinder to emit from
  70991. * @param height The height of the emission cylinder
  70992. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  70993. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  70994. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  70995. * @returns the emitter
  70996. */
  70997. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  70998. /**
  70999. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  71000. * @param radius The radius of the cone to emit from
  71001. * @param angle The base angle of the cone
  71002. * @returns the emitter
  71003. */
  71004. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  71005. /**
  71006. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  71007. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71008. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71009. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71010. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71011. * @returns the emitter
  71012. */
  71013. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  71014. }
  71015. }
  71016. declare module BABYLON {
  71017. /**
  71018. * Type of sub emitter
  71019. */
  71020. export enum SubEmitterType {
  71021. /**
  71022. * Attached to the particle over it's lifetime
  71023. */
  71024. ATTACHED = 0,
  71025. /**
  71026. * Created when the particle dies
  71027. */
  71028. END = 1
  71029. }
  71030. /**
  71031. * Sub emitter class used to emit particles from an existing particle
  71032. */
  71033. export class SubEmitter {
  71034. /**
  71035. * the particle system to be used by the sub emitter
  71036. */
  71037. particleSystem: ParticleSystem;
  71038. /**
  71039. * Type of the submitter (Default: END)
  71040. */
  71041. type: SubEmitterType;
  71042. /**
  71043. * 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)
  71044. * Note: This only is supported when using an emitter of type Mesh
  71045. */
  71046. inheritDirection: boolean;
  71047. /**
  71048. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  71049. */
  71050. inheritedVelocityAmount: number;
  71051. /**
  71052. * Creates a sub emitter
  71053. * @param particleSystem the particle system to be used by the sub emitter
  71054. */
  71055. constructor(
  71056. /**
  71057. * the particle system to be used by the sub emitter
  71058. */
  71059. particleSystem: ParticleSystem);
  71060. /**
  71061. * Clones the sub emitter
  71062. * @returns the cloned sub emitter
  71063. */
  71064. clone(): SubEmitter;
  71065. /**
  71066. * Serialize current object to a JSON object
  71067. * @returns the serialized object
  71068. */
  71069. serialize(): any;
  71070. /** @hidden */
  71071. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  71072. /**
  71073. * Creates a new SubEmitter from a serialized JSON version
  71074. * @param serializationObject defines the JSON object to read from
  71075. * @param scene defines the hosting scene
  71076. * @param rootUrl defines the rootUrl for data loading
  71077. * @returns a new SubEmitter
  71078. */
  71079. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  71080. /** Release associated resources */
  71081. dispose(): void;
  71082. }
  71083. }
  71084. declare module BABYLON {
  71085. /** @hidden */
  71086. export var clipPlaneFragmentDeclaration: {
  71087. name: string;
  71088. shader: string;
  71089. };
  71090. }
  71091. declare module BABYLON {
  71092. /** @hidden */
  71093. export var imageProcessingDeclaration: {
  71094. name: string;
  71095. shader: string;
  71096. };
  71097. }
  71098. declare module BABYLON {
  71099. /** @hidden */
  71100. export var imageProcessingFunctions: {
  71101. name: string;
  71102. shader: string;
  71103. };
  71104. }
  71105. declare module BABYLON {
  71106. /** @hidden */
  71107. export var clipPlaneFragment: {
  71108. name: string;
  71109. shader: string;
  71110. };
  71111. }
  71112. declare module BABYLON {
  71113. /** @hidden */
  71114. export var particlesPixelShader: {
  71115. name: string;
  71116. shader: string;
  71117. };
  71118. }
  71119. declare module BABYLON {
  71120. /** @hidden */
  71121. export var clipPlaneVertexDeclaration: {
  71122. name: string;
  71123. shader: string;
  71124. };
  71125. }
  71126. declare module BABYLON {
  71127. /** @hidden */
  71128. export var clipPlaneVertex: {
  71129. name: string;
  71130. shader: string;
  71131. };
  71132. }
  71133. declare module BABYLON {
  71134. /** @hidden */
  71135. export var particlesVertexShader: {
  71136. name: string;
  71137. shader: string;
  71138. };
  71139. }
  71140. declare module BABYLON {
  71141. /**
  71142. * This represents a particle system in Babylon.
  71143. * 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.
  71144. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71145. * @example https://doc.babylonjs.com/babylon101/particles
  71146. */
  71147. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  71148. /**
  71149. * Billboard mode will only apply to Y axis
  71150. */
  71151. static readonly BILLBOARDMODE_Y: number;
  71152. /**
  71153. * Billboard mode will apply to all axes
  71154. */
  71155. static readonly BILLBOARDMODE_ALL: number;
  71156. /**
  71157. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71158. */
  71159. static readonly BILLBOARDMODE_STRETCHED: number;
  71160. /**
  71161. * This function can be defined to provide custom update for active particles.
  71162. * This function will be called instead of regular update (age, position, color, etc.).
  71163. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  71164. */
  71165. updateFunction: (particles: Particle[]) => void;
  71166. private _emitterWorldMatrix;
  71167. /**
  71168. * This function can be defined to specify initial direction for every new particle.
  71169. * It by default use the emitterType defined function
  71170. */
  71171. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  71172. /**
  71173. * This function can be defined to specify initial position for every new particle.
  71174. * It by default use the emitterType defined function
  71175. */
  71176. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  71177. /**
  71178. * @hidden
  71179. */
  71180. _inheritedVelocityOffset: Vector3;
  71181. /**
  71182. * An event triggered when the system is disposed
  71183. */
  71184. onDisposeObservable: Observable<ParticleSystem>;
  71185. private _onDisposeObserver;
  71186. /**
  71187. * Sets a callback that will be triggered when the system is disposed
  71188. */
  71189. onDispose: () => void;
  71190. private _particles;
  71191. private _epsilon;
  71192. private _capacity;
  71193. private _stockParticles;
  71194. private _newPartsExcess;
  71195. private _vertexData;
  71196. private _vertexBuffer;
  71197. private _vertexBuffers;
  71198. private _spriteBuffer;
  71199. private _indexBuffer;
  71200. private _effect;
  71201. private _customEffect;
  71202. private _cachedDefines;
  71203. private _scaledColorStep;
  71204. private _colorDiff;
  71205. private _scaledDirection;
  71206. private _scaledGravity;
  71207. private _currentRenderId;
  71208. private _alive;
  71209. private _useInstancing;
  71210. private _started;
  71211. private _stopped;
  71212. private _actualFrame;
  71213. private _scaledUpdateSpeed;
  71214. private _vertexBufferSize;
  71215. /** @hidden */
  71216. _currentEmitRateGradient: Nullable<FactorGradient>;
  71217. /** @hidden */
  71218. _currentEmitRate1: number;
  71219. /** @hidden */
  71220. _currentEmitRate2: number;
  71221. /** @hidden */
  71222. _currentStartSizeGradient: Nullable<FactorGradient>;
  71223. /** @hidden */
  71224. _currentStartSize1: number;
  71225. /** @hidden */
  71226. _currentStartSize2: number;
  71227. private readonly _rawTextureWidth;
  71228. private _rampGradientsTexture;
  71229. private _useRampGradients;
  71230. /** Gets or sets a boolean indicating that ramp gradients must be used
  71231. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71232. */
  71233. useRampGradients: boolean;
  71234. /**
  71235. * 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.
  71236. * 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: [])
  71237. */
  71238. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  71239. private _subEmitters;
  71240. /**
  71241. * @hidden
  71242. * If the particle systems emitter should be disposed when the particle system is disposed
  71243. */
  71244. _disposeEmitterOnDispose: boolean;
  71245. /**
  71246. * The current active Sub-systems, this property is used by the root particle system only.
  71247. */
  71248. activeSubSystems: Array<ParticleSystem>;
  71249. private _rootParticleSystem;
  71250. /**
  71251. * Gets the current list of active particles
  71252. */
  71253. readonly particles: Particle[];
  71254. /**
  71255. * Returns the string "ParticleSystem"
  71256. * @returns a string containing the class name
  71257. */
  71258. getClassName(): string;
  71259. /**
  71260. * Instantiates a particle system.
  71261. * 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.
  71262. * @param name The name of the particle system
  71263. * @param capacity The max number of particles alive at the same time
  71264. * @param scene The scene the particle system belongs to
  71265. * @param customEffect a custom effect used to change the way particles are rendered by default
  71266. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71267. * @param epsilon Offset used to render the particles
  71268. */
  71269. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  71270. private _addFactorGradient;
  71271. private _removeFactorGradient;
  71272. /**
  71273. * Adds a new life time gradient
  71274. * @param gradient defines the gradient to use (between 0 and 1)
  71275. * @param factor defines the life time factor to affect to the specified gradient
  71276. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71277. * @returns the current particle system
  71278. */
  71279. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71280. /**
  71281. * Remove a specific life time gradient
  71282. * @param gradient defines the gradient to remove
  71283. * @returns the current particle system
  71284. */
  71285. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71286. /**
  71287. * Adds a new size gradient
  71288. * @param gradient defines the gradient to use (between 0 and 1)
  71289. * @param factor defines the size factor to affect to the specified gradient
  71290. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71291. * @returns the current particle system
  71292. */
  71293. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71294. /**
  71295. * Remove a specific size gradient
  71296. * @param gradient defines the gradient to remove
  71297. * @returns the current particle system
  71298. */
  71299. removeSizeGradient(gradient: number): IParticleSystem;
  71300. /**
  71301. * Adds a new color remap gradient
  71302. * @param gradient defines the gradient to use (between 0 and 1)
  71303. * @param min defines the color remap minimal range
  71304. * @param max defines the color remap maximal range
  71305. * @returns the current particle system
  71306. */
  71307. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71308. /**
  71309. * Remove a specific color remap gradient
  71310. * @param gradient defines the gradient to remove
  71311. * @returns the current particle system
  71312. */
  71313. removeColorRemapGradient(gradient: number): IParticleSystem;
  71314. /**
  71315. * Adds a new alpha remap gradient
  71316. * @param gradient defines the gradient to use (between 0 and 1)
  71317. * @param min defines the alpha remap minimal range
  71318. * @param max defines the alpha remap maximal range
  71319. * @returns the current particle system
  71320. */
  71321. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71322. /**
  71323. * Remove a specific alpha remap gradient
  71324. * @param gradient defines the gradient to remove
  71325. * @returns the current particle system
  71326. */
  71327. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  71328. /**
  71329. * Adds a new angular speed gradient
  71330. * @param gradient defines the gradient to use (between 0 and 1)
  71331. * @param factor defines the angular speed to affect to the specified gradient
  71332. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71333. * @returns the current particle system
  71334. */
  71335. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71336. /**
  71337. * Remove a specific angular speed gradient
  71338. * @param gradient defines the gradient to remove
  71339. * @returns the current particle system
  71340. */
  71341. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  71342. /**
  71343. * Adds a new velocity gradient
  71344. * @param gradient defines the gradient to use (between 0 and 1)
  71345. * @param factor defines the velocity to affect to the specified gradient
  71346. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71347. * @returns the current particle system
  71348. */
  71349. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71350. /**
  71351. * Remove a specific velocity gradient
  71352. * @param gradient defines the gradient to remove
  71353. * @returns the current particle system
  71354. */
  71355. removeVelocityGradient(gradient: number): IParticleSystem;
  71356. /**
  71357. * Adds a new limit velocity gradient
  71358. * @param gradient defines the gradient to use (between 0 and 1)
  71359. * @param factor defines the limit velocity value to affect to the specified gradient
  71360. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71361. * @returns the current particle system
  71362. */
  71363. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71364. /**
  71365. * Remove a specific limit velocity gradient
  71366. * @param gradient defines the gradient to remove
  71367. * @returns the current particle system
  71368. */
  71369. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  71370. /**
  71371. * Adds a new drag gradient
  71372. * @param gradient defines the gradient to use (between 0 and 1)
  71373. * @param factor defines the drag value to affect to the specified gradient
  71374. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71375. * @returns the current particle system
  71376. */
  71377. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71378. /**
  71379. * Remove a specific drag gradient
  71380. * @param gradient defines the gradient to remove
  71381. * @returns the current particle system
  71382. */
  71383. removeDragGradient(gradient: number): IParticleSystem;
  71384. /**
  71385. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  71386. * @param gradient defines the gradient to use (between 0 and 1)
  71387. * @param factor defines the emit rate value to affect to the specified gradient
  71388. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71389. * @returns the current particle system
  71390. */
  71391. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71392. /**
  71393. * Remove a specific emit rate gradient
  71394. * @param gradient defines the gradient to remove
  71395. * @returns the current particle system
  71396. */
  71397. removeEmitRateGradient(gradient: number): IParticleSystem;
  71398. /**
  71399. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  71400. * @param gradient defines the gradient to use (between 0 and 1)
  71401. * @param factor defines the start size value to affect to the specified gradient
  71402. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71403. * @returns the current particle system
  71404. */
  71405. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71406. /**
  71407. * Remove a specific start size gradient
  71408. * @param gradient defines the gradient to remove
  71409. * @returns the current particle system
  71410. */
  71411. removeStartSizeGradient(gradient: number): IParticleSystem;
  71412. private _createRampGradientTexture;
  71413. /**
  71414. * Gets the current list of ramp gradients.
  71415. * You must use addRampGradient and removeRampGradient to udpate this list
  71416. * @returns the list of ramp gradients
  71417. */
  71418. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71419. /**
  71420. * Adds a new ramp gradient used to remap particle colors
  71421. * @param gradient defines the gradient to use (between 0 and 1)
  71422. * @param color defines the color to affect to the specified gradient
  71423. * @returns the current particle system
  71424. */
  71425. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  71426. /**
  71427. * Remove a specific ramp gradient
  71428. * @param gradient defines the gradient to remove
  71429. * @returns the current particle system
  71430. */
  71431. removeRampGradient(gradient: number): ParticleSystem;
  71432. /**
  71433. * Adds a new color gradient
  71434. * @param gradient defines the gradient to use (between 0 and 1)
  71435. * @param color1 defines the color to affect to the specified gradient
  71436. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71437. * @returns this particle system
  71438. */
  71439. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  71440. /**
  71441. * Remove a specific color gradient
  71442. * @param gradient defines the gradient to remove
  71443. * @returns this particle system
  71444. */
  71445. removeColorGradient(gradient: number): IParticleSystem;
  71446. private _fetchR;
  71447. protected _reset(): void;
  71448. private _resetEffect;
  71449. private _createVertexBuffers;
  71450. private _createIndexBuffer;
  71451. /**
  71452. * Gets the maximum number of particles active at the same time.
  71453. * @returns The max number of active particles.
  71454. */
  71455. getCapacity(): number;
  71456. /**
  71457. * Gets whether there are still active particles in the system.
  71458. * @returns True if it is alive, otherwise false.
  71459. */
  71460. isAlive(): boolean;
  71461. /**
  71462. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71463. * @returns True if it has been started, otherwise false.
  71464. */
  71465. isStarted(): boolean;
  71466. private _prepareSubEmitterInternalArray;
  71467. /**
  71468. * Starts the particle system and begins to emit
  71469. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71470. */
  71471. start(delay?: number): void;
  71472. /**
  71473. * Stops the particle system.
  71474. * @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.
  71475. */
  71476. stop(stopSubEmitters?: boolean): void;
  71477. /**
  71478. * Remove all active particles
  71479. */
  71480. reset(): void;
  71481. /**
  71482. * @hidden (for internal use only)
  71483. */
  71484. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  71485. /**
  71486. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  71487. * Its lifetime will start back at 0.
  71488. */
  71489. recycleParticle: (particle: Particle) => void;
  71490. private _stopSubEmitters;
  71491. private _createParticle;
  71492. private _removeFromRoot;
  71493. private _emitFromParticle;
  71494. private _update;
  71495. /** @hidden */
  71496. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  71497. /** @hidden */
  71498. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  71499. /** @hidden */
  71500. private _getEffect;
  71501. /**
  71502. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71503. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  71504. */
  71505. animate(preWarmOnly?: boolean): void;
  71506. private _appendParticleVertices;
  71507. /**
  71508. * Rebuilds the particle system.
  71509. */
  71510. rebuild(): void;
  71511. /**
  71512. * Is this system ready to be used/rendered
  71513. * @return true if the system is ready
  71514. */
  71515. isReady(): boolean;
  71516. private _render;
  71517. /**
  71518. * Renders the particle system in its current state.
  71519. * @returns the current number of particles
  71520. */
  71521. render(): number;
  71522. /**
  71523. * Disposes the particle system and free the associated resources
  71524. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71525. */
  71526. dispose(disposeTexture?: boolean): void;
  71527. /**
  71528. * Clones the particle system.
  71529. * @param name The name of the cloned object
  71530. * @param newEmitter The new emitter to use
  71531. * @returns the cloned particle system
  71532. */
  71533. clone(name: string, newEmitter: any): ParticleSystem;
  71534. /**
  71535. * Serializes the particle system to a JSON object.
  71536. * @returns the JSON object
  71537. */
  71538. serialize(): any;
  71539. /** @hidden */
  71540. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  71541. /** @hidden */
  71542. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  71543. /**
  71544. * Parses a JSON object to create a particle system.
  71545. * @param parsedParticleSystem The JSON object to parse
  71546. * @param scene The scene to create the particle system in
  71547. * @param rootUrl The root url to use to load external dependencies like texture
  71548. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71549. * @returns the Parsed particle system
  71550. */
  71551. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  71552. }
  71553. }
  71554. declare module BABYLON {
  71555. /**
  71556. * A particle represents one of the element emitted by a particle system.
  71557. * This is mainly define by its coordinates, direction, velocity and age.
  71558. */
  71559. export class Particle {
  71560. /**
  71561. * The particle system the particle belongs to.
  71562. */
  71563. particleSystem: ParticleSystem;
  71564. private static _Count;
  71565. /**
  71566. * Unique ID of the particle
  71567. */
  71568. id: number;
  71569. /**
  71570. * The world position of the particle in the scene.
  71571. */
  71572. position: Vector3;
  71573. /**
  71574. * The world direction of the particle in the scene.
  71575. */
  71576. direction: Vector3;
  71577. /**
  71578. * The color of the particle.
  71579. */
  71580. color: Color4;
  71581. /**
  71582. * The color change of the particle per step.
  71583. */
  71584. colorStep: Color4;
  71585. /**
  71586. * Defines how long will the life of the particle be.
  71587. */
  71588. lifeTime: number;
  71589. /**
  71590. * The current age of the particle.
  71591. */
  71592. age: number;
  71593. /**
  71594. * The current size of the particle.
  71595. */
  71596. size: number;
  71597. /**
  71598. * The current scale of the particle.
  71599. */
  71600. scale: Vector2;
  71601. /**
  71602. * The current angle of the particle.
  71603. */
  71604. angle: number;
  71605. /**
  71606. * Defines how fast is the angle changing.
  71607. */
  71608. angularSpeed: number;
  71609. /**
  71610. * Defines the cell index used by the particle to be rendered from a sprite.
  71611. */
  71612. cellIndex: number;
  71613. /**
  71614. * The information required to support color remapping
  71615. */
  71616. remapData: Vector4;
  71617. /** @hidden */
  71618. _randomCellOffset?: number;
  71619. /** @hidden */
  71620. _initialDirection: Nullable<Vector3>;
  71621. /** @hidden */
  71622. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  71623. /** @hidden */
  71624. _initialStartSpriteCellID: number;
  71625. /** @hidden */
  71626. _initialEndSpriteCellID: number;
  71627. /** @hidden */
  71628. _currentColorGradient: Nullable<ColorGradient>;
  71629. /** @hidden */
  71630. _currentColor1: Color4;
  71631. /** @hidden */
  71632. _currentColor2: Color4;
  71633. /** @hidden */
  71634. _currentSizeGradient: Nullable<FactorGradient>;
  71635. /** @hidden */
  71636. _currentSize1: number;
  71637. /** @hidden */
  71638. _currentSize2: number;
  71639. /** @hidden */
  71640. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  71641. /** @hidden */
  71642. _currentAngularSpeed1: number;
  71643. /** @hidden */
  71644. _currentAngularSpeed2: number;
  71645. /** @hidden */
  71646. _currentVelocityGradient: Nullable<FactorGradient>;
  71647. /** @hidden */
  71648. _currentVelocity1: number;
  71649. /** @hidden */
  71650. _currentVelocity2: number;
  71651. /** @hidden */
  71652. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  71653. /** @hidden */
  71654. _currentLimitVelocity1: number;
  71655. /** @hidden */
  71656. _currentLimitVelocity2: number;
  71657. /** @hidden */
  71658. _currentDragGradient: Nullable<FactorGradient>;
  71659. /** @hidden */
  71660. _currentDrag1: number;
  71661. /** @hidden */
  71662. _currentDrag2: number;
  71663. /** @hidden */
  71664. _randomNoiseCoordinates1: Vector3;
  71665. /** @hidden */
  71666. _randomNoiseCoordinates2: Vector3;
  71667. /**
  71668. * Creates a new instance Particle
  71669. * @param particleSystem the particle system the particle belongs to
  71670. */
  71671. constructor(
  71672. /**
  71673. * The particle system the particle belongs to.
  71674. */
  71675. particleSystem: ParticleSystem);
  71676. private updateCellInfoFromSystem;
  71677. /**
  71678. * Defines how the sprite cell index is updated for the particle
  71679. */
  71680. updateCellIndex(): void;
  71681. /** @hidden */
  71682. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  71683. /** @hidden */
  71684. _inheritParticleInfoToSubEmitters(): void;
  71685. /** @hidden */
  71686. _reset(): void;
  71687. /**
  71688. * Copy the properties of particle to another one.
  71689. * @param other the particle to copy the information to.
  71690. */
  71691. copyTo(other: Particle): void;
  71692. }
  71693. }
  71694. declare module BABYLON {
  71695. /**
  71696. * Particle emitter represents a volume emitting particles.
  71697. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  71698. */
  71699. export interface IParticleEmitterType {
  71700. /**
  71701. * Called by the particle System when the direction is computed for the created particle.
  71702. * @param worldMatrix is the world matrix of the particle system
  71703. * @param directionToUpdate is the direction vector to update with the result
  71704. * @param particle is the particle we are computed the direction for
  71705. */
  71706. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71707. /**
  71708. * Called by the particle System when the position is computed for the created particle.
  71709. * @param worldMatrix is the world matrix of the particle system
  71710. * @param positionToUpdate is the position vector to update with the result
  71711. * @param particle is the particle we are computed the position for
  71712. */
  71713. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71714. /**
  71715. * Clones the current emitter and returns a copy of it
  71716. * @returns the new emitter
  71717. */
  71718. clone(): IParticleEmitterType;
  71719. /**
  71720. * Called by the GPUParticleSystem to setup the update shader
  71721. * @param effect defines the update shader
  71722. */
  71723. applyToShader(effect: Effect): void;
  71724. /**
  71725. * Returns a string to use to update the GPU particles update shader
  71726. * @returns the effect defines string
  71727. */
  71728. getEffectDefines(): string;
  71729. /**
  71730. * Returns a string representing the class name
  71731. * @returns a string containing the class name
  71732. */
  71733. getClassName(): string;
  71734. /**
  71735. * Serializes the particle system to a JSON object.
  71736. * @returns the JSON object
  71737. */
  71738. serialize(): any;
  71739. /**
  71740. * Parse properties from a JSON object
  71741. * @param serializationObject defines the JSON object
  71742. */
  71743. parse(serializationObject: any): void;
  71744. }
  71745. }
  71746. declare module BABYLON {
  71747. /**
  71748. * Particle emitter emitting particles from the inside of a box.
  71749. * It emits the particles randomly between 2 given directions.
  71750. */
  71751. export class BoxParticleEmitter implements IParticleEmitterType {
  71752. /**
  71753. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71754. */
  71755. direction1: Vector3;
  71756. /**
  71757. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71758. */
  71759. direction2: Vector3;
  71760. /**
  71761. * 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.
  71762. */
  71763. minEmitBox: Vector3;
  71764. /**
  71765. * 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.
  71766. */
  71767. maxEmitBox: Vector3;
  71768. /**
  71769. * Creates a new instance BoxParticleEmitter
  71770. */
  71771. constructor();
  71772. /**
  71773. * Called by the particle System when the direction is computed for the created particle.
  71774. * @param worldMatrix is the world matrix of the particle system
  71775. * @param directionToUpdate is the direction vector to update with the result
  71776. * @param particle is the particle we are computed the direction for
  71777. */
  71778. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71779. /**
  71780. * Called by the particle System when the position is computed for the created particle.
  71781. * @param worldMatrix is the world matrix of the particle system
  71782. * @param positionToUpdate is the position vector to update with the result
  71783. * @param particle is the particle we are computed the position for
  71784. */
  71785. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71786. /**
  71787. * Clones the current emitter and returns a copy of it
  71788. * @returns the new emitter
  71789. */
  71790. clone(): BoxParticleEmitter;
  71791. /**
  71792. * Called by the GPUParticleSystem to setup the update shader
  71793. * @param effect defines the update shader
  71794. */
  71795. applyToShader(effect: Effect): void;
  71796. /**
  71797. * Returns a string to use to update the GPU particles update shader
  71798. * @returns a string containng the defines string
  71799. */
  71800. getEffectDefines(): string;
  71801. /**
  71802. * Returns the string "BoxParticleEmitter"
  71803. * @returns a string containing the class name
  71804. */
  71805. getClassName(): string;
  71806. /**
  71807. * Serializes the particle system to a JSON object.
  71808. * @returns the JSON object
  71809. */
  71810. serialize(): any;
  71811. /**
  71812. * Parse properties from a JSON object
  71813. * @param serializationObject defines the JSON object
  71814. */
  71815. parse(serializationObject: any): void;
  71816. }
  71817. }
  71818. declare module BABYLON {
  71819. /**
  71820. * Particle emitter emitting particles from the inside of a cone.
  71821. * It emits the particles alongside the cone volume from the base to the particle.
  71822. * The emission direction might be randomized.
  71823. */
  71824. export class ConeParticleEmitter implements IParticleEmitterType {
  71825. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  71826. directionRandomizer: number;
  71827. private _radius;
  71828. private _angle;
  71829. private _height;
  71830. /**
  71831. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  71832. */
  71833. radiusRange: number;
  71834. /**
  71835. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  71836. */
  71837. heightRange: number;
  71838. /**
  71839. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  71840. */
  71841. emitFromSpawnPointOnly: boolean;
  71842. /**
  71843. * Gets or sets the radius of the emission cone
  71844. */
  71845. radius: number;
  71846. /**
  71847. * Gets or sets the angle of the emission cone
  71848. */
  71849. angle: number;
  71850. private _buildHeight;
  71851. /**
  71852. * Creates a new instance ConeParticleEmitter
  71853. * @param radius the radius of the emission cone (1 by default)
  71854. * @param angle the cone base angle (PI by default)
  71855. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  71856. */
  71857. constructor(radius?: number, angle?: number,
  71858. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  71859. directionRandomizer?: number);
  71860. /**
  71861. * Called by the particle System when the direction is computed for the created particle.
  71862. * @param worldMatrix is the world matrix of the particle system
  71863. * @param directionToUpdate is the direction vector to update with the result
  71864. * @param particle is the particle we are computed the direction for
  71865. */
  71866. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71867. /**
  71868. * Called by the particle System when the position is computed for the created particle.
  71869. * @param worldMatrix is the world matrix of the particle system
  71870. * @param positionToUpdate is the position vector to update with the result
  71871. * @param particle is the particle we are computed the position for
  71872. */
  71873. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71874. /**
  71875. * Clones the current emitter and returns a copy of it
  71876. * @returns the new emitter
  71877. */
  71878. clone(): ConeParticleEmitter;
  71879. /**
  71880. * Called by the GPUParticleSystem to setup the update shader
  71881. * @param effect defines the update shader
  71882. */
  71883. applyToShader(effect: Effect): void;
  71884. /**
  71885. * Returns a string to use to update the GPU particles update shader
  71886. * @returns a string containng the defines string
  71887. */
  71888. getEffectDefines(): string;
  71889. /**
  71890. * Returns the string "ConeParticleEmitter"
  71891. * @returns a string containing the class name
  71892. */
  71893. getClassName(): string;
  71894. /**
  71895. * Serializes the particle system to a JSON object.
  71896. * @returns the JSON object
  71897. */
  71898. serialize(): any;
  71899. /**
  71900. * Parse properties from a JSON object
  71901. * @param serializationObject defines the JSON object
  71902. */
  71903. parse(serializationObject: any): void;
  71904. }
  71905. }
  71906. declare module BABYLON {
  71907. /**
  71908. * Particle emitter emitting particles from the inside of a cylinder.
  71909. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  71910. */
  71911. export class CylinderParticleEmitter implements IParticleEmitterType {
  71912. /**
  71913. * The radius of the emission cylinder.
  71914. */
  71915. radius: number;
  71916. /**
  71917. * The height of the emission cylinder.
  71918. */
  71919. height: number;
  71920. /**
  71921. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  71922. */
  71923. radiusRange: number;
  71924. /**
  71925. * How much to randomize the particle direction [0-1].
  71926. */
  71927. directionRandomizer: number;
  71928. /**
  71929. * Creates a new instance CylinderParticleEmitter
  71930. * @param radius the radius of the emission cylinder (1 by default)
  71931. * @param height the height of the emission cylinder (1 by default)
  71932. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71933. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  71934. */
  71935. constructor(
  71936. /**
  71937. * The radius of the emission cylinder.
  71938. */
  71939. radius?: number,
  71940. /**
  71941. * The height of the emission cylinder.
  71942. */
  71943. height?: number,
  71944. /**
  71945. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  71946. */
  71947. radiusRange?: number,
  71948. /**
  71949. * How much to randomize the particle direction [0-1].
  71950. */
  71951. directionRandomizer?: number);
  71952. /**
  71953. * Called by the particle System when the direction is computed for the created particle.
  71954. * @param worldMatrix is the world matrix of the particle system
  71955. * @param directionToUpdate is the direction vector to update with the result
  71956. * @param particle is the particle we are computed the direction for
  71957. */
  71958. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71959. /**
  71960. * Called by the particle System when the position is computed for the created particle.
  71961. * @param worldMatrix is the world matrix of the particle system
  71962. * @param positionToUpdate is the position vector to update with the result
  71963. * @param particle is the particle we are computed the position for
  71964. */
  71965. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71966. /**
  71967. * Clones the current emitter and returns a copy of it
  71968. * @returns the new emitter
  71969. */
  71970. clone(): CylinderParticleEmitter;
  71971. /**
  71972. * Called by the GPUParticleSystem to setup the update shader
  71973. * @param effect defines the update shader
  71974. */
  71975. applyToShader(effect: Effect): void;
  71976. /**
  71977. * Returns a string to use to update the GPU particles update shader
  71978. * @returns a string containng the defines string
  71979. */
  71980. getEffectDefines(): string;
  71981. /**
  71982. * Returns the string "CylinderParticleEmitter"
  71983. * @returns a string containing the class name
  71984. */
  71985. getClassName(): string;
  71986. /**
  71987. * Serializes the particle system to a JSON object.
  71988. * @returns the JSON object
  71989. */
  71990. serialize(): any;
  71991. /**
  71992. * Parse properties from a JSON object
  71993. * @param serializationObject defines the JSON object
  71994. */
  71995. parse(serializationObject: any): void;
  71996. }
  71997. /**
  71998. * Particle emitter emitting particles from the inside of a cylinder.
  71999. * It emits the particles randomly between two vectors.
  72000. */
  72001. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  72002. /**
  72003. * The min limit of the emission direction.
  72004. */
  72005. direction1: Vector3;
  72006. /**
  72007. * The max limit of the emission direction.
  72008. */
  72009. direction2: Vector3;
  72010. /**
  72011. * Creates a new instance CylinderDirectedParticleEmitter
  72012. * @param radius the radius of the emission cylinder (1 by default)
  72013. * @param height the height of the emission cylinder (1 by default)
  72014. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72015. * @param direction1 the min limit of the emission direction (up vector by default)
  72016. * @param direction2 the max limit of the emission direction (up vector by default)
  72017. */
  72018. constructor(radius?: number, height?: number, radiusRange?: number,
  72019. /**
  72020. * The min limit of the emission direction.
  72021. */
  72022. direction1?: Vector3,
  72023. /**
  72024. * The max limit of the emission direction.
  72025. */
  72026. direction2?: Vector3);
  72027. /**
  72028. * Called by the particle System when the direction is computed for the created particle.
  72029. * @param worldMatrix is the world matrix of the particle system
  72030. * @param directionToUpdate is the direction vector to update with the result
  72031. * @param particle is the particle we are computed the direction for
  72032. */
  72033. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72034. /**
  72035. * Clones the current emitter and returns a copy of it
  72036. * @returns the new emitter
  72037. */
  72038. clone(): CylinderDirectedParticleEmitter;
  72039. /**
  72040. * Called by the GPUParticleSystem to setup the update shader
  72041. * @param effect defines the update shader
  72042. */
  72043. applyToShader(effect: Effect): void;
  72044. /**
  72045. * Returns a string to use to update the GPU particles update shader
  72046. * @returns a string containng the defines string
  72047. */
  72048. getEffectDefines(): string;
  72049. /**
  72050. * Returns the string "CylinderDirectedParticleEmitter"
  72051. * @returns a string containing the class name
  72052. */
  72053. getClassName(): string;
  72054. /**
  72055. * Serializes the particle system to a JSON object.
  72056. * @returns the JSON object
  72057. */
  72058. serialize(): any;
  72059. /**
  72060. * Parse properties from a JSON object
  72061. * @param serializationObject defines the JSON object
  72062. */
  72063. parse(serializationObject: any): void;
  72064. }
  72065. }
  72066. declare module BABYLON {
  72067. /**
  72068. * Particle emitter emitting particles from the inside of a hemisphere.
  72069. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  72070. */
  72071. export class HemisphericParticleEmitter implements IParticleEmitterType {
  72072. /**
  72073. * The radius of the emission hemisphere.
  72074. */
  72075. radius: number;
  72076. /**
  72077. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72078. */
  72079. radiusRange: number;
  72080. /**
  72081. * How much to randomize the particle direction [0-1].
  72082. */
  72083. directionRandomizer: number;
  72084. /**
  72085. * Creates a new instance HemisphericParticleEmitter
  72086. * @param radius the radius of the emission hemisphere (1 by default)
  72087. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72088. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72089. */
  72090. constructor(
  72091. /**
  72092. * The radius of the emission hemisphere.
  72093. */
  72094. radius?: number,
  72095. /**
  72096. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72097. */
  72098. radiusRange?: number,
  72099. /**
  72100. * How much to randomize the particle direction [0-1].
  72101. */
  72102. directionRandomizer?: number);
  72103. /**
  72104. * Called by the particle System when the direction is computed for the created particle.
  72105. * @param worldMatrix is the world matrix of the particle system
  72106. * @param directionToUpdate is the direction vector to update with the result
  72107. * @param particle is the particle we are computed the direction for
  72108. */
  72109. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72110. /**
  72111. * Called by the particle System when the position is computed for the created particle.
  72112. * @param worldMatrix is the world matrix of the particle system
  72113. * @param positionToUpdate is the position vector to update with the result
  72114. * @param particle is the particle we are computed the position for
  72115. */
  72116. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72117. /**
  72118. * Clones the current emitter and returns a copy of it
  72119. * @returns the new emitter
  72120. */
  72121. clone(): HemisphericParticleEmitter;
  72122. /**
  72123. * Called by the GPUParticleSystem to setup the update shader
  72124. * @param effect defines the update shader
  72125. */
  72126. applyToShader(effect: Effect): void;
  72127. /**
  72128. * Returns a string to use to update the GPU particles update shader
  72129. * @returns a string containng the defines string
  72130. */
  72131. getEffectDefines(): string;
  72132. /**
  72133. * Returns the string "HemisphericParticleEmitter"
  72134. * @returns a string containing the class name
  72135. */
  72136. getClassName(): string;
  72137. /**
  72138. * Serializes the particle system to a JSON object.
  72139. * @returns the JSON object
  72140. */
  72141. serialize(): any;
  72142. /**
  72143. * Parse properties from a JSON object
  72144. * @param serializationObject defines the JSON object
  72145. */
  72146. parse(serializationObject: any): void;
  72147. }
  72148. }
  72149. declare module BABYLON {
  72150. /**
  72151. * Particle emitter emitting particles from a point.
  72152. * It emits the particles randomly between 2 given directions.
  72153. */
  72154. export class PointParticleEmitter implements IParticleEmitterType {
  72155. /**
  72156. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72157. */
  72158. direction1: Vector3;
  72159. /**
  72160. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72161. */
  72162. direction2: Vector3;
  72163. /**
  72164. * Creates a new instance PointParticleEmitter
  72165. */
  72166. constructor();
  72167. /**
  72168. * Called by the particle System when the direction is computed for the created particle.
  72169. * @param worldMatrix is the world matrix of the particle system
  72170. * @param directionToUpdate is the direction vector to update with the result
  72171. * @param particle is the particle we are computed the direction for
  72172. */
  72173. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72174. /**
  72175. * Called by the particle System when the position is computed for the created particle.
  72176. * @param worldMatrix is the world matrix of the particle system
  72177. * @param positionToUpdate is the position vector to update with the result
  72178. * @param particle is the particle we are computed the position for
  72179. */
  72180. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72181. /**
  72182. * Clones the current emitter and returns a copy of it
  72183. * @returns the new emitter
  72184. */
  72185. clone(): PointParticleEmitter;
  72186. /**
  72187. * Called by the GPUParticleSystem to setup the update shader
  72188. * @param effect defines the update shader
  72189. */
  72190. applyToShader(effect: Effect): void;
  72191. /**
  72192. * Returns a string to use to update the GPU particles update shader
  72193. * @returns a string containng the defines string
  72194. */
  72195. getEffectDefines(): string;
  72196. /**
  72197. * Returns the string "PointParticleEmitter"
  72198. * @returns a string containing the class name
  72199. */
  72200. getClassName(): string;
  72201. /**
  72202. * Serializes the particle system to a JSON object.
  72203. * @returns the JSON object
  72204. */
  72205. serialize(): any;
  72206. /**
  72207. * Parse properties from a JSON object
  72208. * @param serializationObject defines the JSON object
  72209. */
  72210. parse(serializationObject: any): void;
  72211. }
  72212. }
  72213. declare module BABYLON {
  72214. /**
  72215. * Particle emitter emitting particles from the inside of a sphere.
  72216. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  72217. */
  72218. export class SphereParticleEmitter implements IParticleEmitterType {
  72219. /**
  72220. * The radius of the emission sphere.
  72221. */
  72222. radius: number;
  72223. /**
  72224. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72225. */
  72226. radiusRange: number;
  72227. /**
  72228. * How much to randomize the particle direction [0-1].
  72229. */
  72230. directionRandomizer: number;
  72231. /**
  72232. * Creates a new instance SphereParticleEmitter
  72233. * @param radius the radius of the emission sphere (1 by default)
  72234. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72235. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72236. */
  72237. constructor(
  72238. /**
  72239. * The radius of the emission sphere.
  72240. */
  72241. radius?: number,
  72242. /**
  72243. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72244. */
  72245. radiusRange?: number,
  72246. /**
  72247. * How much to randomize the particle direction [0-1].
  72248. */
  72249. directionRandomizer?: number);
  72250. /**
  72251. * Called by the particle System when the direction is computed for the created particle.
  72252. * @param worldMatrix is the world matrix of the particle system
  72253. * @param directionToUpdate is the direction vector to update with the result
  72254. * @param particle is the particle we are computed the direction for
  72255. */
  72256. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72257. /**
  72258. * Called by the particle System when the position is computed for the created particle.
  72259. * @param worldMatrix is the world matrix of the particle system
  72260. * @param positionToUpdate is the position vector to update with the result
  72261. * @param particle is the particle we are computed the position for
  72262. */
  72263. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72264. /**
  72265. * Clones the current emitter and returns a copy of it
  72266. * @returns the new emitter
  72267. */
  72268. clone(): SphereParticleEmitter;
  72269. /**
  72270. * Called by the GPUParticleSystem to setup the update shader
  72271. * @param effect defines the update shader
  72272. */
  72273. applyToShader(effect: Effect): void;
  72274. /**
  72275. * Returns a string to use to update the GPU particles update shader
  72276. * @returns a string containng the defines string
  72277. */
  72278. getEffectDefines(): string;
  72279. /**
  72280. * Returns the string "SphereParticleEmitter"
  72281. * @returns a string containing the class name
  72282. */
  72283. getClassName(): string;
  72284. /**
  72285. * Serializes the particle system to a JSON object.
  72286. * @returns the JSON object
  72287. */
  72288. serialize(): any;
  72289. /**
  72290. * Parse properties from a JSON object
  72291. * @param serializationObject defines the JSON object
  72292. */
  72293. parse(serializationObject: any): void;
  72294. }
  72295. /**
  72296. * Particle emitter emitting particles from the inside of a sphere.
  72297. * It emits the particles randomly between two vectors.
  72298. */
  72299. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  72300. /**
  72301. * The min limit of the emission direction.
  72302. */
  72303. direction1: Vector3;
  72304. /**
  72305. * The max limit of the emission direction.
  72306. */
  72307. direction2: Vector3;
  72308. /**
  72309. * Creates a new instance SphereDirectedParticleEmitter
  72310. * @param radius the radius of the emission sphere (1 by default)
  72311. * @param direction1 the min limit of the emission direction (up vector by default)
  72312. * @param direction2 the max limit of the emission direction (up vector by default)
  72313. */
  72314. constructor(radius?: number,
  72315. /**
  72316. * The min limit of the emission direction.
  72317. */
  72318. direction1?: Vector3,
  72319. /**
  72320. * The max limit of the emission direction.
  72321. */
  72322. direction2?: Vector3);
  72323. /**
  72324. * Called by the particle System when the direction is computed for the created particle.
  72325. * @param worldMatrix is the world matrix of the particle system
  72326. * @param directionToUpdate is the direction vector to update with the result
  72327. * @param particle is the particle we are computed the direction for
  72328. */
  72329. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72330. /**
  72331. * Clones the current emitter and returns a copy of it
  72332. * @returns the new emitter
  72333. */
  72334. clone(): SphereDirectedParticleEmitter;
  72335. /**
  72336. * Called by the GPUParticleSystem to setup the update shader
  72337. * @param effect defines the update shader
  72338. */
  72339. applyToShader(effect: Effect): void;
  72340. /**
  72341. * Returns a string to use to update the GPU particles update shader
  72342. * @returns a string containng the defines string
  72343. */
  72344. getEffectDefines(): string;
  72345. /**
  72346. * Returns the string "SphereDirectedParticleEmitter"
  72347. * @returns a string containing the class name
  72348. */
  72349. getClassName(): string;
  72350. /**
  72351. * Serializes the particle system to a JSON object.
  72352. * @returns the JSON object
  72353. */
  72354. serialize(): any;
  72355. /**
  72356. * Parse properties from a JSON object
  72357. * @param serializationObject defines the JSON object
  72358. */
  72359. parse(serializationObject: any): void;
  72360. }
  72361. }
  72362. declare module BABYLON {
  72363. /**
  72364. * Interface representing a particle system in Babylon.js.
  72365. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  72366. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  72367. */
  72368. export interface IParticleSystem {
  72369. /**
  72370. * List of animations used by the particle system.
  72371. */
  72372. animations: Animation[];
  72373. /**
  72374. * The id of the Particle system.
  72375. */
  72376. id: string;
  72377. /**
  72378. * The name of the Particle system.
  72379. */
  72380. name: string;
  72381. /**
  72382. * The emitter represents the Mesh or position we are attaching the particle system to.
  72383. */
  72384. emitter: Nullable<AbstractMesh | Vector3>;
  72385. /**
  72386. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  72387. */
  72388. isBillboardBased: boolean;
  72389. /**
  72390. * The rendering group used by the Particle system to chose when to render.
  72391. */
  72392. renderingGroupId: number;
  72393. /**
  72394. * The layer mask we are rendering the particles through.
  72395. */
  72396. layerMask: number;
  72397. /**
  72398. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  72399. */
  72400. updateSpeed: number;
  72401. /**
  72402. * The amount of time the particle system is running (depends of the overall update speed).
  72403. */
  72404. targetStopDuration: number;
  72405. /**
  72406. * The texture used to render each particle. (this can be a spritesheet)
  72407. */
  72408. particleTexture: Nullable<Texture>;
  72409. /**
  72410. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  72411. */
  72412. blendMode: number;
  72413. /**
  72414. * Minimum life time of emitting particles.
  72415. */
  72416. minLifeTime: number;
  72417. /**
  72418. * Maximum life time of emitting particles.
  72419. */
  72420. maxLifeTime: number;
  72421. /**
  72422. * Minimum Size of emitting particles.
  72423. */
  72424. minSize: number;
  72425. /**
  72426. * Maximum Size of emitting particles.
  72427. */
  72428. maxSize: number;
  72429. /**
  72430. * Minimum scale of emitting particles on X axis.
  72431. */
  72432. minScaleX: number;
  72433. /**
  72434. * Maximum scale of emitting particles on X axis.
  72435. */
  72436. maxScaleX: number;
  72437. /**
  72438. * Minimum scale of emitting particles on Y axis.
  72439. */
  72440. minScaleY: number;
  72441. /**
  72442. * Maximum scale of emitting particles on Y axis.
  72443. */
  72444. maxScaleY: number;
  72445. /**
  72446. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  72447. */
  72448. color1: Color4;
  72449. /**
  72450. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  72451. */
  72452. color2: Color4;
  72453. /**
  72454. * Color the particle will have at the end of its lifetime.
  72455. */
  72456. colorDead: Color4;
  72457. /**
  72458. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  72459. */
  72460. emitRate: number;
  72461. /**
  72462. * You can use gravity if you want to give an orientation to your particles.
  72463. */
  72464. gravity: Vector3;
  72465. /**
  72466. * Minimum power of emitting particles.
  72467. */
  72468. minEmitPower: number;
  72469. /**
  72470. * Maximum power of emitting particles.
  72471. */
  72472. maxEmitPower: number;
  72473. /**
  72474. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  72475. */
  72476. minAngularSpeed: number;
  72477. /**
  72478. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  72479. */
  72480. maxAngularSpeed: number;
  72481. /**
  72482. * Gets or sets the minimal initial rotation in radians.
  72483. */
  72484. minInitialRotation: number;
  72485. /**
  72486. * Gets or sets the maximal initial rotation in radians.
  72487. */
  72488. maxInitialRotation: number;
  72489. /**
  72490. * The particle emitter type defines the emitter used by the particle system.
  72491. * It can be for example box, sphere, or cone...
  72492. */
  72493. particleEmitterType: Nullable<IParticleEmitterType>;
  72494. /**
  72495. * Defines the delay in milliseconds before starting the system (0 by default)
  72496. */
  72497. startDelay: number;
  72498. /**
  72499. * 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
  72500. */
  72501. preWarmCycles: number;
  72502. /**
  72503. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  72504. */
  72505. preWarmStepOffset: number;
  72506. /**
  72507. * 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)
  72508. */
  72509. spriteCellChangeSpeed: number;
  72510. /**
  72511. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  72512. */
  72513. startSpriteCellID: number;
  72514. /**
  72515. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  72516. */
  72517. endSpriteCellID: number;
  72518. /**
  72519. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  72520. */
  72521. spriteCellWidth: number;
  72522. /**
  72523. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  72524. */
  72525. spriteCellHeight: number;
  72526. /**
  72527. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  72528. */
  72529. spriteRandomStartCell: boolean;
  72530. /**
  72531. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  72532. */
  72533. isAnimationSheetEnabled: boolean;
  72534. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  72535. translationPivot: Vector2;
  72536. /**
  72537. * Gets or sets a texture used to add random noise to particle positions
  72538. */
  72539. noiseTexture: Nullable<BaseTexture>;
  72540. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  72541. noiseStrength: Vector3;
  72542. /**
  72543. * Gets or sets the billboard mode to use when isBillboardBased = true.
  72544. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  72545. */
  72546. billboardMode: number;
  72547. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  72548. limitVelocityDamping: number;
  72549. /**
  72550. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  72551. */
  72552. beginAnimationOnStart: boolean;
  72553. /**
  72554. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  72555. */
  72556. beginAnimationFrom: number;
  72557. /**
  72558. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  72559. */
  72560. beginAnimationTo: number;
  72561. /**
  72562. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  72563. */
  72564. beginAnimationLoop: boolean;
  72565. /**
  72566. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  72567. */
  72568. disposeOnStop: boolean;
  72569. /**
  72570. * Gets the maximum number of particles active at the same time.
  72571. * @returns The max number of active particles.
  72572. */
  72573. getCapacity(): number;
  72574. /**
  72575. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72576. * @returns True if it has been started, otherwise false.
  72577. */
  72578. isStarted(): boolean;
  72579. /**
  72580. * Animates the particle system for this frame.
  72581. */
  72582. animate(): void;
  72583. /**
  72584. * Renders the particle system in its current state.
  72585. * @returns the current number of particles
  72586. */
  72587. render(): number;
  72588. /**
  72589. * Dispose the particle system and frees its associated resources.
  72590. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72591. */
  72592. dispose(disposeTexture?: boolean): void;
  72593. /**
  72594. * Clones the particle system.
  72595. * @param name The name of the cloned object
  72596. * @param newEmitter The new emitter to use
  72597. * @returns the cloned particle system
  72598. */
  72599. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  72600. /**
  72601. * Serializes the particle system to a JSON object.
  72602. * @returns the JSON object
  72603. */
  72604. serialize(): any;
  72605. /**
  72606. * Rebuild the particle system
  72607. */
  72608. rebuild(): void;
  72609. /**
  72610. * Starts the particle system and begins to emit
  72611. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  72612. */
  72613. start(delay?: number): void;
  72614. /**
  72615. * Stops the particle system.
  72616. */
  72617. stop(): void;
  72618. /**
  72619. * Remove all active particles
  72620. */
  72621. reset(): void;
  72622. /**
  72623. * Is this system ready to be used/rendered
  72624. * @return true if the system is ready
  72625. */
  72626. isReady(): boolean;
  72627. /**
  72628. * Adds a new color gradient
  72629. * @param gradient defines the gradient to use (between 0 and 1)
  72630. * @param color1 defines the color to affect to the specified gradient
  72631. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72632. * @returns the current particle system
  72633. */
  72634. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  72635. /**
  72636. * Remove a specific color gradient
  72637. * @param gradient defines the gradient to remove
  72638. * @returns the current particle system
  72639. */
  72640. removeColorGradient(gradient: number): IParticleSystem;
  72641. /**
  72642. * Adds a new size gradient
  72643. * @param gradient defines the gradient to use (between 0 and 1)
  72644. * @param factor defines the size factor to affect to the specified gradient
  72645. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72646. * @returns the current particle system
  72647. */
  72648. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72649. /**
  72650. * Remove a specific size gradient
  72651. * @param gradient defines the gradient to remove
  72652. * @returns the current particle system
  72653. */
  72654. removeSizeGradient(gradient: number): IParticleSystem;
  72655. /**
  72656. * Gets the current list of color gradients.
  72657. * You must use addColorGradient and removeColorGradient to udpate this list
  72658. * @returns the list of color gradients
  72659. */
  72660. getColorGradients(): Nullable<Array<ColorGradient>>;
  72661. /**
  72662. * Gets the current list of size gradients.
  72663. * You must use addSizeGradient and removeSizeGradient to udpate this list
  72664. * @returns the list of size gradients
  72665. */
  72666. getSizeGradients(): Nullable<Array<FactorGradient>>;
  72667. /**
  72668. * Gets the current list of angular speed gradients.
  72669. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  72670. * @returns the list of angular speed gradients
  72671. */
  72672. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  72673. /**
  72674. * Adds a new angular speed gradient
  72675. * @param gradient defines the gradient to use (between 0 and 1)
  72676. * @param factor defines the angular speed to affect to the specified gradient
  72677. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72678. * @returns the current particle system
  72679. */
  72680. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72681. /**
  72682. * Remove a specific angular speed gradient
  72683. * @param gradient defines the gradient to remove
  72684. * @returns the current particle system
  72685. */
  72686. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  72687. /**
  72688. * Gets the current list of velocity gradients.
  72689. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  72690. * @returns the list of velocity gradients
  72691. */
  72692. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  72693. /**
  72694. * Adds a new velocity gradient
  72695. * @param gradient defines the gradient to use (between 0 and 1)
  72696. * @param factor defines the velocity to affect to the specified gradient
  72697. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72698. * @returns the current particle system
  72699. */
  72700. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72701. /**
  72702. * Remove a specific velocity gradient
  72703. * @param gradient defines the gradient to remove
  72704. * @returns the current particle system
  72705. */
  72706. removeVelocityGradient(gradient: number): IParticleSystem;
  72707. /**
  72708. * Gets the current list of limit velocity gradients.
  72709. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  72710. * @returns the list of limit velocity gradients
  72711. */
  72712. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  72713. /**
  72714. * Adds a new limit velocity gradient
  72715. * @param gradient defines the gradient to use (between 0 and 1)
  72716. * @param factor defines the limit velocity to affect to the specified gradient
  72717. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72718. * @returns the current particle system
  72719. */
  72720. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72721. /**
  72722. * Remove a specific limit velocity gradient
  72723. * @param gradient defines the gradient to remove
  72724. * @returns the current particle system
  72725. */
  72726. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  72727. /**
  72728. * Adds a new drag gradient
  72729. * @param gradient defines the gradient to use (between 0 and 1)
  72730. * @param factor defines the drag to affect to the specified gradient
  72731. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72732. * @returns the current particle system
  72733. */
  72734. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72735. /**
  72736. * Remove a specific drag gradient
  72737. * @param gradient defines the gradient to remove
  72738. * @returns the current particle system
  72739. */
  72740. removeDragGradient(gradient: number): IParticleSystem;
  72741. /**
  72742. * Gets the current list of drag gradients.
  72743. * You must use addDragGradient and removeDragGradient to udpate this list
  72744. * @returns the list of drag gradients
  72745. */
  72746. getDragGradients(): Nullable<Array<FactorGradient>>;
  72747. /**
  72748. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  72749. * @param gradient defines the gradient to use (between 0 and 1)
  72750. * @param factor defines the emit rate to affect to the specified gradient
  72751. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72752. * @returns the current particle system
  72753. */
  72754. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72755. /**
  72756. * Remove a specific emit rate gradient
  72757. * @param gradient defines the gradient to remove
  72758. * @returns the current particle system
  72759. */
  72760. removeEmitRateGradient(gradient: number): IParticleSystem;
  72761. /**
  72762. * Gets the current list of emit rate gradients.
  72763. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  72764. * @returns the list of emit rate gradients
  72765. */
  72766. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  72767. /**
  72768. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  72769. * @param gradient defines the gradient to use (between 0 and 1)
  72770. * @param factor defines the start size to affect to the specified gradient
  72771. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72772. * @returns the current particle system
  72773. */
  72774. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72775. /**
  72776. * Remove a specific start size gradient
  72777. * @param gradient defines the gradient to remove
  72778. * @returns the current particle system
  72779. */
  72780. removeStartSizeGradient(gradient: number): IParticleSystem;
  72781. /**
  72782. * Gets the current list of start size gradients.
  72783. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  72784. * @returns the list of start size gradients
  72785. */
  72786. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  72787. /**
  72788. * Adds a new life time gradient
  72789. * @param gradient defines the gradient to use (between 0 and 1)
  72790. * @param factor defines the life time factor to affect to the specified gradient
  72791. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72792. * @returns the current particle system
  72793. */
  72794. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72795. /**
  72796. * Remove a specific life time gradient
  72797. * @param gradient defines the gradient to remove
  72798. * @returns the current particle system
  72799. */
  72800. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72801. /**
  72802. * Gets the current list of life time gradients.
  72803. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  72804. * @returns the list of life time gradients
  72805. */
  72806. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  72807. /**
  72808. * Gets the current list of color gradients.
  72809. * You must use addColorGradient and removeColorGradient to udpate this list
  72810. * @returns the list of color gradients
  72811. */
  72812. getColorGradients(): Nullable<Array<ColorGradient>>;
  72813. /**
  72814. * Adds a new ramp gradient used to remap particle colors
  72815. * @param gradient defines the gradient to use (between 0 and 1)
  72816. * @param color defines the color to affect to the specified gradient
  72817. * @returns the current particle system
  72818. */
  72819. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72820. /**
  72821. * Gets the current list of ramp gradients.
  72822. * You must use addRampGradient and removeRampGradient to udpate this list
  72823. * @returns the list of ramp gradients
  72824. */
  72825. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72826. /** Gets or sets a boolean indicating that ramp gradients must be used
  72827. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72828. */
  72829. useRampGradients: boolean;
  72830. /**
  72831. * Adds a new color remap gradient
  72832. * @param gradient defines the gradient to use (between 0 and 1)
  72833. * @param min defines the color remap minimal range
  72834. * @param max defines the color remap maximal range
  72835. * @returns the current particle system
  72836. */
  72837. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72838. /**
  72839. * Gets the current list of color remap gradients.
  72840. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  72841. * @returns the list of color remap gradients
  72842. */
  72843. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  72844. /**
  72845. * Adds a new alpha remap gradient
  72846. * @param gradient defines the gradient to use (between 0 and 1)
  72847. * @param min defines the alpha remap minimal range
  72848. * @param max defines the alpha remap maximal range
  72849. * @returns the current particle system
  72850. */
  72851. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72852. /**
  72853. * Gets the current list of alpha remap gradients.
  72854. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  72855. * @returns the list of alpha remap gradients
  72856. */
  72857. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  72858. /**
  72859. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  72860. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72861. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72862. * @returns the emitter
  72863. */
  72864. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  72865. /**
  72866. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  72867. * @param radius The radius of the hemisphere to emit from
  72868. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72869. * @returns the emitter
  72870. */
  72871. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  72872. /**
  72873. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  72874. * @param radius The radius of the sphere to emit from
  72875. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72876. * @returns the emitter
  72877. */
  72878. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  72879. /**
  72880. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  72881. * @param radius The radius of the sphere to emit from
  72882. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  72883. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  72884. * @returns the emitter
  72885. */
  72886. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  72887. /**
  72888. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  72889. * @param radius The radius of the emission cylinder
  72890. * @param height The height of the emission cylinder
  72891. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  72892. * @param directionRandomizer How much to randomize the particle direction [0-1]
  72893. * @returns the emitter
  72894. */
  72895. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  72896. /**
  72897. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  72898. * @param radius The radius of the cylinder to emit from
  72899. * @param height The height of the emission cylinder
  72900. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72901. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  72902. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  72903. * @returns the emitter
  72904. */
  72905. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  72906. /**
  72907. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  72908. * @param radius The radius of the cone to emit from
  72909. * @param angle The base angle of the cone
  72910. * @returns the emitter
  72911. */
  72912. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  72913. /**
  72914. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  72915. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72916. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72917. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72918. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72919. * @returns the emitter
  72920. */
  72921. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  72922. /**
  72923. * Get hosting scene
  72924. * @returns the scene
  72925. */
  72926. getScene(): Scene;
  72927. }
  72928. }
  72929. declare module BABYLON {
  72930. /** @hidden */
  72931. export var linePixelShader: {
  72932. name: string;
  72933. shader: string;
  72934. };
  72935. }
  72936. declare module BABYLON {
  72937. /** @hidden */
  72938. export var lineVertexShader: {
  72939. name: string;
  72940. shader: string;
  72941. };
  72942. }
  72943. declare module BABYLON {
  72944. interface AbstractMesh {
  72945. /**
  72946. * Disables the mesh edge rendering mode
  72947. * @returns the currentAbstractMesh
  72948. */
  72949. disableEdgesRendering(): AbstractMesh;
  72950. /**
  72951. * Enables the edge rendering mode on the mesh.
  72952. * This mode makes the mesh edges visible
  72953. * @param epsilon defines the maximal distance between two angles to detect a face
  72954. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  72955. * @returns the currentAbstractMesh
  72956. * @see https://www.babylonjs-playground.com/#19O9TU#0
  72957. */
  72958. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  72959. /**
  72960. * Gets the edgesRenderer associated with the mesh
  72961. */
  72962. edgesRenderer: Nullable<EdgesRenderer>;
  72963. }
  72964. interface LinesMesh {
  72965. /**
  72966. * Enables the edge rendering mode on the mesh.
  72967. * This mode makes the mesh edges visible
  72968. * @param epsilon defines the maximal distance between two angles to detect a face
  72969. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  72970. * @returns the currentAbstractMesh
  72971. * @see https://www.babylonjs-playground.com/#19O9TU#0
  72972. */
  72973. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  72974. }
  72975. interface InstancedLinesMesh {
  72976. /**
  72977. * Enables the edge rendering mode on the mesh.
  72978. * This mode makes the mesh edges visible
  72979. * @param epsilon defines the maximal distance between two angles to detect a face
  72980. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  72981. * @returns the current InstancedLinesMesh
  72982. * @see https://www.babylonjs-playground.com/#19O9TU#0
  72983. */
  72984. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  72985. }
  72986. /**
  72987. * Defines the minimum contract an Edges renderer should follow.
  72988. */
  72989. export interface IEdgesRenderer extends IDisposable {
  72990. /**
  72991. * Gets or sets a boolean indicating if the edgesRenderer is active
  72992. */
  72993. isEnabled: boolean;
  72994. /**
  72995. * Renders the edges of the attached mesh,
  72996. */
  72997. render(): void;
  72998. /**
  72999. * Checks wether or not the edges renderer is ready to render.
  73000. * @return true if ready, otherwise false.
  73001. */
  73002. isReady(): boolean;
  73003. }
  73004. /**
  73005. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  73006. */
  73007. export class EdgesRenderer implements IEdgesRenderer {
  73008. /**
  73009. * Define the size of the edges with an orthographic camera
  73010. */
  73011. edgesWidthScalerForOrthographic: number;
  73012. /**
  73013. * Define the size of the edges with a perspective camera
  73014. */
  73015. edgesWidthScalerForPerspective: number;
  73016. protected _source: AbstractMesh;
  73017. protected _linesPositions: number[];
  73018. protected _linesNormals: number[];
  73019. protected _linesIndices: number[];
  73020. protected _epsilon: number;
  73021. protected _indicesCount: number;
  73022. protected _lineShader: ShaderMaterial;
  73023. protected _ib: WebGLBuffer;
  73024. protected _buffers: {
  73025. [key: string]: Nullable<VertexBuffer>;
  73026. };
  73027. protected _checkVerticesInsteadOfIndices: boolean;
  73028. private _meshRebuildObserver;
  73029. private _meshDisposeObserver;
  73030. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  73031. isEnabled: boolean;
  73032. /**
  73033. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  73034. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  73035. * @param source Mesh used to create edges
  73036. * @param epsilon sum of angles in adjacency to check for edge
  73037. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  73038. * @param generateEdgesLines - should generate Lines or only prepare resources.
  73039. */
  73040. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  73041. protected _prepareRessources(): void;
  73042. /** @hidden */
  73043. _rebuild(): void;
  73044. /**
  73045. * Releases the required resources for the edges renderer
  73046. */
  73047. dispose(): void;
  73048. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  73049. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  73050. /**
  73051. * Checks if the pair of p0 and p1 is en edge
  73052. * @param faceIndex
  73053. * @param edge
  73054. * @param faceNormals
  73055. * @param p0
  73056. * @param p1
  73057. * @private
  73058. */
  73059. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  73060. /**
  73061. * push line into the position, normal and index buffer
  73062. * @protected
  73063. */
  73064. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  73065. /**
  73066. * Generates lines edges from adjacencjes
  73067. * @private
  73068. */
  73069. _generateEdgesLines(): void;
  73070. /**
  73071. * Checks wether or not the edges renderer is ready to render.
  73072. * @return true if ready, otherwise false.
  73073. */
  73074. isReady(): boolean;
  73075. /**
  73076. * Renders the edges of the attached mesh,
  73077. */
  73078. render(): void;
  73079. }
  73080. /**
  73081. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  73082. */
  73083. export class LineEdgesRenderer extends EdgesRenderer {
  73084. /**
  73085. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  73086. * @param source LineMesh used to generate edges
  73087. * @param epsilon not important (specified angle for edge detection)
  73088. * @param checkVerticesInsteadOfIndices not important for LineMesh
  73089. */
  73090. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  73091. /**
  73092. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  73093. */
  73094. _generateEdgesLines(): void;
  73095. }
  73096. }
  73097. declare module BABYLON {
  73098. /**
  73099. * This represents the object necessary to create a rendering group.
  73100. * This is exclusively used and created by the rendering manager.
  73101. * To modify the behavior, you use the available helpers in your scene or meshes.
  73102. * @hidden
  73103. */
  73104. export class RenderingGroup {
  73105. index: number;
  73106. private _scene;
  73107. private _opaqueSubMeshes;
  73108. private _transparentSubMeshes;
  73109. private _alphaTestSubMeshes;
  73110. private _depthOnlySubMeshes;
  73111. private _particleSystems;
  73112. private _spriteManagers;
  73113. private _opaqueSortCompareFn;
  73114. private _alphaTestSortCompareFn;
  73115. private _transparentSortCompareFn;
  73116. private _renderOpaque;
  73117. private _renderAlphaTest;
  73118. private _renderTransparent;
  73119. private _edgesRenderers;
  73120. onBeforeTransparentRendering: () => void;
  73121. /**
  73122. * Set the opaque sort comparison function.
  73123. * If null the sub meshes will be render in the order they were created
  73124. */
  73125. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73126. /**
  73127. * Set the alpha test sort comparison function.
  73128. * If null the sub meshes will be render in the order they were created
  73129. */
  73130. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73131. /**
  73132. * Set the transparent sort comparison function.
  73133. * If null the sub meshes will be render in the order they were created
  73134. */
  73135. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73136. /**
  73137. * Creates a new rendering group.
  73138. * @param index The rendering group index
  73139. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  73140. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  73141. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  73142. */
  73143. 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>);
  73144. /**
  73145. * Render all the sub meshes contained in the group.
  73146. * @param customRenderFunction Used to override the default render behaviour of the group.
  73147. * @returns true if rendered some submeshes.
  73148. */
  73149. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  73150. /**
  73151. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  73152. * @param subMeshes The submeshes to render
  73153. */
  73154. private renderOpaqueSorted;
  73155. /**
  73156. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  73157. * @param subMeshes The submeshes to render
  73158. */
  73159. private renderAlphaTestSorted;
  73160. /**
  73161. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  73162. * @param subMeshes The submeshes to render
  73163. */
  73164. private renderTransparentSorted;
  73165. /**
  73166. * Renders the submeshes in a specified order.
  73167. * @param subMeshes The submeshes to sort before render
  73168. * @param sortCompareFn The comparison function use to sort
  73169. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  73170. * @param transparent Specifies to activate blending if true
  73171. */
  73172. private static renderSorted;
  73173. /**
  73174. * Renders the submeshes in the order they were dispatched (no sort applied).
  73175. * @param subMeshes The submeshes to render
  73176. */
  73177. private static renderUnsorted;
  73178. /**
  73179. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73180. * are rendered back to front if in the same alpha index.
  73181. *
  73182. * @param a The first submesh
  73183. * @param b The second submesh
  73184. * @returns The result of the comparison
  73185. */
  73186. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  73187. /**
  73188. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73189. * are rendered back to front.
  73190. *
  73191. * @param a The first submesh
  73192. * @param b The second submesh
  73193. * @returns The result of the comparison
  73194. */
  73195. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  73196. /**
  73197. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73198. * are rendered front to back (prevent overdraw).
  73199. *
  73200. * @param a The first submesh
  73201. * @param b The second submesh
  73202. * @returns The result of the comparison
  73203. */
  73204. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  73205. /**
  73206. * Resets the different lists of submeshes to prepare a new frame.
  73207. */
  73208. prepare(): void;
  73209. dispose(): void;
  73210. /**
  73211. * Inserts the submesh in its correct queue depending on its material.
  73212. * @param subMesh The submesh to dispatch
  73213. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  73214. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  73215. */
  73216. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  73217. dispatchSprites(spriteManager: ISpriteManager): void;
  73218. dispatchParticles(particleSystem: IParticleSystem): void;
  73219. private _renderParticles;
  73220. private _renderSprites;
  73221. }
  73222. }
  73223. declare module BABYLON {
  73224. /**
  73225. * Interface describing the different options available in the rendering manager
  73226. * regarding Auto Clear between groups.
  73227. */
  73228. export interface IRenderingManagerAutoClearSetup {
  73229. /**
  73230. * Defines whether or not autoclear is enable.
  73231. */
  73232. autoClear: boolean;
  73233. /**
  73234. * Defines whether or not to autoclear the depth buffer.
  73235. */
  73236. depth: boolean;
  73237. /**
  73238. * Defines whether or not to autoclear the stencil buffer.
  73239. */
  73240. stencil: boolean;
  73241. }
  73242. /**
  73243. * This class is used by the onRenderingGroupObservable
  73244. */
  73245. export class RenderingGroupInfo {
  73246. /**
  73247. * The Scene that being rendered
  73248. */
  73249. scene: Scene;
  73250. /**
  73251. * The camera currently used for the rendering pass
  73252. */
  73253. camera: Nullable<Camera>;
  73254. /**
  73255. * The ID of the renderingGroup being processed
  73256. */
  73257. renderingGroupId: number;
  73258. }
  73259. /**
  73260. * This is the manager responsible of all the rendering for meshes sprites and particles.
  73261. * It is enable to manage the different groups as well as the different necessary sort functions.
  73262. * This should not be used directly aside of the few static configurations
  73263. */
  73264. export class RenderingManager {
  73265. /**
  73266. * The max id used for rendering groups (not included)
  73267. */
  73268. static MAX_RENDERINGGROUPS: number;
  73269. /**
  73270. * The min id used for rendering groups (included)
  73271. */
  73272. static MIN_RENDERINGGROUPS: number;
  73273. /**
  73274. * Used to globally prevent autoclearing scenes.
  73275. */
  73276. static AUTOCLEAR: boolean;
  73277. /**
  73278. * @hidden
  73279. */
  73280. _useSceneAutoClearSetup: boolean;
  73281. private _scene;
  73282. private _renderingGroups;
  73283. private _depthStencilBufferAlreadyCleaned;
  73284. private _autoClearDepthStencil;
  73285. private _customOpaqueSortCompareFn;
  73286. private _customAlphaTestSortCompareFn;
  73287. private _customTransparentSortCompareFn;
  73288. private _renderingGroupInfo;
  73289. /**
  73290. * Instantiates a new rendering group for a particular scene
  73291. * @param scene Defines the scene the groups belongs to
  73292. */
  73293. constructor(scene: Scene);
  73294. private _clearDepthStencilBuffer;
  73295. /**
  73296. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  73297. * @hidden
  73298. */
  73299. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  73300. /**
  73301. * Resets the different information of the group to prepare a new frame
  73302. * @hidden
  73303. */
  73304. reset(): void;
  73305. /**
  73306. * Dispose and release the group and its associated resources.
  73307. * @hidden
  73308. */
  73309. dispose(): void;
  73310. /**
  73311. * Clear the info related to rendering groups preventing retention points during dispose.
  73312. */
  73313. freeRenderingGroups(): void;
  73314. private _prepareRenderingGroup;
  73315. /**
  73316. * Add a sprite manager to the rendering manager in order to render it this frame.
  73317. * @param spriteManager Define the sprite manager to render
  73318. */
  73319. dispatchSprites(spriteManager: ISpriteManager): void;
  73320. /**
  73321. * Add a particle system to the rendering manager in order to render it this frame.
  73322. * @param particleSystem Define the particle system to render
  73323. */
  73324. dispatchParticles(particleSystem: IParticleSystem): void;
  73325. /**
  73326. * Add a submesh to the manager in order to render it this frame
  73327. * @param subMesh The submesh to dispatch
  73328. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  73329. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  73330. */
  73331. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  73332. /**
  73333. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  73334. * This allowed control for front to back rendering or reversly depending of the special needs.
  73335. *
  73336. * @param renderingGroupId The rendering group id corresponding to its index
  73337. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  73338. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  73339. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  73340. */
  73341. 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;
  73342. /**
  73343. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  73344. *
  73345. * @param renderingGroupId The rendering group id corresponding to its index
  73346. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  73347. * @param depth Automatically clears depth between groups if true and autoClear is true.
  73348. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  73349. */
  73350. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  73351. /**
  73352. * Gets the current auto clear configuration for one rendering group of the rendering
  73353. * manager.
  73354. * @param index the rendering group index to get the information for
  73355. * @returns The auto clear setup for the requested rendering group
  73356. */
  73357. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  73358. }
  73359. }
  73360. declare module BABYLON {
  73361. /**
  73362. * This Helps creating a texture that will be created from a camera in your scene.
  73363. * It is basically a dynamic texture that could be used to create special effects for instance.
  73364. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  73365. */
  73366. export class RenderTargetTexture extends Texture {
  73367. isCube: boolean;
  73368. /**
  73369. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  73370. */
  73371. static readonly REFRESHRATE_RENDER_ONCE: number;
  73372. /**
  73373. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  73374. */
  73375. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  73376. /**
  73377. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  73378. * the central point of your effect and can save a lot of performances.
  73379. */
  73380. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  73381. /**
  73382. * Use this predicate to dynamically define the list of mesh you want to render.
  73383. * If set, the renderList property will be overwritten.
  73384. */
  73385. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  73386. private _renderList;
  73387. /**
  73388. * Use this list to define the list of mesh you want to render.
  73389. */
  73390. renderList: Nullable<Array<AbstractMesh>>;
  73391. private _hookArray;
  73392. /**
  73393. * Define if particles should be rendered in your texture.
  73394. */
  73395. renderParticles: boolean;
  73396. /**
  73397. * Define if sprites should be rendered in your texture.
  73398. */
  73399. renderSprites: boolean;
  73400. /**
  73401. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  73402. */
  73403. coordinatesMode: number;
  73404. /**
  73405. * Define the camera used to render the texture.
  73406. */
  73407. activeCamera: Nullable<Camera>;
  73408. /**
  73409. * Override the render function of the texture with your own one.
  73410. */
  73411. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  73412. /**
  73413. * Define if camera post processes should be use while rendering the texture.
  73414. */
  73415. useCameraPostProcesses: boolean;
  73416. /**
  73417. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  73418. */
  73419. ignoreCameraViewport: boolean;
  73420. private _postProcessManager;
  73421. private _postProcesses;
  73422. private _resizeObserver;
  73423. /**
  73424. * An event triggered when the texture is unbind.
  73425. */
  73426. onBeforeBindObservable: Observable<RenderTargetTexture>;
  73427. /**
  73428. * An event triggered when the texture is unbind.
  73429. */
  73430. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  73431. private _onAfterUnbindObserver;
  73432. /**
  73433. * Set a after unbind callback in the texture.
  73434. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  73435. */
  73436. onAfterUnbind: () => void;
  73437. /**
  73438. * An event triggered before rendering the texture
  73439. */
  73440. onBeforeRenderObservable: Observable<number>;
  73441. private _onBeforeRenderObserver;
  73442. /**
  73443. * Set a before render callback in the texture.
  73444. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  73445. */
  73446. onBeforeRender: (faceIndex: number) => void;
  73447. /**
  73448. * An event triggered after rendering the texture
  73449. */
  73450. onAfterRenderObservable: Observable<number>;
  73451. private _onAfterRenderObserver;
  73452. /**
  73453. * Set a after render callback in the texture.
  73454. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  73455. */
  73456. onAfterRender: (faceIndex: number) => void;
  73457. /**
  73458. * An event triggered after the texture clear
  73459. */
  73460. onClearObservable: Observable<Engine>;
  73461. private _onClearObserver;
  73462. /**
  73463. * Set a clear callback in the texture.
  73464. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  73465. */
  73466. onClear: (Engine: Engine) => void;
  73467. /**
  73468. * Define the clear color of the Render Target if it should be different from the scene.
  73469. */
  73470. clearColor: Color4;
  73471. protected _size: number | {
  73472. width: number;
  73473. height: number;
  73474. };
  73475. protected _initialSizeParameter: number | {
  73476. width: number;
  73477. height: number;
  73478. } | {
  73479. ratio: number;
  73480. };
  73481. protected _sizeRatio: Nullable<number>;
  73482. /** @hidden */
  73483. _generateMipMaps: boolean;
  73484. protected _renderingManager: RenderingManager;
  73485. /** @hidden */
  73486. _waitingRenderList: string[];
  73487. protected _doNotChangeAspectRatio: boolean;
  73488. protected _currentRefreshId: number;
  73489. protected _refreshRate: number;
  73490. protected _textureMatrix: Matrix;
  73491. protected _samples: number;
  73492. protected _renderTargetOptions: RenderTargetCreationOptions;
  73493. /**
  73494. * Gets render target creation options that were used.
  73495. */
  73496. readonly renderTargetOptions: RenderTargetCreationOptions;
  73497. protected _engine: Engine;
  73498. protected _onRatioRescale(): void;
  73499. /**
  73500. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  73501. * It must define where the camera used to render the texture is set
  73502. */
  73503. boundingBoxPosition: Vector3;
  73504. private _boundingBoxSize;
  73505. /**
  73506. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  73507. * When defined, the cubemap will switch to local mode
  73508. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  73509. * @example https://www.babylonjs-playground.com/#RNASML
  73510. */
  73511. boundingBoxSize: Vector3;
  73512. /**
  73513. * In case the RTT has been created with a depth texture, get the associated
  73514. * depth texture.
  73515. * Otherwise, return null.
  73516. */
  73517. depthStencilTexture: Nullable<InternalTexture>;
  73518. /**
  73519. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  73520. * or used a shadow, depth texture...
  73521. * @param name The friendly name of the texture
  73522. * @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)
  73523. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  73524. * @param generateMipMaps True if mip maps need to be generated after render.
  73525. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  73526. * @param type The type of the buffer in the RTT (int, half float, float...)
  73527. * @param isCube True if a cube texture needs to be created
  73528. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  73529. * @param generateDepthBuffer True to generate a depth buffer
  73530. * @param generateStencilBuffer True to generate a stencil buffer
  73531. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  73532. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  73533. * @param delayAllocation if the texture allocation should be delayed (default: false)
  73534. */
  73535. constructor(name: string, size: number | {
  73536. width: number;
  73537. height: number;
  73538. } | {
  73539. ratio: number;
  73540. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  73541. /**
  73542. * Creates a depth stencil texture.
  73543. * This is only available in WebGL 2 or with the depth texture extension available.
  73544. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  73545. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  73546. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  73547. */
  73548. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  73549. private _processSizeParameter;
  73550. /**
  73551. * Define the number of samples to use in case of MSAA.
  73552. * It defaults to one meaning no MSAA has been enabled.
  73553. */
  73554. samples: number;
  73555. /**
  73556. * Resets the refresh counter of the texture and start bak from scratch.
  73557. * Could be useful to regenerate the texture if it is setup to render only once.
  73558. */
  73559. resetRefreshCounter(): void;
  73560. /**
  73561. * Define the refresh rate of the texture or the rendering frequency.
  73562. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  73563. */
  73564. refreshRate: number;
  73565. /**
  73566. * Adds a post process to the render target rendering passes.
  73567. * @param postProcess define the post process to add
  73568. */
  73569. addPostProcess(postProcess: PostProcess): void;
  73570. /**
  73571. * Clear all the post processes attached to the render target
  73572. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  73573. */
  73574. clearPostProcesses(dispose?: boolean): void;
  73575. /**
  73576. * Remove one of the post process from the list of attached post processes to the texture
  73577. * @param postProcess define the post process to remove from the list
  73578. */
  73579. removePostProcess(postProcess: PostProcess): void;
  73580. /** @hidden */
  73581. _shouldRender(): boolean;
  73582. /**
  73583. * Gets the actual render size of the texture.
  73584. * @returns the width of the render size
  73585. */
  73586. getRenderSize(): number;
  73587. /**
  73588. * Gets the actual render width of the texture.
  73589. * @returns the width of the render size
  73590. */
  73591. getRenderWidth(): number;
  73592. /**
  73593. * Gets the actual render height of the texture.
  73594. * @returns the height of the render size
  73595. */
  73596. getRenderHeight(): number;
  73597. /**
  73598. * Get if the texture can be rescaled or not.
  73599. */
  73600. readonly canRescale: boolean;
  73601. /**
  73602. * Resize the texture using a ratio.
  73603. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  73604. */
  73605. scale(ratio: number): void;
  73606. /**
  73607. * Get the texture reflection matrix used to rotate/transform the reflection.
  73608. * @returns the reflection matrix
  73609. */
  73610. getReflectionTextureMatrix(): Matrix;
  73611. /**
  73612. * Resize the texture to a new desired size.
  73613. * Be carrefull as it will recreate all the data in the new texture.
  73614. * @param size Define the new size. It can be:
  73615. * - a number for squared texture,
  73616. * - an object containing { width: number, height: number }
  73617. * - or an object containing a ratio { ratio: number }
  73618. */
  73619. resize(size: number | {
  73620. width: number;
  73621. height: number;
  73622. } | {
  73623. ratio: number;
  73624. }): void;
  73625. /**
  73626. * Renders all the objects from the render list into the texture.
  73627. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  73628. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  73629. */
  73630. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  73631. private _bestReflectionRenderTargetDimension;
  73632. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  73633. private renderToTarget;
  73634. /**
  73635. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  73636. * This allowed control for front to back rendering or reversly depending of the special needs.
  73637. *
  73638. * @param renderingGroupId The rendering group id corresponding to its index
  73639. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  73640. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  73641. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  73642. */
  73643. 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;
  73644. /**
  73645. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  73646. *
  73647. * @param renderingGroupId The rendering group id corresponding to its index
  73648. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  73649. */
  73650. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  73651. /**
  73652. * Clones the texture.
  73653. * @returns the cloned texture
  73654. */
  73655. clone(): RenderTargetTexture;
  73656. /**
  73657. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  73658. * @returns The JSON representation of the texture
  73659. */
  73660. serialize(): any;
  73661. /**
  73662. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  73663. */
  73664. disposeFramebufferObjects(): void;
  73665. /**
  73666. * Dispose the texture and release its associated resources.
  73667. */
  73668. dispose(): void;
  73669. /** @hidden */
  73670. _rebuild(): void;
  73671. /**
  73672. * Clear the info related to rendering groups preventing retention point in material dispose.
  73673. */
  73674. freeRenderingGroups(): void;
  73675. }
  73676. }
  73677. declare module BABYLON {
  73678. /**
  73679. * Mirror texture can be used to simulate the view from a mirror in a scene.
  73680. * It will dynamically be rendered every frame to adapt to the camera point of view.
  73681. * You can then easily use it as a reflectionTexture on a flat surface.
  73682. * In case the surface is not a plane, please consider relying on reflection probes.
  73683. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  73684. */
  73685. export class MirrorTexture extends RenderTargetTexture {
  73686. private scene;
  73687. /**
  73688. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  73689. * 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.
  73690. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  73691. */
  73692. mirrorPlane: Plane;
  73693. /**
  73694. * Define the blur ratio used to blur the reflection if needed.
  73695. */
  73696. blurRatio: number;
  73697. /**
  73698. * Define the adaptive blur kernel used to blur the reflection if needed.
  73699. * This will autocompute the closest best match for the `blurKernel`
  73700. */
  73701. adaptiveBlurKernel: number;
  73702. /**
  73703. * Define the blur kernel used to blur the reflection if needed.
  73704. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  73705. */
  73706. blurKernel: number;
  73707. /**
  73708. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  73709. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  73710. */
  73711. blurKernelX: number;
  73712. /**
  73713. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  73714. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  73715. */
  73716. blurKernelY: number;
  73717. private _autoComputeBlurKernel;
  73718. protected _onRatioRescale(): void;
  73719. private _updateGammaSpace;
  73720. private _imageProcessingConfigChangeObserver;
  73721. private _transformMatrix;
  73722. private _mirrorMatrix;
  73723. private _savedViewMatrix;
  73724. private _blurX;
  73725. private _blurY;
  73726. private _adaptiveBlurKernel;
  73727. private _blurKernelX;
  73728. private _blurKernelY;
  73729. private _blurRatio;
  73730. /**
  73731. * Instantiates a Mirror Texture.
  73732. * Mirror texture can be used to simulate the view from a mirror in a scene.
  73733. * It will dynamically be rendered every frame to adapt to the camera point of view.
  73734. * You can then easily use it as a reflectionTexture on a flat surface.
  73735. * In case the surface is not a plane, please consider relying on reflection probes.
  73736. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  73737. * @param name
  73738. * @param size
  73739. * @param scene
  73740. * @param generateMipMaps
  73741. * @param type
  73742. * @param samplingMode
  73743. * @param generateDepthBuffer
  73744. */
  73745. constructor(name: string, size: number | {
  73746. width: number;
  73747. height: number;
  73748. } | {
  73749. ratio: number;
  73750. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  73751. private _preparePostProcesses;
  73752. /**
  73753. * Clone the mirror texture.
  73754. * @returns the cloned texture
  73755. */
  73756. clone(): MirrorTexture;
  73757. /**
  73758. * Serialize the texture to a JSON representation you could use in Parse later on
  73759. * @returns the serialized JSON representation
  73760. */
  73761. serialize(): any;
  73762. /**
  73763. * Dispose the texture and release its associated resources.
  73764. */
  73765. dispose(): void;
  73766. }
  73767. }
  73768. declare module BABYLON {
  73769. /**
  73770. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  73771. * @see http://doc.babylonjs.com/babylon101/materials#texture
  73772. */
  73773. export class Texture extends BaseTexture {
  73774. /** @hidden */
  73775. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  73776. /** @hidden */
  73777. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  73778. /** @hidden */
  73779. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  73780. /** nearest is mag = nearest and min = nearest and mip = linear */
  73781. static readonly NEAREST_SAMPLINGMODE: number;
  73782. /** nearest is mag = nearest and min = nearest and mip = linear */
  73783. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  73784. /** Bilinear is mag = linear and min = linear and mip = nearest */
  73785. static readonly BILINEAR_SAMPLINGMODE: number;
  73786. /** Bilinear is mag = linear and min = linear and mip = nearest */
  73787. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  73788. /** Trilinear is mag = linear and min = linear and mip = linear */
  73789. static readonly TRILINEAR_SAMPLINGMODE: number;
  73790. /** Trilinear is mag = linear and min = linear and mip = linear */
  73791. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  73792. /** mag = nearest and min = nearest and mip = nearest */
  73793. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  73794. /** mag = nearest and min = linear and mip = nearest */
  73795. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  73796. /** mag = nearest and min = linear and mip = linear */
  73797. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  73798. /** mag = nearest and min = linear and mip = none */
  73799. static readonly NEAREST_LINEAR: number;
  73800. /** mag = nearest and min = nearest and mip = none */
  73801. static readonly NEAREST_NEAREST: number;
  73802. /** mag = linear and min = nearest and mip = nearest */
  73803. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  73804. /** mag = linear and min = nearest and mip = linear */
  73805. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  73806. /** mag = linear and min = linear and mip = none */
  73807. static readonly LINEAR_LINEAR: number;
  73808. /** mag = linear and min = nearest and mip = none */
  73809. static readonly LINEAR_NEAREST: number;
  73810. /** Explicit coordinates mode */
  73811. static readonly EXPLICIT_MODE: number;
  73812. /** Spherical coordinates mode */
  73813. static readonly SPHERICAL_MODE: number;
  73814. /** Planar coordinates mode */
  73815. static readonly PLANAR_MODE: number;
  73816. /** Cubic coordinates mode */
  73817. static readonly CUBIC_MODE: number;
  73818. /** Projection coordinates mode */
  73819. static readonly PROJECTION_MODE: number;
  73820. /** Inverse Cubic coordinates mode */
  73821. static readonly SKYBOX_MODE: number;
  73822. /** Inverse Cubic coordinates mode */
  73823. static readonly INVCUBIC_MODE: number;
  73824. /** Equirectangular coordinates mode */
  73825. static readonly EQUIRECTANGULAR_MODE: number;
  73826. /** Equirectangular Fixed coordinates mode */
  73827. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  73828. /** Equirectangular Fixed Mirrored coordinates mode */
  73829. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  73830. /** Texture is not repeating outside of 0..1 UVs */
  73831. static readonly CLAMP_ADDRESSMODE: number;
  73832. /** Texture is repeating outside of 0..1 UVs */
  73833. static readonly WRAP_ADDRESSMODE: number;
  73834. /** Texture is repeating and mirrored */
  73835. static readonly MIRROR_ADDRESSMODE: number;
  73836. /**
  73837. * 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
  73838. */
  73839. static UseSerializedUrlIfAny: boolean;
  73840. /**
  73841. * Define the url of the texture.
  73842. */
  73843. url: Nullable<string>;
  73844. /**
  73845. * Define an offset on the texture to offset the u coordinates of the UVs
  73846. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  73847. */
  73848. uOffset: number;
  73849. /**
  73850. * Define an offset on the texture to offset the v coordinates of the UVs
  73851. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  73852. */
  73853. vOffset: number;
  73854. /**
  73855. * Define an offset on the texture to scale the u coordinates of the UVs
  73856. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  73857. */
  73858. uScale: number;
  73859. /**
  73860. * Define an offset on the texture to scale the v coordinates of the UVs
  73861. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  73862. */
  73863. vScale: number;
  73864. /**
  73865. * Define an offset on the texture to rotate around the u coordinates of the UVs
  73866. * @see http://doc.babylonjs.com/how_to/more_materials
  73867. */
  73868. uAng: number;
  73869. /**
  73870. * Define an offset on the texture to rotate around the v coordinates of the UVs
  73871. * @see http://doc.babylonjs.com/how_to/more_materials
  73872. */
  73873. vAng: number;
  73874. /**
  73875. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  73876. * @see http://doc.babylonjs.com/how_to/more_materials
  73877. */
  73878. wAng: number;
  73879. /**
  73880. * Defines the center of rotation (U)
  73881. */
  73882. uRotationCenter: number;
  73883. /**
  73884. * Defines the center of rotation (V)
  73885. */
  73886. vRotationCenter: number;
  73887. /**
  73888. * Defines the center of rotation (W)
  73889. */
  73890. wRotationCenter: number;
  73891. /**
  73892. * Are mip maps generated for this texture or not.
  73893. */
  73894. readonly noMipmap: boolean;
  73895. private _noMipmap;
  73896. /** @hidden */
  73897. _invertY: boolean;
  73898. private _rowGenerationMatrix;
  73899. private _cachedTextureMatrix;
  73900. private _projectionModeMatrix;
  73901. private _t0;
  73902. private _t1;
  73903. private _t2;
  73904. private _cachedUOffset;
  73905. private _cachedVOffset;
  73906. private _cachedUScale;
  73907. private _cachedVScale;
  73908. private _cachedUAng;
  73909. private _cachedVAng;
  73910. private _cachedWAng;
  73911. private _cachedProjectionMatrixId;
  73912. private _cachedCoordinatesMode;
  73913. /** @hidden */
  73914. protected _initialSamplingMode: number;
  73915. /** @hidden */
  73916. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  73917. private _deleteBuffer;
  73918. protected _format: Nullable<number>;
  73919. private _delayedOnLoad;
  73920. private _delayedOnError;
  73921. /**
  73922. * Observable triggered once the texture has been loaded.
  73923. */
  73924. onLoadObservable: Observable<Texture>;
  73925. protected _isBlocking: boolean;
  73926. /**
  73927. * Is the texture preventing material to render while loading.
  73928. * If false, a default texture will be used instead of the loading one during the preparation step.
  73929. */
  73930. isBlocking: boolean;
  73931. /**
  73932. * Get the current sampling mode associated with the texture.
  73933. */
  73934. readonly samplingMode: number;
  73935. /**
  73936. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  73937. */
  73938. readonly invertY: boolean;
  73939. /**
  73940. * Instantiates a new texture.
  73941. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  73942. * @see http://doc.babylonjs.com/babylon101/materials#texture
  73943. * @param url define the url of the picture to load as a texture
  73944. * @param scene define the scene the texture will belong to
  73945. * @param noMipmap define if the texture will require mip maps or not
  73946. * @param invertY define if the texture needs to be inverted on the y axis during loading
  73947. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  73948. * @param onLoad define a callback triggered when the texture has been loaded
  73949. * @param onError define a callback triggered when an error occurred during the loading session
  73950. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  73951. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  73952. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  73953. */
  73954. 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);
  73955. /**
  73956. * Update the url (and optional buffer) of this texture if url was null during construction.
  73957. * @param url the url of the texture
  73958. * @param buffer the buffer of the texture (defaults to null)
  73959. * @param onLoad callback called when the texture is loaded (defaults to null)
  73960. */
  73961. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  73962. /**
  73963. * Finish the loading sequence of a texture flagged as delayed load.
  73964. * @hidden
  73965. */
  73966. delayLoad(): void;
  73967. private _prepareRowForTextureGeneration;
  73968. /**
  73969. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  73970. * @returns the transform matrix of the texture.
  73971. */
  73972. getTextureMatrix(): Matrix;
  73973. /**
  73974. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  73975. * @returns The reflection texture transform
  73976. */
  73977. getReflectionTextureMatrix(): Matrix;
  73978. /**
  73979. * Clones the texture.
  73980. * @returns the cloned texture
  73981. */
  73982. clone(): Texture;
  73983. /**
  73984. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  73985. * @returns The JSON representation of the texture
  73986. */
  73987. serialize(): any;
  73988. /**
  73989. * Get the current class name of the texture useful for serialization or dynamic coding.
  73990. * @returns "Texture"
  73991. */
  73992. getClassName(): string;
  73993. /**
  73994. * Dispose the texture and release its associated resources.
  73995. */
  73996. dispose(): void;
  73997. /**
  73998. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  73999. * @param parsedTexture Define the JSON representation of the texture
  74000. * @param scene Define the scene the parsed texture should be instantiated in
  74001. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  74002. * @returns The parsed texture if successful
  74003. */
  74004. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  74005. /**
  74006. * Creates a texture from its base 64 representation.
  74007. * @param data Define the base64 payload without the data: prefix
  74008. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  74009. * @param scene Define the scene the texture should belong to
  74010. * @param noMipmap Forces the texture to not create mip map information if true
  74011. * @param invertY define if the texture needs to be inverted on the y axis during loading
  74012. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  74013. * @param onLoad define a callback triggered when the texture has been loaded
  74014. * @param onError define a callback triggered when an error occurred during the loading session
  74015. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  74016. * @returns the created texture
  74017. */
  74018. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  74019. /**
  74020. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  74021. * @param data Define the base64 payload without the data: prefix
  74022. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  74023. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  74024. * @param scene Define the scene the texture should belong to
  74025. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  74026. * @param noMipmap Forces the texture to not create mip map information if true
  74027. * @param invertY define if the texture needs to be inverted on the y axis during loading
  74028. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  74029. * @param onLoad define a callback triggered when the texture has been loaded
  74030. * @param onError define a callback triggered when an error occurred during the loading session
  74031. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  74032. * @returns the created texture
  74033. */
  74034. 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;
  74035. }
  74036. }
  74037. declare module BABYLON {
  74038. /**
  74039. * Defines the options associated with the creation of a shader material.
  74040. */
  74041. export interface IShaderMaterialOptions {
  74042. /**
  74043. * Does the material work in alpha blend mode
  74044. */
  74045. needAlphaBlending: boolean;
  74046. /**
  74047. * Does the material work in alpha test mode
  74048. */
  74049. needAlphaTesting: boolean;
  74050. /**
  74051. * The list of attribute names used in the shader
  74052. */
  74053. attributes: string[];
  74054. /**
  74055. * The list of unifrom names used in the shader
  74056. */
  74057. uniforms: string[];
  74058. /**
  74059. * The list of UBO names used in the shader
  74060. */
  74061. uniformBuffers: string[];
  74062. /**
  74063. * The list of sampler names used in the shader
  74064. */
  74065. samplers: string[];
  74066. /**
  74067. * The list of defines used in the shader
  74068. */
  74069. defines: string[];
  74070. }
  74071. /**
  74072. * 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.
  74073. *
  74074. * This returned material effects how the mesh will look based on the code in the shaders.
  74075. *
  74076. * @see http://doc.babylonjs.com/how_to/shader_material
  74077. */
  74078. export class ShaderMaterial extends Material {
  74079. private _shaderPath;
  74080. private _options;
  74081. private _textures;
  74082. private _textureArrays;
  74083. private _floats;
  74084. private _ints;
  74085. private _floatsArrays;
  74086. private _colors3;
  74087. private _colors3Arrays;
  74088. private _colors4;
  74089. private _vectors2;
  74090. private _vectors3;
  74091. private _vectors4;
  74092. private _matrices;
  74093. private _matrices3x3;
  74094. private _matrices2x2;
  74095. private _vectors2Arrays;
  74096. private _vectors3Arrays;
  74097. private _cachedWorldViewMatrix;
  74098. private _renderId;
  74099. /**
  74100. * Instantiate a new shader material.
  74101. * 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.
  74102. * This returned material effects how the mesh will look based on the code in the shaders.
  74103. * @see http://doc.babylonjs.com/how_to/shader_material
  74104. * @param name Define the name of the material in the scene
  74105. * @param scene Define the scene the material belongs to
  74106. * @param shaderPath Defines the route to the shader code in one of three ways:
  74107. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  74108. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  74109. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  74110. * @param options Define the options used to create the shader
  74111. */
  74112. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  74113. /**
  74114. * Gets the current class name of the material e.g. "ShaderMaterial"
  74115. * Mainly use in serialization.
  74116. * @returns the class name
  74117. */
  74118. getClassName(): string;
  74119. /**
  74120. * Specifies if the material will require alpha blending
  74121. * @returns a boolean specifying if alpha blending is needed
  74122. */
  74123. needAlphaBlending(): boolean;
  74124. /**
  74125. * Specifies if this material should be rendered in alpha test mode
  74126. * @returns a boolean specifying if an alpha test is needed.
  74127. */
  74128. needAlphaTesting(): boolean;
  74129. private _checkUniform;
  74130. /**
  74131. * Set a texture in the shader.
  74132. * @param name Define the name of the uniform samplers as defined in the shader
  74133. * @param texture Define the texture to bind to this sampler
  74134. * @return the material itself allowing "fluent" like uniform updates
  74135. */
  74136. setTexture(name: string, texture: Texture): ShaderMaterial;
  74137. /**
  74138. * Set a texture array in the shader.
  74139. * @param name Define the name of the uniform sampler array as defined in the shader
  74140. * @param textures Define the list of textures to bind to this sampler
  74141. * @return the material itself allowing "fluent" like uniform updates
  74142. */
  74143. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  74144. /**
  74145. * Set a float in the shader.
  74146. * @param name Define the name of the uniform as defined in the shader
  74147. * @param value Define the value to give to the uniform
  74148. * @return the material itself allowing "fluent" like uniform updates
  74149. */
  74150. setFloat(name: string, value: number): ShaderMaterial;
  74151. /**
  74152. * Set a int in the shader.
  74153. * @param name Define the name of the uniform as defined in the shader
  74154. * @param value Define the value to give to the uniform
  74155. * @return the material itself allowing "fluent" like uniform updates
  74156. */
  74157. setInt(name: string, value: number): ShaderMaterial;
  74158. /**
  74159. * Set an array of floats in the shader.
  74160. * @param name Define the name of the uniform as defined in the shader
  74161. * @param value Define the value to give to the uniform
  74162. * @return the material itself allowing "fluent" like uniform updates
  74163. */
  74164. setFloats(name: string, value: number[]): ShaderMaterial;
  74165. /**
  74166. * Set a vec3 in the shader from a Color3.
  74167. * @param name Define the name of the uniform as defined in the shader
  74168. * @param value Define the value to give to the uniform
  74169. * @return the material itself allowing "fluent" like uniform updates
  74170. */
  74171. setColor3(name: string, value: Color3): ShaderMaterial;
  74172. /**
  74173. * Set a vec3 array in the shader from a Color3 array.
  74174. * @param name Define the name of the uniform as defined in the shader
  74175. * @param value Define the value to give to the uniform
  74176. * @return the material itself allowing "fluent" like uniform updates
  74177. */
  74178. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  74179. /**
  74180. * Set a vec4 in the shader from a Color4.
  74181. * @param name Define the name of the uniform as defined in the shader
  74182. * @param value Define the value to give to the uniform
  74183. * @return the material itself allowing "fluent" like uniform updates
  74184. */
  74185. setColor4(name: string, value: Color4): ShaderMaterial;
  74186. /**
  74187. * Set a vec2 in the shader from a Vector2.
  74188. * @param name Define the name of the uniform as defined in the shader
  74189. * @param value Define the value to give to the uniform
  74190. * @return the material itself allowing "fluent" like uniform updates
  74191. */
  74192. setVector2(name: string, value: Vector2): ShaderMaterial;
  74193. /**
  74194. * Set a vec3 in the shader from a Vector3.
  74195. * @param name Define the name of the uniform as defined in the shader
  74196. * @param value Define the value to give to the uniform
  74197. * @return the material itself allowing "fluent" like uniform updates
  74198. */
  74199. setVector3(name: string, value: Vector3): ShaderMaterial;
  74200. /**
  74201. * Set a vec4 in the shader from a Vector4.
  74202. * @param name Define the name of the uniform as defined in the shader
  74203. * @param value Define the value to give to the uniform
  74204. * @return the material itself allowing "fluent" like uniform updates
  74205. */
  74206. setVector4(name: string, value: Vector4): ShaderMaterial;
  74207. /**
  74208. * Set a mat4 in the shader from a Matrix.
  74209. * @param name Define the name of the uniform as defined in the shader
  74210. * @param value Define the value to give to the uniform
  74211. * @return the material itself allowing "fluent" like uniform updates
  74212. */
  74213. setMatrix(name: string, value: Matrix): ShaderMaterial;
  74214. /**
  74215. * Set a mat3 in the shader from a Float32Array.
  74216. * @param name Define the name of the uniform as defined in the shader
  74217. * @param value Define the value to give to the uniform
  74218. * @return the material itself allowing "fluent" like uniform updates
  74219. */
  74220. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  74221. /**
  74222. * Set a mat2 in the shader from a Float32Array.
  74223. * @param name Define the name of the uniform as defined in the shader
  74224. * @param value Define the value to give to the uniform
  74225. * @return the material itself allowing "fluent" like uniform updates
  74226. */
  74227. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  74228. /**
  74229. * Set a vec2 array in the shader from a number array.
  74230. * @param name Define the name of the uniform as defined in the shader
  74231. * @param value Define the value to give to the uniform
  74232. * @return the material itself allowing "fluent" like uniform updates
  74233. */
  74234. setArray2(name: string, value: number[]): ShaderMaterial;
  74235. /**
  74236. * Set a vec3 array in the shader from a number array.
  74237. * @param name Define the name of the uniform as defined in the shader
  74238. * @param value Define the value to give to the uniform
  74239. * @return the material itself allowing "fluent" like uniform updates
  74240. */
  74241. setArray3(name: string, value: number[]): ShaderMaterial;
  74242. private _checkCache;
  74243. /**
  74244. * Checks if the material is ready to render the requested mesh
  74245. * @param mesh Define the mesh to render
  74246. * @param useInstances Define whether or not the material is used with instances
  74247. * @returns true if ready, otherwise false
  74248. */
  74249. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  74250. /**
  74251. * Binds the world matrix to the material
  74252. * @param world defines the world transformation matrix
  74253. */
  74254. bindOnlyWorldMatrix(world: Matrix): void;
  74255. /**
  74256. * Binds the material to the mesh
  74257. * @param world defines the world transformation matrix
  74258. * @param mesh defines the mesh to bind the material to
  74259. */
  74260. bind(world: Matrix, mesh?: Mesh): void;
  74261. /**
  74262. * Gets the active textures from the material
  74263. * @returns an array of textures
  74264. */
  74265. getActiveTextures(): BaseTexture[];
  74266. /**
  74267. * Specifies if the material uses a texture
  74268. * @param texture defines the texture to check against the material
  74269. * @returns a boolean specifying if the material uses the texture
  74270. */
  74271. hasTexture(texture: BaseTexture): boolean;
  74272. /**
  74273. * Makes a duplicate of the material, and gives it a new name
  74274. * @param name defines the new name for the duplicated material
  74275. * @returns the cloned material
  74276. */
  74277. clone(name: string): ShaderMaterial;
  74278. /**
  74279. * Disposes the material
  74280. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  74281. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  74282. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  74283. */
  74284. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  74285. /**
  74286. * Serializes this material in a JSON representation
  74287. * @returns the serialized material object
  74288. */
  74289. serialize(): any;
  74290. /**
  74291. * Creates a shader material from parsed shader material data
  74292. * @param source defines the JSON represnetation of the material
  74293. * @param scene defines the hosting scene
  74294. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  74295. * @returns a new material
  74296. */
  74297. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  74298. }
  74299. }
  74300. declare module BABYLON {
  74301. /** @hidden */
  74302. export var colorPixelShader: {
  74303. name: string;
  74304. shader: string;
  74305. };
  74306. }
  74307. declare module BABYLON {
  74308. /** @hidden */
  74309. export var colorVertexShader: {
  74310. name: string;
  74311. shader: string;
  74312. };
  74313. }
  74314. declare module BABYLON {
  74315. /**
  74316. * Line mesh
  74317. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  74318. */
  74319. export class LinesMesh extends Mesh {
  74320. /**
  74321. * If vertex color should be applied to the mesh
  74322. */
  74323. useVertexColor?: boolean | undefined;
  74324. /**
  74325. * If vertex alpha should be applied to the mesh
  74326. */
  74327. useVertexAlpha?: boolean | undefined;
  74328. /**
  74329. * Color of the line (Default: White)
  74330. */
  74331. color: Color3;
  74332. /**
  74333. * Alpha of the line (Default: 1)
  74334. */
  74335. alpha: number;
  74336. /**
  74337. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74338. * This margin is expressed in world space coordinates, so its value may vary.
  74339. * Default value is 0.1
  74340. */
  74341. intersectionThreshold: number;
  74342. private _colorShader;
  74343. /**
  74344. * Creates a new LinesMesh
  74345. * @param name defines the name
  74346. * @param scene defines the hosting scene
  74347. * @param parent defines the parent mesh if any
  74348. * @param source defines the optional source LinesMesh used to clone data from
  74349. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  74350. * When false, achieved by calling a clone(), also passing False.
  74351. * This will make creation of children, recursive.
  74352. * @param useVertexColor defines if this LinesMesh supports vertex color
  74353. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  74354. */
  74355. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  74356. /**
  74357. * If vertex color should be applied to the mesh
  74358. */
  74359. useVertexColor?: boolean | undefined,
  74360. /**
  74361. * If vertex alpha should be applied to the mesh
  74362. */
  74363. useVertexAlpha?: boolean | undefined);
  74364. /**
  74365. * Returns the string "LineMesh"
  74366. */
  74367. getClassName(): string;
  74368. /**
  74369. * @hidden
  74370. */
  74371. /**
  74372. * @hidden
  74373. */
  74374. material: Material;
  74375. /**
  74376. * @hidden
  74377. */
  74378. readonly checkCollisions: boolean;
  74379. /** @hidden */
  74380. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  74381. /** @hidden */
  74382. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  74383. /**
  74384. * Disposes of the line mesh
  74385. * @param doNotRecurse If children should be disposed
  74386. */
  74387. dispose(doNotRecurse?: boolean): void;
  74388. /**
  74389. * Returns a new LineMesh object cloned from the current one.
  74390. */
  74391. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  74392. /**
  74393. * Creates a new InstancedLinesMesh object from the mesh model.
  74394. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  74395. * @param name defines the name of the new instance
  74396. * @returns a new InstancedLinesMesh
  74397. */
  74398. createInstance(name: string): InstancedLinesMesh;
  74399. }
  74400. /**
  74401. * Creates an instance based on a source LinesMesh
  74402. */
  74403. export class InstancedLinesMesh extends InstancedMesh {
  74404. /**
  74405. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74406. * This margin is expressed in world space coordinates, so its value may vary.
  74407. * Initilized with the intersectionThreshold value of the source LinesMesh
  74408. */
  74409. intersectionThreshold: number;
  74410. constructor(name: string, source: LinesMesh);
  74411. /**
  74412. * Returns the string "InstancedLinesMesh".
  74413. */
  74414. getClassName(): string;
  74415. }
  74416. }
  74417. declare module BABYLON {
  74418. /**
  74419. * Mesh representing the gorund
  74420. */
  74421. export class GroundMesh extends Mesh {
  74422. /** If octree should be generated */
  74423. generateOctree: boolean;
  74424. private _heightQuads;
  74425. /** @hidden */
  74426. _subdivisionsX: number;
  74427. /** @hidden */
  74428. _subdivisionsY: number;
  74429. /** @hidden */
  74430. _width: number;
  74431. /** @hidden */
  74432. _height: number;
  74433. /** @hidden */
  74434. _minX: number;
  74435. /** @hidden */
  74436. _maxX: number;
  74437. /** @hidden */
  74438. _minZ: number;
  74439. /** @hidden */
  74440. _maxZ: number;
  74441. constructor(name: string, scene: Scene);
  74442. /**
  74443. * "GroundMesh"
  74444. * @returns "GroundMesh"
  74445. */
  74446. getClassName(): string;
  74447. /**
  74448. * The minimum of x and y subdivisions
  74449. */
  74450. readonly subdivisions: number;
  74451. /**
  74452. * X subdivisions
  74453. */
  74454. readonly subdivisionsX: number;
  74455. /**
  74456. * Y subdivisions
  74457. */
  74458. readonly subdivisionsY: number;
  74459. /**
  74460. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  74461. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  74462. * @param chunksCount the number of subdivisions for x and y
  74463. * @param octreeBlocksSize (Default: 32)
  74464. */
  74465. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  74466. /**
  74467. * Returns a height (y) value in the Worl system :
  74468. * the ground altitude at the coordinates (x, z) expressed in the World system.
  74469. * @param x x coordinate
  74470. * @param z z coordinate
  74471. * @returns the ground y position if (x, z) are outside the ground surface.
  74472. */
  74473. getHeightAtCoordinates(x: number, z: number): number;
  74474. /**
  74475. * Returns a normalized vector (Vector3) orthogonal to the ground
  74476. * at the ground coordinates (x, z) expressed in the World system.
  74477. * @param x x coordinate
  74478. * @param z z coordinate
  74479. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  74480. */
  74481. getNormalAtCoordinates(x: number, z: number): Vector3;
  74482. /**
  74483. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  74484. * at the ground coordinates (x, z) expressed in the World system.
  74485. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  74486. * @param x x coordinate
  74487. * @param z z coordinate
  74488. * @param ref vector to store the result
  74489. * @returns the GroundMesh.
  74490. */
  74491. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  74492. /**
  74493. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  74494. * if the ground has been updated.
  74495. * This can be used in the render loop.
  74496. * @returns the GroundMesh.
  74497. */
  74498. updateCoordinateHeights(): GroundMesh;
  74499. private _getFacetAt;
  74500. private _initHeightQuads;
  74501. private _computeHeightQuads;
  74502. /**
  74503. * Serializes this ground mesh
  74504. * @param serializationObject object to write serialization to
  74505. */
  74506. serialize(serializationObject: any): void;
  74507. /**
  74508. * Parses a serialized ground mesh
  74509. * @param parsedMesh the serialized mesh
  74510. * @param scene the scene to create the ground mesh in
  74511. * @returns the created ground mesh
  74512. */
  74513. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  74514. }
  74515. }
  74516. declare module BABYLON {
  74517. /**
  74518. * Interface for Physics-Joint data
  74519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74520. */
  74521. export interface PhysicsJointData {
  74522. /**
  74523. * The main pivot of the joint
  74524. */
  74525. mainPivot?: Vector3;
  74526. /**
  74527. * The connected pivot of the joint
  74528. */
  74529. connectedPivot?: Vector3;
  74530. /**
  74531. * The main axis of the joint
  74532. */
  74533. mainAxis?: Vector3;
  74534. /**
  74535. * The connected axis of the joint
  74536. */
  74537. connectedAxis?: Vector3;
  74538. /**
  74539. * The collision of the joint
  74540. */
  74541. collision?: boolean;
  74542. /**
  74543. * Native Oimo/Cannon/Energy data
  74544. */
  74545. nativeParams?: any;
  74546. }
  74547. /**
  74548. * This is a holder class for the physics joint created by the physics plugin
  74549. * It holds a set of functions to control the underlying joint
  74550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74551. */
  74552. export class PhysicsJoint {
  74553. /**
  74554. * The type of the physics joint
  74555. */
  74556. type: number;
  74557. /**
  74558. * The data for the physics joint
  74559. */
  74560. jointData: PhysicsJointData;
  74561. private _physicsJoint;
  74562. protected _physicsPlugin: IPhysicsEnginePlugin;
  74563. /**
  74564. * Initializes the physics joint
  74565. * @param type The type of the physics joint
  74566. * @param jointData The data for the physics joint
  74567. */
  74568. constructor(
  74569. /**
  74570. * The type of the physics joint
  74571. */
  74572. type: number,
  74573. /**
  74574. * The data for the physics joint
  74575. */
  74576. jointData: PhysicsJointData);
  74577. /**
  74578. * Gets the physics joint
  74579. */
  74580. /**
  74581. * Sets the physics joint
  74582. */
  74583. physicsJoint: any;
  74584. /**
  74585. * Sets the physics plugin
  74586. */
  74587. physicsPlugin: IPhysicsEnginePlugin;
  74588. /**
  74589. * Execute a function that is physics-plugin specific.
  74590. * @param {Function} func the function that will be executed.
  74591. * It accepts two parameters: the physics world and the physics joint
  74592. */
  74593. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  74594. /**
  74595. * Distance-Joint type
  74596. */
  74597. static DistanceJoint: number;
  74598. /**
  74599. * Hinge-Joint type
  74600. */
  74601. static HingeJoint: number;
  74602. /**
  74603. * Ball-and-Socket joint type
  74604. */
  74605. static BallAndSocketJoint: number;
  74606. /**
  74607. * Wheel-Joint type
  74608. */
  74609. static WheelJoint: number;
  74610. /**
  74611. * Slider-Joint type
  74612. */
  74613. static SliderJoint: number;
  74614. /**
  74615. * Prismatic-Joint type
  74616. */
  74617. static PrismaticJoint: number;
  74618. /**
  74619. * Universal-Joint type
  74620. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  74621. */
  74622. static UniversalJoint: number;
  74623. /**
  74624. * Hinge-Joint 2 type
  74625. */
  74626. static Hinge2Joint: number;
  74627. /**
  74628. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  74629. */
  74630. static PointToPointJoint: number;
  74631. /**
  74632. * Spring-Joint type
  74633. */
  74634. static SpringJoint: number;
  74635. /**
  74636. * Lock-Joint type
  74637. */
  74638. static LockJoint: number;
  74639. }
  74640. /**
  74641. * A class representing a physics distance joint
  74642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74643. */
  74644. export class DistanceJoint extends PhysicsJoint {
  74645. /**
  74646. *
  74647. * @param jointData The data for the Distance-Joint
  74648. */
  74649. constructor(jointData: DistanceJointData);
  74650. /**
  74651. * Update the predefined distance.
  74652. * @param maxDistance The maximum preferred distance
  74653. * @param minDistance The minimum preferred distance
  74654. */
  74655. updateDistance(maxDistance: number, minDistance?: number): void;
  74656. }
  74657. /**
  74658. * Represents a Motor-Enabled Joint
  74659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74660. */
  74661. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  74662. /**
  74663. * Initializes the Motor-Enabled Joint
  74664. * @param type The type of the joint
  74665. * @param jointData The physica joint data for the joint
  74666. */
  74667. constructor(type: number, jointData: PhysicsJointData);
  74668. /**
  74669. * Set the motor values.
  74670. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74671. * @param force the force to apply
  74672. * @param maxForce max force for this motor.
  74673. */
  74674. setMotor(force?: number, maxForce?: number): void;
  74675. /**
  74676. * Set the motor's limits.
  74677. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74678. * @param upperLimit The upper limit of the motor
  74679. * @param lowerLimit The lower limit of the motor
  74680. */
  74681. setLimit(upperLimit: number, lowerLimit?: number): void;
  74682. }
  74683. /**
  74684. * This class represents a single physics Hinge-Joint
  74685. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74686. */
  74687. export class HingeJoint extends MotorEnabledJoint {
  74688. /**
  74689. * Initializes the Hinge-Joint
  74690. * @param jointData The joint data for the Hinge-Joint
  74691. */
  74692. constructor(jointData: PhysicsJointData);
  74693. /**
  74694. * Set the motor values.
  74695. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74696. * @param {number} force the force to apply
  74697. * @param {number} maxForce max force for this motor.
  74698. */
  74699. setMotor(force?: number, maxForce?: number): void;
  74700. /**
  74701. * Set the motor's limits.
  74702. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74703. * @param upperLimit The upper limit of the motor
  74704. * @param lowerLimit The lower limit of the motor
  74705. */
  74706. setLimit(upperLimit: number, lowerLimit?: number): void;
  74707. }
  74708. /**
  74709. * This class represents a dual hinge physics joint (same as wheel joint)
  74710. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74711. */
  74712. export class Hinge2Joint extends MotorEnabledJoint {
  74713. /**
  74714. * Initializes the Hinge2-Joint
  74715. * @param jointData The joint data for the Hinge2-Joint
  74716. */
  74717. constructor(jointData: PhysicsJointData);
  74718. /**
  74719. * Set the motor values.
  74720. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74721. * @param {number} force the force to apply
  74722. * @param {number} maxForce max force for this motor.
  74723. * @param {motorIndex} the motor's index, 0 or 1.
  74724. */
  74725. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  74726. /**
  74727. * Set the motor limits.
  74728. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74729. * @param {number} upperLimit the upper limit
  74730. * @param {number} lowerLimit lower limit
  74731. * @param {motorIndex} the motor's index, 0 or 1.
  74732. */
  74733. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  74734. }
  74735. /**
  74736. * Interface for a motor enabled joint
  74737. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74738. */
  74739. export interface IMotorEnabledJoint {
  74740. /**
  74741. * Physics joint
  74742. */
  74743. physicsJoint: any;
  74744. /**
  74745. * Sets the motor of the motor-enabled joint
  74746. * @param force The force of the motor
  74747. * @param maxForce The maximum force of the motor
  74748. * @param motorIndex The index of the motor
  74749. */
  74750. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  74751. /**
  74752. * Sets the limit of the motor
  74753. * @param upperLimit The upper limit of the motor
  74754. * @param lowerLimit The lower limit of the motor
  74755. * @param motorIndex The index of the motor
  74756. */
  74757. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  74758. }
  74759. /**
  74760. * Joint data for a Distance-Joint
  74761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74762. */
  74763. export interface DistanceJointData extends PhysicsJointData {
  74764. /**
  74765. * Max distance the 2 joint objects can be apart
  74766. */
  74767. maxDistance: number;
  74768. }
  74769. /**
  74770. * Joint data from a spring joint
  74771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74772. */
  74773. export interface SpringJointData extends PhysicsJointData {
  74774. /**
  74775. * Length of the spring
  74776. */
  74777. length: number;
  74778. /**
  74779. * Stiffness of the spring
  74780. */
  74781. stiffness: number;
  74782. /**
  74783. * Damping of the spring
  74784. */
  74785. damping: number;
  74786. /** this callback will be called when applying the force to the impostors. */
  74787. forceApplicationCallback: () => void;
  74788. }
  74789. }
  74790. declare module BABYLON {
  74791. /**
  74792. * Interface used to describe a physics joint
  74793. */
  74794. export interface PhysicsImpostorJoint {
  74795. /** Defines the main impostor to which the joint is linked */
  74796. mainImpostor: PhysicsImpostor;
  74797. /** Defines the impostor that is connected to the main impostor using this joint */
  74798. connectedImpostor: PhysicsImpostor;
  74799. /** Defines the joint itself */
  74800. joint: PhysicsJoint;
  74801. }
  74802. /** @hidden */
  74803. export interface IPhysicsEnginePlugin {
  74804. world: any;
  74805. name: string;
  74806. setGravity(gravity: Vector3): void;
  74807. setTimeStep(timeStep: number): void;
  74808. getTimeStep(): number;
  74809. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  74810. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  74811. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  74812. generatePhysicsBody(impostor: PhysicsImpostor): void;
  74813. removePhysicsBody(impostor: PhysicsImpostor): void;
  74814. generateJoint(joint: PhysicsImpostorJoint): void;
  74815. removeJoint(joint: PhysicsImpostorJoint): void;
  74816. isSupported(): boolean;
  74817. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  74818. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  74819. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  74820. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  74821. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  74822. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  74823. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  74824. getBodyMass(impostor: PhysicsImpostor): number;
  74825. getBodyFriction(impostor: PhysicsImpostor): number;
  74826. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  74827. getBodyRestitution(impostor: PhysicsImpostor): number;
  74828. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  74829. sleepBody(impostor: PhysicsImpostor): void;
  74830. wakeUpBody(impostor: PhysicsImpostor): void;
  74831. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  74832. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  74833. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  74834. getRadius(impostor: PhysicsImpostor): number;
  74835. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  74836. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  74837. dispose(): void;
  74838. }
  74839. /**
  74840. * Interface used to define a physics engine
  74841. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  74842. */
  74843. export interface IPhysicsEngine {
  74844. /**
  74845. * Gets the gravity vector used by the simulation
  74846. */
  74847. gravity: Vector3;
  74848. /**
  74849. * Sets the gravity vector used by the simulation
  74850. * @param gravity defines the gravity vector to use
  74851. */
  74852. setGravity(gravity: Vector3): void;
  74853. /**
  74854. * Set the time step of the physics engine.
  74855. * Default is 1/60.
  74856. * To slow it down, enter 1/600 for example.
  74857. * To speed it up, 1/30
  74858. * @param newTimeStep the new timestep to apply to this world.
  74859. */
  74860. setTimeStep(newTimeStep: number): void;
  74861. /**
  74862. * Get the time step of the physics engine.
  74863. * @returns the current time step
  74864. */
  74865. getTimeStep(): number;
  74866. /**
  74867. * Release all resources
  74868. */
  74869. dispose(): void;
  74870. /**
  74871. * Gets the name of the current physics plugin
  74872. * @returns the name of the plugin
  74873. */
  74874. getPhysicsPluginName(): string;
  74875. /**
  74876. * Adding a new impostor for the impostor tracking.
  74877. * This will be done by the impostor itself.
  74878. * @param impostor the impostor to add
  74879. */
  74880. addImpostor(impostor: PhysicsImpostor): void;
  74881. /**
  74882. * Remove an impostor from the engine.
  74883. * This impostor and its mesh will not longer be updated by the physics engine.
  74884. * @param impostor the impostor to remove
  74885. */
  74886. removeImpostor(impostor: PhysicsImpostor): void;
  74887. /**
  74888. * Add a joint to the physics engine
  74889. * @param mainImpostor defines the main impostor to which the joint is added.
  74890. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  74891. * @param joint defines the joint that will connect both impostors.
  74892. */
  74893. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  74894. /**
  74895. * Removes a joint from the simulation
  74896. * @param mainImpostor defines the impostor used with the joint
  74897. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  74898. * @param joint defines the joint to remove
  74899. */
  74900. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  74901. /**
  74902. * Gets the current plugin used to run the simulation
  74903. * @returns current plugin
  74904. */
  74905. getPhysicsPlugin(): IPhysicsEnginePlugin;
  74906. /**
  74907. * Gets the list of physic impostors
  74908. * @returns an array of PhysicsImpostor
  74909. */
  74910. getImpostors(): Array<PhysicsImpostor>;
  74911. /**
  74912. * Gets the impostor for a physics enabled object
  74913. * @param object defines the object impersonated by the impostor
  74914. * @returns the PhysicsImpostor or null if not found
  74915. */
  74916. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  74917. /**
  74918. * Gets the impostor for a physics body object
  74919. * @param body defines physics body used by the impostor
  74920. * @returns the PhysicsImpostor or null if not found
  74921. */
  74922. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  74923. /**
  74924. * Called by the scene. No need to call it.
  74925. * @param delta defines the timespam between frames
  74926. */
  74927. _step(delta: number): void;
  74928. }
  74929. }
  74930. declare module BABYLON {
  74931. /**
  74932. * The interface for the physics imposter parameters
  74933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74934. */
  74935. export interface PhysicsImpostorParameters {
  74936. /**
  74937. * The mass of the physics imposter
  74938. */
  74939. mass: number;
  74940. /**
  74941. * The friction of the physics imposter
  74942. */
  74943. friction?: number;
  74944. /**
  74945. * The coefficient of restitution of the physics imposter
  74946. */
  74947. restitution?: number;
  74948. /**
  74949. * The native options of the physics imposter
  74950. */
  74951. nativeOptions?: any;
  74952. /**
  74953. * Specifies if the parent should be ignored
  74954. */
  74955. ignoreParent?: boolean;
  74956. /**
  74957. * Specifies if bi-directional transformations should be disabled
  74958. */
  74959. disableBidirectionalTransformation?: boolean;
  74960. }
  74961. /**
  74962. * Interface for a physics-enabled object
  74963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74964. */
  74965. export interface IPhysicsEnabledObject {
  74966. /**
  74967. * The position of the physics-enabled object
  74968. */
  74969. position: Vector3;
  74970. /**
  74971. * The rotation of the physics-enabled object
  74972. */
  74973. rotationQuaternion: Nullable<Quaternion>;
  74974. /**
  74975. * The scale of the physics-enabled object
  74976. */
  74977. scaling: Vector3;
  74978. /**
  74979. * The rotation of the physics-enabled object
  74980. */
  74981. rotation?: Vector3;
  74982. /**
  74983. * The parent of the physics-enabled object
  74984. */
  74985. parent?: any;
  74986. /**
  74987. * The bounding info of the physics-enabled object
  74988. * @returns The bounding info of the physics-enabled object
  74989. */
  74990. getBoundingInfo(): BoundingInfo;
  74991. /**
  74992. * Computes the world matrix
  74993. * @param force Specifies if the world matrix should be computed by force
  74994. * @returns A world matrix
  74995. */
  74996. computeWorldMatrix(force: boolean): Matrix;
  74997. /**
  74998. * Gets the world matrix
  74999. * @returns A world matrix
  75000. */
  75001. getWorldMatrix?(): Matrix;
  75002. /**
  75003. * Gets the child meshes
  75004. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  75005. * @returns An array of abstract meshes
  75006. */
  75007. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  75008. /**
  75009. * Gets the vertex data
  75010. * @param kind The type of vertex data
  75011. * @returns A nullable array of numbers, or a float32 array
  75012. */
  75013. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  75014. /**
  75015. * Gets the indices from the mesh
  75016. * @returns A nullable array of index arrays
  75017. */
  75018. getIndices?(): Nullable<IndicesArray>;
  75019. /**
  75020. * Gets the scene from the mesh
  75021. * @returns the indices array or null
  75022. */
  75023. getScene?(): Scene;
  75024. /**
  75025. * Gets the absolute position from the mesh
  75026. * @returns the absolute position
  75027. */
  75028. getAbsolutePosition(): Vector3;
  75029. /**
  75030. * Gets the absolute pivot point from the mesh
  75031. * @returns the absolute pivot point
  75032. */
  75033. getAbsolutePivotPoint(): Vector3;
  75034. /**
  75035. * Rotates the mesh
  75036. * @param axis The axis of rotation
  75037. * @param amount The amount of rotation
  75038. * @param space The space of the rotation
  75039. * @returns The rotation transform node
  75040. */
  75041. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  75042. /**
  75043. * Translates the mesh
  75044. * @param axis The axis of translation
  75045. * @param distance The distance of translation
  75046. * @param space The space of the translation
  75047. * @returns The transform node
  75048. */
  75049. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  75050. /**
  75051. * Sets the absolute position of the mesh
  75052. * @param absolutePosition The absolute position of the mesh
  75053. * @returns The transform node
  75054. */
  75055. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  75056. /**
  75057. * Gets the class name of the mesh
  75058. * @returns The class name
  75059. */
  75060. getClassName(): string;
  75061. }
  75062. /**
  75063. * Represents a physics imposter
  75064. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75065. */
  75066. export class PhysicsImpostor {
  75067. /**
  75068. * The physics-enabled object used as the physics imposter
  75069. */
  75070. object: IPhysicsEnabledObject;
  75071. /**
  75072. * The type of the physics imposter
  75073. */
  75074. type: number;
  75075. private _options;
  75076. private _scene?;
  75077. /**
  75078. * The default object size of the imposter
  75079. */
  75080. static DEFAULT_OBJECT_SIZE: Vector3;
  75081. /**
  75082. * The identity quaternion of the imposter
  75083. */
  75084. static IDENTITY_QUATERNION: Quaternion;
  75085. /** @hidden */
  75086. _pluginData: any;
  75087. private _physicsEngine;
  75088. private _physicsBody;
  75089. private _bodyUpdateRequired;
  75090. private _onBeforePhysicsStepCallbacks;
  75091. private _onAfterPhysicsStepCallbacks;
  75092. /** @hidden */
  75093. _onPhysicsCollideCallbacks: Array<{
  75094. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  75095. otherImpostors: Array<PhysicsImpostor>;
  75096. }>;
  75097. private _deltaPosition;
  75098. private _deltaRotation;
  75099. private _deltaRotationConjugated;
  75100. private _parent;
  75101. private _isDisposed;
  75102. private static _tmpVecs;
  75103. private static _tmpQuat;
  75104. /**
  75105. * Specifies if the physics imposter is disposed
  75106. */
  75107. readonly isDisposed: boolean;
  75108. /**
  75109. * Gets the mass of the physics imposter
  75110. */
  75111. mass: number;
  75112. /**
  75113. * Gets the coefficient of friction
  75114. */
  75115. /**
  75116. * Sets the coefficient of friction
  75117. */
  75118. friction: number;
  75119. /**
  75120. * Gets the coefficient of restitution
  75121. */
  75122. /**
  75123. * Sets the coefficient of restitution
  75124. */
  75125. restitution: number;
  75126. /**
  75127. * The unique id of the physics imposter
  75128. * set by the physics engine when adding this impostor to the array
  75129. */
  75130. uniqueId: number;
  75131. private _joints;
  75132. /**
  75133. * Initializes the physics imposter
  75134. * @param object The physics-enabled object used as the physics imposter
  75135. * @param type The type of the physics imposter
  75136. * @param _options The options for the physics imposter
  75137. * @param _scene The Babylon scene
  75138. */
  75139. constructor(
  75140. /**
  75141. * The physics-enabled object used as the physics imposter
  75142. */
  75143. object: IPhysicsEnabledObject,
  75144. /**
  75145. * The type of the physics imposter
  75146. */
  75147. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  75148. /**
  75149. * This function will completly initialize this impostor.
  75150. * It will create a new body - but only if this mesh has no parent.
  75151. * If it has, this impostor will not be used other than to define the impostor
  75152. * of the child mesh.
  75153. * @hidden
  75154. */
  75155. _init(): void;
  75156. private _getPhysicsParent;
  75157. /**
  75158. * Should a new body be generated.
  75159. * @returns boolean specifying if body initialization is required
  75160. */
  75161. isBodyInitRequired(): boolean;
  75162. /**
  75163. * Sets the updated scaling
  75164. * @param updated Specifies if the scaling is updated
  75165. */
  75166. setScalingUpdated(): void;
  75167. /**
  75168. * Force a regeneration of this or the parent's impostor's body.
  75169. * Use under cautious - This will remove all joints already implemented.
  75170. */
  75171. forceUpdate(): void;
  75172. /**
  75173. * Gets the body that holds this impostor. Either its own, or its parent.
  75174. */
  75175. /**
  75176. * Set the physics body. Used mainly by the physics engine/plugin
  75177. */
  75178. physicsBody: any;
  75179. /**
  75180. * Get the parent of the physics imposter
  75181. * @returns Physics imposter or null
  75182. */
  75183. /**
  75184. * Sets the parent of the physics imposter
  75185. */
  75186. parent: Nullable<PhysicsImpostor>;
  75187. /**
  75188. * Resets the update flags
  75189. */
  75190. resetUpdateFlags(): void;
  75191. /**
  75192. * Gets the object extend size
  75193. * @returns the object extend size
  75194. */
  75195. getObjectExtendSize(): Vector3;
  75196. /**
  75197. * Gets the object center
  75198. * @returns The object center
  75199. */
  75200. getObjectCenter(): Vector3;
  75201. /**
  75202. * Get a specific parametes from the options parameter
  75203. * @param paramName The object parameter name
  75204. * @returns The object parameter
  75205. */
  75206. getParam(paramName: string): any;
  75207. /**
  75208. * Sets a specific parameter in the options given to the physics plugin
  75209. * @param paramName The parameter name
  75210. * @param value The value of the parameter
  75211. */
  75212. setParam(paramName: string, value: number): void;
  75213. /**
  75214. * Specifically change the body's mass option. Won't recreate the physics body object
  75215. * @param mass The mass of the physics imposter
  75216. */
  75217. setMass(mass: number): void;
  75218. /**
  75219. * Gets the linear velocity
  75220. * @returns linear velocity or null
  75221. */
  75222. getLinearVelocity(): Nullable<Vector3>;
  75223. /**
  75224. * Sets the linear velocity
  75225. * @param velocity linear velocity or null
  75226. */
  75227. setLinearVelocity(velocity: Nullable<Vector3>): void;
  75228. /**
  75229. * Gets the angular velocity
  75230. * @returns angular velocity or null
  75231. */
  75232. getAngularVelocity(): Nullable<Vector3>;
  75233. /**
  75234. * Sets the angular velocity
  75235. * @param velocity The velocity or null
  75236. */
  75237. setAngularVelocity(velocity: Nullable<Vector3>): void;
  75238. /**
  75239. * Execute a function with the physics plugin native code
  75240. * Provide a function the will have two variables - the world object and the physics body object
  75241. * @param func The function to execute with the physics plugin native code
  75242. */
  75243. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  75244. /**
  75245. * Register a function that will be executed before the physics world is stepping forward
  75246. * @param func The function to execute before the physics world is stepped forward
  75247. */
  75248. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  75249. /**
  75250. * Unregister a function that will be executed before the physics world is stepping forward
  75251. * @param func The function to execute before the physics world is stepped forward
  75252. */
  75253. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  75254. /**
  75255. * Register a function that will be executed after the physics step
  75256. * @param func The function to execute after physics step
  75257. */
  75258. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  75259. /**
  75260. * Unregisters a function that will be executed after the physics step
  75261. * @param func The function to execute after physics step
  75262. */
  75263. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  75264. /**
  75265. * register a function that will be executed when this impostor collides against a different body
  75266. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  75267. * @param func Callback that is executed on collision
  75268. */
  75269. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  75270. /**
  75271. * Unregisters the physics imposter on contact
  75272. * @param collideAgainst The physics object to collide against
  75273. * @param func Callback to execute on collision
  75274. */
  75275. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  75276. private _tmpQuat;
  75277. private _tmpQuat2;
  75278. /**
  75279. * Get the parent rotation
  75280. * @returns The parent rotation
  75281. */
  75282. getParentsRotation(): Quaternion;
  75283. /**
  75284. * this function is executed by the physics engine.
  75285. */
  75286. beforeStep: () => void;
  75287. /**
  75288. * this function is executed by the physics engine
  75289. */
  75290. afterStep: () => void;
  75291. /**
  75292. * Legacy collision detection event support
  75293. */
  75294. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  75295. /**
  75296. * event and body object due to cannon's event-based architecture.
  75297. */
  75298. onCollide: (e: {
  75299. body: any;
  75300. }) => void;
  75301. /**
  75302. * Apply a force
  75303. * @param force The force to apply
  75304. * @param contactPoint The contact point for the force
  75305. * @returns The physics imposter
  75306. */
  75307. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  75308. /**
  75309. * Apply an impulse
  75310. * @param force The impulse force
  75311. * @param contactPoint The contact point for the impulse force
  75312. * @returns The physics imposter
  75313. */
  75314. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  75315. /**
  75316. * A help function to create a joint
  75317. * @param otherImpostor A physics imposter used to create a joint
  75318. * @param jointType The type of joint
  75319. * @param jointData The data for the joint
  75320. * @returns The physics imposter
  75321. */
  75322. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  75323. /**
  75324. * Add a joint to this impostor with a different impostor
  75325. * @param otherImpostor A physics imposter used to add a joint
  75326. * @param joint The joint to add
  75327. * @returns The physics imposter
  75328. */
  75329. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  75330. /**
  75331. * Will keep this body still, in a sleep mode.
  75332. * @returns the physics imposter
  75333. */
  75334. sleep(): PhysicsImpostor;
  75335. /**
  75336. * Wake the body up.
  75337. * @returns The physics imposter
  75338. */
  75339. wakeUp(): PhysicsImpostor;
  75340. /**
  75341. * Clones the physics imposter
  75342. * @param newObject The physics imposter clones to this physics-enabled object
  75343. * @returns A nullable physics imposter
  75344. */
  75345. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  75346. /**
  75347. * Disposes the physics imposter
  75348. */
  75349. dispose(): void;
  75350. /**
  75351. * Sets the delta position
  75352. * @param position The delta position amount
  75353. */
  75354. setDeltaPosition(position: Vector3): void;
  75355. /**
  75356. * Sets the delta rotation
  75357. * @param rotation The delta rotation amount
  75358. */
  75359. setDeltaRotation(rotation: Quaternion): void;
  75360. /**
  75361. * Gets the box size of the physics imposter and stores the result in the input parameter
  75362. * @param result Stores the box size
  75363. * @returns The physics imposter
  75364. */
  75365. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  75366. /**
  75367. * Gets the radius of the physics imposter
  75368. * @returns Radius of the physics imposter
  75369. */
  75370. getRadius(): number;
  75371. /**
  75372. * Sync a bone with this impostor
  75373. * @param bone The bone to sync to the impostor.
  75374. * @param boneMesh The mesh that the bone is influencing.
  75375. * @param jointPivot The pivot of the joint / bone in local space.
  75376. * @param distToJoint Optional distance from the impostor to the joint.
  75377. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  75378. */
  75379. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  75380. /**
  75381. * Sync impostor to a bone
  75382. * @param bone The bone that the impostor will be synced to.
  75383. * @param boneMesh The mesh that the bone is influencing.
  75384. * @param jointPivot The pivot of the joint / bone in local space.
  75385. * @param distToJoint Optional distance from the impostor to the joint.
  75386. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  75387. * @param boneAxis Optional vector3 axis the bone is aligned with
  75388. */
  75389. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  75390. /**
  75391. * No-Imposter type
  75392. */
  75393. static NoImpostor: number;
  75394. /**
  75395. * Sphere-Imposter type
  75396. */
  75397. static SphereImpostor: number;
  75398. /**
  75399. * Box-Imposter type
  75400. */
  75401. static BoxImpostor: number;
  75402. /**
  75403. * Plane-Imposter type
  75404. */
  75405. static PlaneImpostor: number;
  75406. /**
  75407. * Mesh-imposter type
  75408. */
  75409. static MeshImpostor: number;
  75410. /**
  75411. * Cylinder-Imposter type
  75412. */
  75413. static CylinderImpostor: number;
  75414. /**
  75415. * Particle-Imposter type
  75416. */
  75417. static ParticleImpostor: number;
  75418. /**
  75419. * Heightmap-Imposter type
  75420. */
  75421. static HeightmapImpostor: number;
  75422. }
  75423. }
  75424. declare module BABYLON {
  75425. /**
  75426. * Class used to represent a specific level of detail of a mesh
  75427. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  75428. */
  75429. export class MeshLODLevel {
  75430. /** Defines the distance where this level should star being displayed */
  75431. distance: number;
  75432. /** Defines the mesh to use to render this level */
  75433. mesh: Nullable<Mesh>;
  75434. /**
  75435. * Creates a new LOD level
  75436. * @param distance defines the distance where this level should star being displayed
  75437. * @param mesh defines the mesh to use to render this level
  75438. */
  75439. constructor(
  75440. /** Defines the distance where this level should star being displayed */
  75441. distance: number,
  75442. /** Defines the mesh to use to render this level */
  75443. mesh: Nullable<Mesh>);
  75444. }
  75445. /**
  75446. * @hidden
  75447. **/
  75448. export class _CreationDataStorage {
  75449. closePath?: boolean;
  75450. closeArray?: boolean;
  75451. idx: number[];
  75452. dashSize: number;
  75453. gapSize: number;
  75454. path3D: Path3D;
  75455. pathArray: Vector3[][];
  75456. arc: number;
  75457. radius: number;
  75458. cap: number;
  75459. tessellation: number;
  75460. }
  75461. /**
  75462. * @hidden
  75463. **/
  75464. class _InstanceDataStorage {
  75465. visibleInstances: any;
  75466. renderIdForInstances: number[];
  75467. batchCache: _InstancesBatch;
  75468. instancesBufferSize: number;
  75469. instancesBuffer: Nullable<Buffer>;
  75470. instancesData: Float32Array;
  75471. overridenInstanceCount: number;
  75472. }
  75473. /**
  75474. * @hidden
  75475. **/
  75476. export class _InstancesBatch {
  75477. mustReturn: boolean;
  75478. visibleInstances: Nullable<InstancedMesh[]>[];
  75479. renderSelf: boolean[];
  75480. }
  75481. /**
  75482. * Class used to represent renderable models
  75483. */
  75484. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  75485. /**
  75486. * Mesh side orientation : usually the external or front surface
  75487. */
  75488. static readonly FRONTSIDE: number;
  75489. /**
  75490. * Mesh side orientation : usually the internal or back surface
  75491. */
  75492. static readonly BACKSIDE: number;
  75493. /**
  75494. * Mesh side orientation : both internal and external or front and back surfaces
  75495. */
  75496. static readonly DOUBLESIDE: number;
  75497. /**
  75498. * Mesh side orientation : by default, `FRONTSIDE`
  75499. */
  75500. static readonly DEFAULTSIDE: number;
  75501. /**
  75502. * Mesh cap setting : no cap
  75503. */
  75504. static readonly NO_CAP: number;
  75505. /**
  75506. * Mesh cap setting : one cap at the beginning of the mesh
  75507. */
  75508. static readonly CAP_START: number;
  75509. /**
  75510. * Mesh cap setting : one cap at the end of the mesh
  75511. */
  75512. static readonly CAP_END: number;
  75513. /**
  75514. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  75515. */
  75516. static readonly CAP_ALL: number;
  75517. /**
  75518. * Gets the default side orientation.
  75519. * @param orientation the orientation to value to attempt to get
  75520. * @returns the default orientation
  75521. * @hidden
  75522. */
  75523. static _GetDefaultSideOrientation(orientation?: number): number;
  75524. private _onBeforeRenderObservable;
  75525. private _onBeforeBindObservable;
  75526. private _onAfterRenderObservable;
  75527. private _onBeforeDrawObservable;
  75528. /**
  75529. * An event triggered before rendering the mesh
  75530. */
  75531. readonly onBeforeRenderObservable: Observable<Mesh>;
  75532. /**
  75533. * An event triggered before binding the mesh
  75534. */
  75535. readonly onBeforeBindObservable: Observable<Mesh>;
  75536. /**
  75537. * An event triggered after rendering the mesh
  75538. */
  75539. readonly onAfterRenderObservable: Observable<Mesh>;
  75540. /**
  75541. * An event triggered before drawing the mesh
  75542. */
  75543. readonly onBeforeDrawObservable: Observable<Mesh>;
  75544. private _onBeforeDrawObserver;
  75545. /**
  75546. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  75547. */
  75548. onBeforeDraw: () => void;
  75549. /**
  75550. * Gets the delay loading state of the mesh (when delay loading is turned on)
  75551. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  75552. */
  75553. delayLoadState: number;
  75554. /**
  75555. * Gets the list of instances created from this mesh
  75556. * it is not supposed to be modified manually.
  75557. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  75558. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75559. */
  75560. instances: InstancedMesh[];
  75561. /**
  75562. * Gets the file containing delay loading data for this mesh
  75563. */
  75564. delayLoadingFile: string;
  75565. /** @hidden */
  75566. _binaryInfo: any;
  75567. private _LODLevels;
  75568. /**
  75569. * User defined function used to change how LOD level selection is done
  75570. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  75571. */
  75572. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  75573. private _morphTargetManager;
  75574. /**
  75575. * Gets or sets the morph target manager
  75576. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  75577. */
  75578. morphTargetManager: Nullable<MorphTargetManager>;
  75579. /** @hidden */
  75580. _creationDataStorage: Nullable<_CreationDataStorage>;
  75581. /** @hidden */
  75582. _geometry: Nullable<Geometry>;
  75583. /** @hidden */
  75584. _delayInfo: Array<string>;
  75585. /** @hidden */
  75586. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  75587. /** @hidden */
  75588. _instanceDataStorage: _InstanceDataStorage;
  75589. private _effectiveMaterial;
  75590. /** @hidden */
  75591. _shouldGenerateFlatShading: boolean;
  75592. private _preActivateId;
  75593. /** @hidden */
  75594. _originalBuilderSideOrientation: number;
  75595. /**
  75596. * Use this property to change the original side orientation defined at construction time
  75597. */
  75598. overrideMaterialSideOrientation: Nullable<number>;
  75599. private _areNormalsFrozen;
  75600. private _sourcePositions;
  75601. private _sourceNormals;
  75602. private _source;
  75603. private meshMap;
  75604. /**
  75605. * Gets the source mesh (the one used to clone this one from)
  75606. */
  75607. readonly source: Nullable<Mesh>;
  75608. /**
  75609. * Gets or sets a boolean indicating that this mesh does not use index buffer
  75610. */
  75611. isUnIndexed: boolean;
  75612. /**
  75613. * @constructor
  75614. * @param name The value used by scene.getMeshByName() to do a lookup.
  75615. * @param scene The scene to add this mesh to.
  75616. * @param parent The parent of this mesh, if it has one
  75617. * @param source An optional Mesh from which geometry is shared, cloned.
  75618. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75619. * When false, achieved by calling a clone(), also passing False.
  75620. * This will make creation of children, recursive.
  75621. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  75622. */
  75623. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  75624. /**
  75625. * Gets the class name
  75626. * @returns the string "Mesh".
  75627. */
  75628. getClassName(): string;
  75629. /** @hidden */
  75630. readonly _isMesh: boolean;
  75631. /**
  75632. * Returns a description of this mesh
  75633. * @param fullDetails define if full details about this mesh must be used
  75634. * @returns a descriptive string representing this mesh
  75635. */
  75636. toString(fullDetails?: boolean): string;
  75637. /** @hidden */
  75638. _unBindEffect(): void;
  75639. /**
  75640. * Gets a boolean indicating if this mesh has LOD
  75641. */
  75642. readonly hasLODLevels: boolean;
  75643. /**
  75644. * Gets the list of MeshLODLevel associated with the current mesh
  75645. * @returns an array of MeshLODLevel
  75646. */
  75647. getLODLevels(): MeshLODLevel[];
  75648. private _sortLODLevels;
  75649. /**
  75650. * Add a mesh as LOD level triggered at the given distance.
  75651. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75652. * @param distance The distance from the center of the object to show this level
  75653. * @param mesh The mesh to be added as LOD level (can be null)
  75654. * @return This mesh (for chaining)
  75655. */
  75656. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  75657. /**
  75658. * Returns the LOD level mesh at the passed distance or null if not found.
  75659. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75660. * @param distance The distance from the center of the object to show this level
  75661. * @returns a Mesh or `null`
  75662. */
  75663. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  75664. /**
  75665. * Remove a mesh from the LOD array
  75666. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75667. * @param mesh defines the mesh to be removed
  75668. * @return This mesh (for chaining)
  75669. */
  75670. removeLODLevel(mesh: Mesh): Mesh;
  75671. /**
  75672. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  75673. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75674. * @param camera defines the camera to use to compute distance
  75675. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  75676. * @return This mesh (for chaining)
  75677. */
  75678. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  75679. /**
  75680. * Gets the mesh internal Geometry object
  75681. */
  75682. readonly geometry: Nullable<Geometry>;
  75683. /**
  75684. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  75685. * @returns the total number of vertices
  75686. */
  75687. getTotalVertices(): number;
  75688. /**
  75689. * Returns the content of an associated vertex buffer
  75690. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  75691. * - VertexBuffer.PositionKind
  75692. * - VertexBuffer.UVKind
  75693. * - VertexBuffer.UV2Kind
  75694. * - VertexBuffer.UV3Kind
  75695. * - VertexBuffer.UV4Kind
  75696. * - VertexBuffer.UV5Kind
  75697. * - VertexBuffer.UV6Kind
  75698. * - VertexBuffer.ColorKind
  75699. * - VertexBuffer.MatricesIndicesKind
  75700. * - VertexBuffer.MatricesIndicesExtraKind
  75701. * - VertexBuffer.MatricesWeightsKind
  75702. * - VertexBuffer.MatricesWeightsExtraKind
  75703. * @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
  75704. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  75705. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  75706. */
  75707. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  75708. /**
  75709. * Returns the mesh VertexBuffer object from the requested `kind`
  75710. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  75711. * - VertexBuffer.PositionKind
  75712. * - VertexBuffer.UVKind
  75713. * - VertexBuffer.UV2Kind
  75714. * - VertexBuffer.UV3Kind
  75715. * - VertexBuffer.UV4Kind
  75716. * - VertexBuffer.UV5Kind
  75717. * - VertexBuffer.UV6Kind
  75718. * - VertexBuffer.ColorKind
  75719. * - VertexBuffer.MatricesIndicesKind
  75720. * - VertexBuffer.MatricesIndicesExtraKind
  75721. * - VertexBuffer.MatricesWeightsKind
  75722. * - VertexBuffer.MatricesWeightsExtraKind
  75723. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  75724. */
  75725. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  75726. /**
  75727. * Tests if a specific vertex buffer is associated with this mesh
  75728. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  75729. * - VertexBuffer.PositionKind
  75730. * - VertexBuffer.UVKind
  75731. * - VertexBuffer.UV2Kind
  75732. * - VertexBuffer.UV3Kind
  75733. * - VertexBuffer.UV4Kind
  75734. * - VertexBuffer.UV5Kind
  75735. * - VertexBuffer.UV6Kind
  75736. * - VertexBuffer.ColorKind
  75737. * - VertexBuffer.MatricesIndicesKind
  75738. * - VertexBuffer.MatricesIndicesExtraKind
  75739. * - VertexBuffer.MatricesWeightsKind
  75740. * - VertexBuffer.MatricesWeightsExtraKind
  75741. * @returns a boolean
  75742. */
  75743. isVerticesDataPresent(kind: string): boolean;
  75744. /**
  75745. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  75746. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  75747. * - VertexBuffer.PositionKind
  75748. * - VertexBuffer.UVKind
  75749. * - VertexBuffer.UV2Kind
  75750. * - VertexBuffer.UV3Kind
  75751. * - VertexBuffer.UV4Kind
  75752. * - VertexBuffer.UV5Kind
  75753. * - VertexBuffer.UV6Kind
  75754. * - VertexBuffer.ColorKind
  75755. * - VertexBuffer.MatricesIndicesKind
  75756. * - VertexBuffer.MatricesIndicesExtraKind
  75757. * - VertexBuffer.MatricesWeightsKind
  75758. * - VertexBuffer.MatricesWeightsExtraKind
  75759. * @returns a boolean
  75760. */
  75761. isVertexBufferUpdatable(kind: string): boolean;
  75762. /**
  75763. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  75764. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  75765. * - VertexBuffer.PositionKind
  75766. * - VertexBuffer.UVKind
  75767. * - VertexBuffer.UV2Kind
  75768. * - VertexBuffer.UV3Kind
  75769. * - VertexBuffer.UV4Kind
  75770. * - VertexBuffer.UV5Kind
  75771. * - VertexBuffer.UV6Kind
  75772. * - VertexBuffer.ColorKind
  75773. * - VertexBuffer.MatricesIndicesKind
  75774. * - VertexBuffer.MatricesIndicesExtraKind
  75775. * - VertexBuffer.MatricesWeightsKind
  75776. * - VertexBuffer.MatricesWeightsExtraKind
  75777. * @returns an array of strings
  75778. */
  75779. getVerticesDataKinds(): string[];
  75780. /**
  75781. * Returns a positive integer : the total number of indices in this mesh geometry.
  75782. * @returns the numner of indices or zero if the mesh has no geometry.
  75783. */
  75784. getTotalIndices(): number;
  75785. /**
  75786. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75787. * @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.
  75788. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  75789. * @returns the indices array or an empty array if the mesh has no geometry
  75790. */
  75791. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  75792. readonly isBlocked: boolean;
  75793. /**
  75794. * Determine if the current mesh is ready to be rendered
  75795. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75796. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  75797. * @returns true if all associated assets are ready (material, textures, shaders)
  75798. */
  75799. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  75800. /**
  75801. * 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.
  75802. */
  75803. readonly areNormalsFrozen: boolean;
  75804. /**
  75805. * 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.
  75806. * @returns the current mesh
  75807. */
  75808. freezeNormals(): Mesh;
  75809. /**
  75810. * 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
  75811. * @returns the current mesh
  75812. */
  75813. unfreezeNormals(): Mesh;
  75814. /**
  75815. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  75816. */
  75817. overridenInstanceCount: number;
  75818. /** @hidden */
  75819. _preActivate(): Mesh;
  75820. /** @hidden */
  75821. _preActivateForIntermediateRendering(renderId: number): Mesh;
  75822. /** @hidden */
  75823. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  75824. /**
  75825. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75826. * This means the mesh underlying bounding box and sphere are recomputed.
  75827. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75828. * @returns the current mesh
  75829. */
  75830. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  75831. /** @hidden */
  75832. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  75833. /**
  75834. * This function will subdivide the mesh into multiple submeshes
  75835. * @param count defines the expected number of submeshes
  75836. */
  75837. subdivide(count: number): void;
  75838. /**
  75839. * Copy a FloatArray into a specific associated vertex buffer
  75840. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  75841. * - VertexBuffer.PositionKind
  75842. * - VertexBuffer.UVKind
  75843. * - VertexBuffer.UV2Kind
  75844. * - VertexBuffer.UV3Kind
  75845. * - VertexBuffer.UV4Kind
  75846. * - VertexBuffer.UV5Kind
  75847. * - VertexBuffer.UV6Kind
  75848. * - VertexBuffer.ColorKind
  75849. * - VertexBuffer.MatricesIndicesKind
  75850. * - VertexBuffer.MatricesIndicesExtraKind
  75851. * - VertexBuffer.MatricesWeightsKind
  75852. * - VertexBuffer.MatricesWeightsExtraKind
  75853. * @param data defines the data source
  75854. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  75855. * @param stride defines the data stride size (can be null)
  75856. * @returns the current mesh
  75857. */
  75858. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75859. /**
  75860. * Flags an associated vertex buffer as updatable
  75861. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  75862. * - VertexBuffer.PositionKind
  75863. * - VertexBuffer.UVKind
  75864. * - VertexBuffer.UV2Kind
  75865. * - VertexBuffer.UV3Kind
  75866. * - VertexBuffer.UV4Kind
  75867. * - VertexBuffer.UV5Kind
  75868. * - VertexBuffer.UV6Kind
  75869. * - VertexBuffer.ColorKind
  75870. * - VertexBuffer.MatricesIndicesKind
  75871. * - VertexBuffer.MatricesIndicesExtraKind
  75872. * - VertexBuffer.MatricesWeightsKind
  75873. * - VertexBuffer.MatricesWeightsExtraKind
  75874. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  75875. */
  75876. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  75877. /**
  75878. * Sets the mesh global Vertex Buffer
  75879. * @param buffer defines the buffer to use
  75880. * @returns the current mesh
  75881. */
  75882. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  75883. /**
  75884. * Update a specific associated vertex buffer
  75885. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  75886. * - VertexBuffer.PositionKind
  75887. * - VertexBuffer.UVKind
  75888. * - VertexBuffer.UV2Kind
  75889. * - VertexBuffer.UV3Kind
  75890. * - VertexBuffer.UV4Kind
  75891. * - VertexBuffer.UV5Kind
  75892. * - VertexBuffer.UV6Kind
  75893. * - VertexBuffer.ColorKind
  75894. * - VertexBuffer.MatricesIndicesKind
  75895. * - VertexBuffer.MatricesIndicesExtraKind
  75896. * - VertexBuffer.MatricesWeightsKind
  75897. * - VertexBuffer.MatricesWeightsExtraKind
  75898. * @param data defines the data source
  75899. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  75900. * @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)
  75901. * @returns the current mesh
  75902. */
  75903. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  75904. /**
  75905. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  75906. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  75907. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  75908. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  75909. * @returns the current mesh
  75910. */
  75911. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  75912. /**
  75913. * Creates a un-shared specific occurence of the geometry for the mesh.
  75914. * @returns the current mesh
  75915. */
  75916. makeGeometryUnique(): Mesh;
  75917. /**
  75918. * Set the index buffer of this mesh
  75919. * @param indices defines the source data
  75920. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  75921. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  75922. * @returns the current mesh
  75923. */
  75924. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  75925. /**
  75926. * Update the current index buffer
  75927. * @param indices defines the source data
  75928. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  75929. * @returns the current mesh
  75930. */
  75931. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  75932. /**
  75933. * Invert the geometry to move from a right handed system to a left handed one.
  75934. * @returns the current mesh
  75935. */
  75936. toLeftHanded(): Mesh;
  75937. /** @hidden */
  75938. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  75939. /** @hidden */
  75940. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  75941. /**
  75942. * Registers for this mesh a javascript function called just before the rendering process
  75943. * @param func defines the function to call before rendering this mesh
  75944. * @returns the current mesh
  75945. */
  75946. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  75947. /**
  75948. * Disposes a previously registered javascript function called before the rendering
  75949. * @param func defines the function to remove
  75950. * @returns the current mesh
  75951. */
  75952. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  75953. /**
  75954. * Registers for this mesh a javascript function called just after the rendering is complete
  75955. * @param func defines the function to call after rendering this mesh
  75956. * @returns the current mesh
  75957. */
  75958. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  75959. /**
  75960. * Disposes a previously registered javascript function called after the rendering.
  75961. * @param func defines the function to remove
  75962. * @returns the current mesh
  75963. */
  75964. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  75965. /** @hidden */
  75966. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  75967. /** @hidden */
  75968. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  75969. /** @hidden */
  75970. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  75971. /**
  75972. * 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
  75973. * @param subMesh defines the subMesh to render
  75974. * @param enableAlphaMode defines if alpha mode can be changed
  75975. * @returns the current mesh
  75976. */
  75977. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  75978. private _onBeforeDraw;
  75979. /**
  75980. * Renormalize the mesh and patch it up if there are no weights
  75981. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  75982. * However in the case of zero weights then we set just a single influence to 1.
  75983. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  75984. */
  75985. cleanMatrixWeights(): void;
  75986. private normalizeSkinFourWeights;
  75987. private normalizeSkinWeightsAndExtra;
  75988. /**
  75989. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  75990. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  75991. * the user know there was an issue with importing the mesh
  75992. * @returns a validation object with skinned, valid and report string
  75993. */
  75994. validateSkinning(): {
  75995. skinned: boolean;
  75996. valid: boolean;
  75997. report: string;
  75998. };
  75999. /** @hidden */
  76000. _checkDelayState(): Mesh;
  76001. private _queueLoad;
  76002. /**
  76003. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  76004. * A mesh is in the frustum if its bounding box intersects the frustum
  76005. * @param frustumPlanes defines the frustum to test
  76006. * @returns true if the mesh is in the frustum planes
  76007. */
  76008. isInFrustum(frustumPlanes: Plane[]): boolean;
  76009. /**
  76010. * Sets the mesh material by the material or multiMaterial `id` property
  76011. * @param id is a string identifying the material or the multiMaterial
  76012. * @returns the current mesh
  76013. */
  76014. setMaterialByID(id: string): Mesh;
  76015. /**
  76016. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  76017. * @returns an array of IAnimatable
  76018. */
  76019. getAnimatables(): IAnimatable[];
  76020. /**
  76021. * Modifies the mesh geometry according to the passed transformation matrix.
  76022. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  76023. * The mesh normals are modified using the same transformation.
  76024. * Note that, under the hood, this method sets a new VertexBuffer each call.
  76025. * @param transform defines the transform matrix to use
  76026. * @see http://doc.babylonjs.com/resources/baking_transformations
  76027. * @returns the current mesh
  76028. */
  76029. bakeTransformIntoVertices(transform: Matrix): Mesh;
  76030. /**
  76031. * Modifies the mesh geometry according to its own current World Matrix.
  76032. * The mesh World Matrix is then reset.
  76033. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  76034. * Note that, under the hood, this method sets a new VertexBuffer each call.
  76035. * @see http://doc.babylonjs.com/resources/baking_transformations
  76036. * @returns the current mesh
  76037. */
  76038. bakeCurrentTransformIntoVertices(): Mesh;
  76039. /** @hidden */
  76040. readonly _positions: Nullable<Vector3[]>;
  76041. /** @hidden */
  76042. _resetPointsArrayCache(): Mesh;
  76043. /** @hidden */
  76044. _generatePointsArray(): boolean;
  76045. /**
  76046. * Returns a new Mesh object generated from the current mesh properties.
  76047. * This method must not get confused with createInstance()
  76048. * @param name is a string, the name given to the new mesh
  76049. * @param newParent can be any Node object (default `null`)
  76050. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  76051. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  76052. * @returns a new mesh
  76053. */
  76054. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  76055. /**
  76056. * Releases resources associated with this mesh.
  76057. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  76058. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  76059. */
  76060. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76061. /**
  76062. * Modifies the mesh geometry according to a displacement map.
  76063. * 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.
  76064. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  76065. * @param url is a string, the URL from the image file is to be downloaded.
  76066. * @param minHeight is the lower limit of the displacement.
  76067. * @param maxHeight is the upper limit of the displacement.
  76068. * @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.
  76069. * @param uvOffset is an optional vector2 used to offset UV.
  76070. * @param uvScale is an optional vector2 used to scale UV.
  76071. * @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.
  76072. * @returns the Mesh.
  76073. */
  76074. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  76075. /**
  76076. * Modifies the mesh geometry according to a displacementMap buffer.
  76077. * 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.
  76078. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  76079. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  76080. * @param heightMapWidth is the width of the buffer image.
  76081. * @param heightMapHeight is the height of the buffer image.
  76082. * @param minHeight is the lower limit of the displacement.
  76083. * @param maxHeight is the upper limit of the displacement.
  76084. * @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.
  76085. * @param uvOffset is an optional vector2 used to offset UV.
  76086. * @param uvScale is an optional vector2 used to scale UV.
  76087. * @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.
  76088. * @returns the Mesh.
  76089. */
  76090. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  76091. /**
  76092. * Modify the mesh to get a flat shading rendering.
  76093. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  76094. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  76095. * @returns current mesh
  76096. */
  76097. convertToFlatShadedMesh(): Mesh;
  76098. /**
  76099. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  76100. * In other words, more vertices, no more indices and a single bigger VBO.
  76101. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  76102. * @returns current mesh
  76103. */
  76104. convertToUnIndexedMesh(): Mesh;
  76105. /**
  76106. * Inverses facet orientations.
  76107. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  76108. * @param flipNormals will also inverts the normals
  76109. * @returns current mesh
  76110. */
  76111. flipFaces(flipNormals?: boolean): Mesh;
  76112. /** @hidden */
  76113. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  76114. /** @hidden */
  76115. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  76116. /**
  76117. * Creates a new InstancedMesh object from the mesh model.
  76118. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76119. * @param name defines the name of the new instance
  76120. * @returns a new InstancedMesh
  76121. */
  76122. createInstance(name: string): InstancedMesh;
  76123. /**
  76124. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  76125. * After this call, all the mesh instances have the same submeshes than the current mesh.
  76126. * @returns the current mesh
  76127. */
  76128. synchronizeInstances(): Mesh;
  76129. /**
  76130. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  76131. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  76132. * This should be used together with the simplification to avoid disappearing triangles.
  76133. * @param successCallback an optional success callback to be called after the optimization finished.
  76134. * @returns the current mesh
  76135. */
  76136. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  76137. /**
  76138. * Serialize current mesh
  76139. * @param serializationObject defines the object which will receive the serialization data
  76140. */
  76141. serialize(serializationObject: any): void;
  76142. /** @hidden */
  76143. _syncGeometryWithMorphTargetManager(): void;
  76144. /** @hidden */
  76145. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  76146. /**
  76147. * Returns a new Mesh object parsed from the source provided.
  76148. * @param parsedMesh is the source
  76149. * @param scene defines the hosting scene
  76150. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  76151. * @returns a new Mesh
  76152. */
  76153. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  76154. /**
  76155. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  76156. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  76157. * @param name defines the name of the mesh to create
  76158. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  76159. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  76160. * @param closePath creates a seam between the first and the last points of each path of the path array
  76161. * @param offset is taken in account only if the `pathArray` is containing a single path
  76162. * @param scene defines the hosting scene
  76163. * @param updatable defines if the mesh must be flagged as updatable
  76164. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76165. * @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)
  76166. * @returns a new Mesh
  76167. */
  76168. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  76169. /**
  76170. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  76171. * @param name defines the name of the mesh to create
  76172. * @param radius sets the radius size (float) of the polygon (default 0.5)
  76173. * @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
  76174. * @param scene defines the hosting scene
  76175. * @param updatable defines if the mesh must be flagged as updatable
  76176. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76177. * @returns a new Mesh
  76178. */
  76179. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  76180. /**
  76181. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  76182. * @param name defines the name of the mesh to create
  76183. * @param size sets the size (float) of each box side (default 1)
  76184. * @param scene defines the hosting scene
  76185. * @param updatable defines if the mesh must be flagged as updatable
  76186. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76187. * @returns a new Mesh
  76188. */
  76189. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  76190. /**
  76191. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  76192. * @param name defines the name of the mesh to create
  76193. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  76194. * @param diameter sets the diameter size (float) of the sphere (default 1)
  76195. * @param scene defines the hosting scene
  76196. * @param updatable defines if the mesh must be flagged as updatable
  76197. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76198. * @returns a new Mesh
  76199. */
  76200. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76201. /**
  76202. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  76203. * @param name defines the name of the mesh to create
  76204. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  76205. * @param diameterTop set the top cap diameter (floats, default 1)
  76206. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  76207. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  76208. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  76209. * @param scene defines the hosting scene
  76210. * @param updatable defines if the mesh must be flagged as updatable
  76211. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76212. * @returns a new Mesh
  76213. */
  76214. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  76215. /**
  76216. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  76217. * @param name defines the name of the mesh to create
  76218. * @param diameter sets the diameter size (float) of the torus (default 1)
  76219. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  76220. * @param tessellation sets the number of torus sides (postive integer, default 16)
  76221. * @param scene defines the hosting scene
  76222. * @param updatable defines if the mesh must be flagged as updatable
  76223. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76224. * @returns a new Mesh
  76225. */
  76226. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76227. /**
  76228. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  76229. * @param name defines the name of the mesh to create
  76230. * @param radius sets the global radius size (float) of the torus knot (default 2)
  76231. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  76232. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  76233. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  76234. * @param p the number of windings on X axis (positive integers, default 2)
  76235. * @param q the number of windings on Y axis (positive integers, default 3)
  76236. * @param scene defines the hosting scene
  76237. * @param updatable defines if the mesh must be flagged as updatable
  76238. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76239. * @returns a new Mesh
  76240. */
  76241. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76242. /**
  76243. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  76244. * @param name defines the name of the mesh to create
  76245. * @param points is an array successive Vector3
  76246. * @param scene defines the hosting scene
  76247. * @param updatable defines if the mesh must be flagged as updatable
  76248. * @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).
  76249. * @returns a new Mesh
  76250. */
  76251. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  76252. /**
  76253. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  76254. * @param name defines the name of the mesh to create
  76255. * @param points is an array successive Vector3
  76256. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  76257. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  76258. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  76259. * @param scene defines the hosting scene
  76260. * @param updatable defines if the mesh must be flagged as updatable
  76261. * @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)
  76262. * @returns a new Mesh
  76263. */
  76264. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  76265. /**
  76266. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  76267. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  76268. * 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.
  76269. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  76270. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  76271. * Remember you can only change the shape positions, not their number when updating a polygon.
  76272. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  76273. * @param name defines the name of the mesh to create
  76274. * @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
  76275. * @param scene defines the hosting scene
  76276. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  76277. * @param updatable defines if the mesh must be flagged as updatable
  76278. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76279. * @param earcutInjection can be used to inject your own earcut reference
  76280. * @returns a new Mesh
  76281. */
  76282. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  76283. /**
  76284. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  76285. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  76286. * @param name defines the name of the mesh to create
  76287. * @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
  76288. * @param depth defines the height of extrusion
  76289. * @param scene defines the hosting scene
  76290. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  76291. * @param updatable defines if the mesh must be flagged as updatable
  76292. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76293. * @param earcutInjection can be used to inject your own earcut reference
  76294. * @returns a new Mesh
  76295. */
  76296. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  76297. /**
  76298. * Creates an extruded shape mesh.
  76299. * 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
  76300. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  76301. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  76302. * @param name defines the name of the mesh to create
  76303. * @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
  76304. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  76305. * @param scale is the value to scale the shape
  76306. * @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
  76307. * @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
  76308. * @param scene defines the hosting scene
  76309. * @param updatable defines if the mesh must be flagged as updatable
  76310. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76311. * @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)
  76312. * @returns a new Mesh
  76313. */
  76314. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  76315. /**
  76316. * Creates an custom extruded shape mesh.
  76317. * The custom extrusion is a parametric shape.
  76318. * It has no predefined shape. Its final shape will depend on the input parameters.
  76319. * Please consider using the same method from the MeshBuilder class instead
  76320. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  76321. * @param name defines the name of the mesh to create
  76322. * @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
  76323. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  76324. * @param scaleFunction is a custom Javascript function called on each path point
  76325. * @param rotationFunction is a custom Javascript function called on each path point
  76326. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  76327. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  76328. * @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
  76329. * @param scene defines the hosting scene
  76330. * @param updatable defines if the mesh must be flagged as updatable
  76331. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76332. * @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)
  76333. * @returns a new Mesh
  76334. */
  76335. 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;
  76336. /**
  76337. * Creates lathe mesh.
  76338. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  76339. * Please consider using the same method from the MeshBuilder class instead
  76340. * @param name defines the name of the mesh to create
  76341. * @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
  76342. * @param radius is the radius value of the lathe
  76343. * @param tessellation is the side number of the lathe.
  76344. * @param scene defines the hosting scene
  76345. * @param updatable defines if the mesh must be flagged as updatable
  76346. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76347. * @returns a new Mesh
  76348. */
  76349. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76350. /**
  76351. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  76352. * @param name defines the name of the mesh to create
  76353. * @param size sets the size (float) of both sides of the plane at once (default 1)
  76354. * @param scene defines the hosting scene
  76355. * @param updatable defines if the mesh must be flagged as updatable
  76356. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76357. * @returns a new Mesh
  76358. */
  76359. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76360. /**
  76361. * Creates a ground mesh.
  76362. * Please consider using the same method from the MeshBuilder class instead
  76363. * @param name defines the name of the mesh to create
  76364. * @param width set the width of the ground
  76365. * @param height set the height of the ground
  76366. * @param subdivisions sets the number of subdivisions per side
  76367. * @param scene defines the hosting scene
  76368. * @param updatable defines if the mesh must be flagged as updatable
  76369. * @returns a new Mesh
  76370. */
  76371. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  76372. /**
  76373. * Creates a tiled ground mesh.
  76374. * Please consider using the same method from the MeshBuilder class instead
  76375. * @param name defines the name of the mesh to create
  76376. * @param xmin set the ground minimum X coordinate
  76377. * @param zmin set the ground minimum Y coordinate
  76378. * @param xmax set the ground maximum X coordinate
  76379. * @param zmax set the ground maximum Z coordinate
  76380. * @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
  76381. * @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
  76382. * @param scene defines the hosting scene
  76383. * @param updatable defines if the mesh must be flagged as updatable
  76384. * @returns a new Mesh
  76385. */
  76386. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  76387. w: number;
  76388. h: number;
  76389. }, precision: {
  76390. w: number;
  76391. h: number;
  76392. }, scene: Scene, updatable?: boolean): Mesh;
  76393. /**
  76394. * Creates a ground mesh from a height map.
  76395. * Please consider using the same method from the MeshBuilder class instead
  76396. * @see http://doc.babylonjs.com/babylon101/height_map
  76397. * @param name defines the name of the mesh to create
  76398. * @param url sets the URL of the height map image resource
  76399. * @param width set the ground width size
  76400. * @param height set the ground height size
  76401. * @param subdivisions sets the number of subdivision per side
  76402. * @param minHeight is the minimum altitude on the ground
  76403. * @param maxHeight is the maximum altitude on the ground
  76404. * @param scene defines the hosting scene
  76405. * @param updatable defines if the mesh must be flagged as updatable
  76406. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  76407. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  76408. * @returns a new Mesh
  76409. */
  76410. 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;
  76411. /**
  76412. * Creates a tube mesh.
  76413. * The tube is a parametric shape.
  76414. * It has no predefined shape. Its final shape will depend on the input parameters.
  76415. * Please consider using the same method from the MeshBuilder class instead
  76416. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  76417. * @param name defines the name of the mesh to create
  76418. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  76419. * @param radius sets the tube radius size
  76420. * @param tessellation is the number of sides on the tubular surface
  76421. * @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
  76422. * @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
  76423. * @param scene defines the hosting scene
  76424. * @param updatable defines if the mesh must be flagged as updatable
  76425. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76426. * @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)
  76427. * @returns a new Mesh
  76428. */
  76429. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  76430. (i: number, distance: number): number;
  76431. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  76432. /**
  76433. * Creates a polyhedron mesh.
  76434. * Please consider using the same method from the MeshBuilder class instead.
  76435. * * 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
  76436. * * The parameter `size` (positive float, default 1) sets the polygon size
  76437. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  76438. * * 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`
  76439. * * 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
  76440. * * 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)`)
  76441. * * 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
  76442. * * 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
  76443. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  76444. * * If you create a double-sided mesh, you can choose what parts of 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
  76445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76446. * @param name defines the name of the mesh to create
  76447. * @param options defines the options used to create the mesh
  76448. * @param scene defines the hosting scene
  76449. * @returns a new Mesh
  76450. */
  76451. static CreatePolyhedron(name: string, options: {
  76452. type?: number;
  76453. size?: number;
  76454. sizeX?: number;
  76455. sizeY?: number;
  76456. sizeZ?: number;
  76457. custom?: any;
  76458. faceUV?: Vector4[];
  76459. faceColors?: Color4[];
  76460. updatable?: boolean;
  76461. sideOrientation?: number;
  76462. }, scene: Scene): Mesh;
  76463. /**
  76464. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  76465. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  76466. * * 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`)
  76467. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  76468. * * 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
  76469. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  76470. * * If you create a double-sided mesh, you can choose what parts of 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
  76471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76472. * @param name defines the name of the mesh
  76473. * @param options defines the options used to create the mesh
  76474. * @param scene defines the hosting scene
  76475. * @returns a new Mesh
  76476. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  76477. */
  76478. static CreateIcoSphere(name: string, options: {
  76479. radius?: number;
  76480. flat?: boolean;
  76481. subdivisions?: number;
  76482. sideOrientation?: number;
  76483. updatable?: boolean;
  76484. }, scene: Scene): Mesh;
  76485. /**
  76486. * Creates a decal mesh.
  76487. * Please consider using the same method from the MeshBuilder class instead.
  76488. * A decal is a mesh usually applied as a model onto the surface of another mesh
  76489. * @param name defines the name of the mesh
  76490. * @param sourceMesh defines the mesh receiving the decal
  76491. * @param position sets the position of the decal in world coordinates
  76492. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  76493. * @param size sets the decal scaling
  76494. * @param angle sets the angle to rotate the decal
  76495. * @returns a new Mesh
  76496. */
  76497. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  76498. /**
  76499. * Prepare internal position array for software CPU skinning
  76500. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  76501. */
  76502. setPositionsForCPUSkinning(): Float32Array;
  76503. /**
  76504. * Prepare internal normal array for software CPU skinning
  76505. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  76506. */
  76507. setNormalsForCPUSkinning(): Float32Array;
  76508. /**
  76509. * Updates the vertex buffer by applying transformation from the bones
  76510. * @param skeleton defines the skeleton to apply to current mesh
  76511. * @returns the current mesh
  76512. */
  76513. applySkeleton(skeleton: Skeleton): Mesh;
  76514. /**
  76515. * 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
  76516. * @param meshes defines the list of meshes to scan
  76517. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  76518. */
  76519. static MinMax(meshes: AbstractMesh[]): {
  76520. min: Vector3;
  76521. max: Vector3;
  76522. };
  76523. /**
  76524. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  76525. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  76526. * @returns a vector3
  76527. */
  76528. static Center(meshesOrMinMaxVector: {
  76529. min: Vector3;
  76530. max: Vector3;
  76531. } | AbstractMesh[]): Vector3;
  76532. /**
  76533. * Merge the array of meshes into a single mesh for performance reasons.
  76534. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  76535. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  76536. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  76537. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  76538. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  76539. * @returns a new mesh
  76540. */
  76541. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  76542. /** @hidden */
  76543. addInstance(instance: InstancedMesh): void;
  76544. /** @hidden */
  76545. removeInstance(instance: InstancedMesh): void;
  76546. }
  76547. }
  76548. declare module BABYLON {
  76549. /**
  76550. * Base class for the main features of a material in Babylon.js
  76551. */
  76552. export class Material implements IAnimatable {
  76553. /**
  76554. * Returns the triangle fill mode
  76555. */
  76556. static readonly TriangleFillMode: number;
  76557. /**
  76558. * Returns the wireframe mode
  76559. */
  76560. static readonly WireFrameFillMode: number;
  76561. /**
  76562. * Returns the point fill mode
  76563. */
  76564. static readonly PointFillMode: number;
  76565. /**
  76566. * Returns the point list draw mode
  76567. */
  76568. static readonly PointListDrawMode: number;
  76569. /**
  76570. * Returns the line list draw mode
  76571. */
  76572. static readonly LineListDrawMode: number;
  76573. /**
  76574. * Returns the line loop draw mode
  76575. */
  76576. static readonly LineLoopDrawMode: number;
  76577. /**
  76578. * Returns the line strip draw mode
  76579. */
  76580. static readonly LineStripDrawMode: number;
  76581. /**
  76582. * Returns the triangle strip draw mode
  76583. */
  76584. static readonly TriangleStripDrawMode: number;
  76585. /**
  76586. * Returns the triangle fan draw mode
  76587. */
  76588. static readonly TriangleFanDrawMode: number;
  76589. /**
  76590. * Stores the clock-wise side orientation
  76591. */
  76592. static readonly ClockWiseSideOrientation: number;
  76593. /**
  76594. * Stores the counter clock-wise side orientation
  76595. */
  76596. static readonly CounterClockWiseSideOrientation: number;
  76597. /**
  76598. * The dirty texture flag value
  76599. */
  76600. static readonly TextureDirtyFlag: number;
  76601. /**
  76602. * The dirty light flag value
  76603. */
  76604. static readonly LightDirtyFlag: number;
  76605. /**
  76606. * The dirty fresnel flag value
  76607. */
  76608. static readonly FresnelDirtyFlag: number;
  76609. /**
  76610. * The dirty attribute flag value
  76611. */
  76612. static readonly AttributesDirtyFlag: number;
  76613. /**
  76614. * The dirty misc flag value
  76615. */
  76616. static readonly MiscDirtyFlag: number;
  76617. /**
  76618. * The all dirty flag value
  76619. */
  76620. static readonly AllDirtyFlag: number;
  76621. /**
  76622. * The ID of the material
  76623. */
  76624. id: string;
  76625. /**
  76626. * Gets or sets the unique id of the material
  76627. */
  76628. uniqueId: number;
  76629. /**
  76630. * The name of the material
  76631. */
  76632. name: string;
  76633. /**
  76634. * Gets or sets user defined metadata
  76635. */
  76636. metadata: any;
  76637. /**
  76638. * For internal use only. Please do not use.
  76639. */
  76640. reservedDataStore: any;
  76641. /**
  76642. * Specifies if the ready state should be checked on each call
  76643. */
  76644. checkReadyOnEveryCall: boolean;
  76645. /**
  76646. * Specifies if the ready state should be checked once
  76647. */
  76648. checkReadyOnlyOnce: boolean;
  76649. /**
  76650. * The state of the material
  76651. */
  76652. state: string;
  76653. /**
  76654. * The alpha value of the material
  76655. */
  76656. protected _alpha: number;
  76657. /**
  76658. * Sets the alpha value of the material
  76659. */
  76660. /**
  76661. * Gets the alpha value of the material
  76662. */
  76663. alpha: number;
  76664. /**
  76665. * Specifies if back face culling is enabled
  76666. */
  76667. protected _backFaceCulling: boolean;
  76668. /**
  76669. * Sets the back-face culling state
  76670. */
  76671. /**
  76672. * Gets the back-face culling state
  76673. */
  76674. backFaceCulling: boolean;
  76675. /**
  76676. * Stores the value for side orientation
  76677. */
  76678. sideOrientation: number;
  76679. /**
  76680. * Callback triggered when the material is compiled
  76681. */
  76682. onCompiled: (effect: Effect) => void;
  76683. /**
  76684. * Callback triggered when an error occurs
  76685. */
  76686. onError: (effect: Effect, errors: string) => void;
  76687. /**
  76688. * Callback triggered to get the render target textures
  76689. */
  76690. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  76691. /**
  76692. * Gets a boolean indicating that current material needs to register RTT
  76693. */
  76694. readonly hasRenderTargetTextures: boolean;
  76695. /**
  76696. * Specifies if the material should be serialized
  76697. */
  76698. doNotSerialize: boolean;
  76699. /**
  76700. * @hidden
  76701. */
  76702. _storeEffectOnSubMeshes: boolean;
  76703. /**
  76704. * Stores the animations for the material
  76705. */
  76706. animations: Array<Animation>;
  76707. /**
  76708. * An event triggered when the material is disposed
  76709. */
  76710. onDisposeObservable: Observable<Material>;
  76711. /**
  76712. * An observer which watches for dispose events
  76713. */
  76714. private _onDisposeObserver;
  76715. private _onUnBindObservable;
  76716. /**
  76717. * Called during a dispose event
  76718. */
  76719. onDispose: () => void;
  76720. private _onBindObservable;
  76721. /**
  76722. * An event triggered when the material is bound
  76723. */
  76724. readonly onBindObservable: Observable<AbstractMesh>;
  76725. /**
  76726. * An observer which watches for bind events
  76727. */
  76728. private _onBindObserver;
  76729. /**
  76730. * Called during a bind event
  76731. */
  76732. onBind: (Mesh: AbstractMesh) => void;
  76733. /**
  76734. * An event triggered when the material is unbound
  76735. */
  76736. readonly onUnBindObservable: Observable<Material>;
  76737. /**
  76738. * Stores the value of the alpha mode
  76739. */
  76740. private _alphaMode;
  76741. /**
  76742. * Sets the value of the alpha mode.
  76743. *
  76744. * | Value | Type | Description |
  76745. * | --- | --- | --- |
  76746. * | 0 | ALPHA_DISABLE | |
  76747. * | 1 | ALPHA_ADD | |
  76748. * | 2 | ALPHA_COMBINE | |
  76749. * | 3 | ALPHA_SUBTRACT | |
  76750. * | 4 | ALPHA_MULTIPLY | |
  76751. * | 5 | ALPHA_MAXIMIZED | |
  76752. * | 6 | ALPHA_ONEONE | |
  76753. * | 7 | ALPHA_PREMULTIPLIED | |
  76754. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  76755. * | 9 | ALPHA_INTERPOLATE | |
  76756. * | 10 | ALPHA_SCREENMODE | |
  76757. *
  76758. */
  76759. /**
  76760. * Gets the value of the alpha mode
  76761. */
  76762. alphaMode: number;
  76763. /**
  76764. * Stores the state of the need depth pre-pass value
  76765. */
  76766. private _needDepthPrePass;
  76767. /**
  76768. * Sets the need depth pre-pass value
  76769. */
  76770. /**
  76771. * Gets the depth pre-pass value
  76772. */
  76773. needDepthPrePass: boolean;
  76774. /**
  76775. * Specifies if depth writing should be disabled
  76776. */
  76777. disableDepthWrite: boolean;
  76778. /**
  76779. * Specifies if depth writing should be forced
  76780. */
  76781. forceDepthWrite: boolean;
  76782. /**
  76783. * Specifies if there should be a separate pass for culling
  76784. */
  76785. separateCullingPass: boolean;
  76786. /**
  76787. * Stores the state specifing if fog should be enabled
  76788. */
  76789. private _fogEnabled;
  76790. /**
  76791. * Sets the state for enabling fog
  76792. */
  76793. /**
  76794. * Gets the value of the fog enabled state
  76795. */
  76796. fogEnabled: boolean;
  76797. /**
  76798. * Stores the size of points
  76799. */
  76800. pointSize: number;
  76801. /**
  76802. * Stores the z offset value
  76803. */
  76804. zOffset: number;
  76805. /**
  76806. * Gets a value specifying if wireframe mode is enabled
  76807. */
  76808. /**
  76809. * Sets the state of wireframe mode
  76810. */
  76811. wireframe: boolean;
  76812. /**
  76813. * Gets the value specifying if point clouds are enabled
  76814. */
  76815. /**
  76816. * Sets the state of point cloud mode
  76817. */
  76818. pointsCloud: boolean;
  76819. /**
  76820. * Gets the material fill mode
  76821. */
  76822. /**
  76823. * Sets the material fill mode
  76824. */
  76825. fillMode: number;
  76826. /**
  76827. * @hidden
  76828. * Stores the effects for the material
  76829. */
  76830. _effect: Nullable<Effect>;
  76831. /**
  76832. * @hidden
  76833. * Specifies if the material was previously ready
  76834. */
  76835. _wasPreviouslyReady: boolean;
  76836. /**
  76837. * Specifies if uniform buffers should be used
  76838. */
  76839. private _useUBO;
  76840. /**
  76841. * Stores a reference to the scene
  76842. */
  76843. private _scene;
  76844. /**
  76845. * Stores the fill mode state
  76846. */
  76847. private _fillMode;
  76848. /**
  76849. * Specifies if the depth write state should be cached
  76850. */
  76851. private _cachedDepthWriteState;
  76852. /**
  76853. * Stores the uniform buffer
  76854. */
  76855. protected _uniformBuffer: UniformBuffer;
  76856. /** @hidden */
  76857. _indexInSceneMaterialArray: number;
  76858. /** @hidden */
  76859. meshMap: Nullable<{
  76860. [id: string]: AbstractMesh | undefined;
  76861. }>;
  76862. /**
  76863. * Creates a material instance
  76864. * @param name defines the name of the material
  76865. * @param scene defines the scene to reference
  76866. * @param doNotAdd specifies if the material should be added to the scene
  76867. */
  76868. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  76869. /**
  76870. * Returns a string representation of the current material
  76871. * @param fullDetails defines a boolean indicating which levels of logging is desired
  76872. * @returns a string with material information
  76873. */
  76874. toString(fullDetails?: boolean): string;
  76875. /**
  76876. * Gets the class name of the material
  76877. * @returns a string with the class name of the material
  76878. */
  76879. getClassName(): string;
  76880. /**
  76881. * Specifies if updates for the material been locked
  76882. */
  76883. readonly isFrozen: boolean;
  76884. /**
  76885. * Locks updates for the material
  76886. */
  76887. freeze(): void;
  76888. /**
  76889. * Unlocks updates for the material
  76890. */
  76891. unfreeze(): void;
  76892. /**
  76893. * Specifies if the material is ready to be used
  76894. * @param mesh defines the mesh to check
  76895. * @param useInstances specifies if instances should be used
  76896. * @returns a boolean indicating if the material is ready to be used
  76897. */
  76898. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  76899. /**
  76900. * Specifies that the submesh is ready to be used
  76901. * @param mesh defines the mesh to check
  76902. * @param subMesh defines which submesh to check
  76903. * @param useInstances specifies that instances should be used
  76904. * @returns a boolean indicating that the submesh is ready or not
  76905. */
  76906. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  76907. /**
  76908. * Returns the material effect
  76909. * @returns the effect associated with the material
  76910. */
  76911. getEffect(): Nullable<Effect>;
  76912. /**
  76913. * Returns the current scene
  76914. * @returns a Scene
  76915. */
  76916. getScene(): Scene;
  76917. /**
  76918. * Specifies if the material will require alpha blending
  76919. * @returns a boolean specifying if alpha blending is needed
  76920. */
  76921. needAlphaBlending(): boolean;
  76922. /**
  76923. * Specifies if the mesh will require alpha blending
  76924. * @param mesh defines the mesh to check
  76925. * @returns a boolean specifying if alpha blending is needed for the mesh
  76926. */
  76927. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  76928. /**
  76929. * Specifies if this material should be rendered in alpha test mode
  76930. * @returns a boolean specifying if an alpha test is needed.
  76931. */
  76932. needAlphaTesting(): boolean;
  76933. /**
  76934. * Gets the texture used for the alpha test
  76935. * @returns the texture to use for alpha testing
  76936. */
  76937. getAlphaTestTexture(): Nullable<BaseTexture>;
  76938. /**
  76939. * Marks the material to indicate that it needs to be re-calculated
  76940. */
  76941. markDirty(): void;
  76942. /** @hidden */
  76943. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  76944. /**
  76945. * Binds the material to the mesh
  76946. * @param world defines the world transformation matrix
  76947. * @param mesh defines the mesh to bind the material to
  76948. */
  76949. bind(world: Matrix, mesh?: Mesh): void;
  76950. /**
  76951. * Binds the submesh to the material
  76952. * @param world defines the world transformation matrix
  76953. * @param mesh defines the mesh containing the submesh
  76954. * @param subMesh defines the submesh to bind the material to
  76955. */
  76956. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  76957. /**
  76958. * Binds the world matrix to the material
  76959. * @param world defines the world transformation matrix
  76960. */
  76961. bindOnlyWorldMatrix(world: Matrix): void;
  76962. /**
  76963. * Binds the scene's uniform buffer to the effect.
  76964. * @param effect defines the effect to bind to the scene uniform buffer
  76965. * @param sceneUbo defines the uniform buffer storing scene data
  76966. */
  76967. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  76968. /**
  76969. * Binds the view matrix to the effect
  76970. * @param effect defines the effect to bind the view matrix to
  76971. */
  76972. bindView(effect: Effect): void;
  76973. /**
  76974. * Binds the view projection matrix to the effect
  76975. * @param effect defines the effect to bind the view projection matrix to
  76976. */
  76977. bindViewProjection(effect: Effect): void;
  76978. /**
  76979. * Specifies if material alpha testing should be turned on for the mesh
  76980. * @param mesh defines the mesh to check
  76981. */
  76982. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  76983. /**
  76984. * Processes to execute after binding the material to a mesh
  76985. * @param mesh defines the rendered mesh
  76986. */
  76987. protected _afterBind(mesh?: Mesh): void;
  76988. /**
  76989. * Unbinds the material from the mesh
  76990. */
  76991. unbind(): void;
  76992. /**
  76993. * Gets the active textures from the material
  76994. * @returns an array of textures
  76995. */
  76996. getActiveTextures(): BaseTexture[];
  76997. /**
  76998. * Specifies if the material uses a texture
  76999. * @param texture defines the texture to check against the material
  77000. * @returns a boolean specifying if the material uses the texture
  77001. */
  77002. hasTexture(texture: BaseTexture): boolean;
  77003. /**
  77004. * Makes a duplicate of the material, and gives it a new name
  77005. * @param name defines the new name for the duplicated material
  77006. * @returns the cloned material
  77007. */
  77008. clone(name: string): Nullable<Material>;
  77009. /**
  77010. * Gets the meshes bound to the material
  77011. * @returns an array of meshes bound to the material
  77012. */
  77013. getBindedMeshes(): AbstractMesh[];
  77014. /**
  77015. * Force shader compilation
  77016. * @param mesh defines the mesh associated with this material
  77017. * @param onCompiled defines a function to execute once the material is compiled
  77018. * @param options defines the options to configure the compilation
  77019. */
  77020. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  77021. clipPlane: boolean;
  77022. }>): void;
  77023. /**
  77024. * Force shader compilation
  77025. * @param mesh defines the mesh that will use this material
  77026. * @param options defines additional options for compiling the shaders
  77027. * @returns a promise that resolves when the compilation completes
  77028. */
  77029. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  77030. clipPlane: boolean;
  77031. }>): Promise<void>;
  77032. private static readonly _ImageProcessingDirtyCallBack;
  77033. private static readonly _TextureDirtyCallBack;
  77034. private static readonly _FresnelDirtyCallBack;
  77035. private static readonly _MiscDirtyCallBack;
  77036. private static readonly _LightsDirtyCallBack;
  77037. private static readonly _AttributeDirtyCallBack;
  77038. private static _FresnelAndMiscDirtyCallBack;
  77039. private static _TextureAndMiscDirtyCallBack;
  77040. private static readonly _DirtyCallbackArray;
  77041. private static readonly _RunDirtyCallBacks;
  77042. /**
  77043. * Marks a define in the material to indicate that it needs to be re-computed
  77044. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  77045. */
  77046. markAsDirty(flag: number): void;
  77047. /**
  77048. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  77049. * @param func defines a function which checks material defines against the submeshes
  77050. */
  77051. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  77052. /**
  77053. * Indicates that image processing needs to be re-calculated for all submeshes
  77054. */
  77055. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  77056. /**
  77057. * Indicates that textures need to be re-calculated for all submeshes
  77058. */
  77059. protected _markAllSubMeshesAsTexturesDirty(): void;
  77060. /**
  77061. * Indicates that fresnel needs to be re-calculated for all submeshes
  77062. */
  77063. protected _markAllSubMeshesAsFresnelDirty(): void;
  77064. /**
  77065. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  77066. */
  77067. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  77068. /**
  77069. * Indicates that lights need to be re-calculated for all submeshes
  77070. */
  77071. protected _markAllSubMeshesAsLightsDirty(): void;
  77072. /**
  77073. * Indicates that attributes need to be re-calculated for all submeshes
  77074. */
  77075. protected _markAllSubMeshesAsAttributesDirty(): void;
  77076. /**
  77077. * Indicates that misc needs to be re-calculated for all submeshes
  77078. */
  77079. protected _markAllSubMeshesAsMiscDirty(): void;
  77080. /**
  77081. * Indicates that textures and misc need to be re-calculated for all submeshes
  77082. */
  77083. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  77084. /**
  77085. * Disposes the material
  77086. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  77087. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  77088. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  77089. */
  77090. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  77091. /** @hidden */
  77092. private releaseVertexArrayObject;
  77093. /**
  77094. * Serializes this material
  77095. * @returns the serialized material object
  77096. */
  77097. serialize(): any;
  77098. /**
  77099. * Creates a material from parsed material data
  77100. * @param parsedMaterial defines parsed material data
  77101. * @param scene defines the hosting scene
  77102. * @param rootUrl defines the root URL to use to load textures
  77103. * @returns a new material
  77104. */
  77105. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  77106. }
  77107. }
  77108. declare module BABYLON {
  77109. /**
  77110. * A multi-material is used to apply different materials to different parts of the same object without the need of
  77111. * separate meshes. This can be use to improve performances.
  77112. * @see http://doc.babylonjs.com/how_to/multi_materials
  77113. */
  77114. export class MultiMaterial extends Material {
  77115. private _subMaterials;
  77116. /**
  77117. * Gets or Sets the list of Materials used within the multi material.
  77118. * They need to be ordered according to the submeshes order in the associated mesh
  77119. */
  77120. subMaterials: Nullable<Material>[];
  77121. /**
  77122. * Function used to align with Node.getChildren()
  77123. * @returns the list of Materials used within the multi material
  77124. */
  77125. getChildren(): Nullable<Material>[];
  77126. /**
  77127. * Instantiates a new Multi Material
  77128. * A multi-material is used to apply different materials to different parts of the same object without the need of
  77129. * separate meshes. This can be use to improve performances.
  77130. * @see http://doc.babylonjs.com/how_to/multi_materials
  77131. * @param name Define the name in the scene
  77132. * @param scene Define the scene the material belongs to
  77133. */
  77134. constructor(name: string, scene: Scene);
  77135. private _hookArray;
  77136. /**
  77137. * Get one of the submaterial by its index in the submaterials array
  77138. * @param index The index to look the sub material at
  77139. * @returns The Material if the index has been defined
  77140. */
  77141. getSubMaterial(index: number): Nullable<Material>;
  77142. /**
  77143. * Get the list of active textures for the whole sub materials list.
  77144. * @returns All the textures that will be used during the rendering
  77145. */
  77146. getActiveTextures(): BaseTexture[];
  77147. /**
  77148. * Gets the current class name of the material e.g. "MultiMaterial"
  77149. * Mainly use in serialization.
  77150. * @returns the class name
  77151. */
  77152. getClassName(): string;
  77153. /**
  77154. * Checks if the material is ready to render the requested sub mesh
  77155. * @param mesh Define the mesh the submesh belongs to
  77156. * @param subMesh Define the sub mesh to look readyness for
  77157. * @param useInstances Define whether or not the material is used with instances
  77158. * @returns true if ready, otherwise false
  77159. */
  77160. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  77161. /**
  77162. * Clones the current material and its related sub materials
  77163. * @param name Define the name of the newly cloned material
  77164. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  77165. * @returns the cloned material
  77166. */
  77167. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  77168. /**
  77169. * Serializes the materials into a JSON representation.
  77170. * @returns the JSON representation
  77171. */
  77172. serialize(): any;
  77173. /**
  77174. * Dispose the material and release its associated resources
  77175. * @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)
  77176. * @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)
  77177. * @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)
  77178. */
  77179. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  77180. /**
  77181. * Creates a MultiMaterial from parsed MultiMaterial data.
  77182. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  77183. * @param scene defines the hosting scene
  77184. * @returns a new MultiMaterial
  77185. */
  77186. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  77187. }
  77188. }
  77189. declare module BABYLON {
  77190. /**
  77191. * Base class for submeshes
  77192. */
  77193. export class BaseSubMesh {
  77194. /** @hidden */
  77195. _materialDefines: Nullable<MaterialDefines>;
  77196. /** @hidden */
  77197. _materialEffect: Nullable<Effect>;
  77198. /**
  77199. * Gets associated effect
  77200. */
  77201. readonly effect: Nullable<Effect>;
  77202. /**
  77203. * Sets associated effect (effect used to render this submesh)
  77204. * @param effect defines the effect to associate with
  77205. * @param defines defines the set of defines used to compile this effect
  77206. */
  77207. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  77208. }
  77209. /**
  77210. * Defines a subdivision inside a mesh
  77211. */
  77212. export class SubMesh extends BaseSubMesh implements ICullable {
  77213. /** the material index to use */
  77214. materialIndex: number;
  77215. /** vertex index start */
  77216. verticesStart: number;
  77217. /** vertices count */
  77218. verticesCount: number;
  77219. /** index start */
  77220. indexStart: number;
  77221. /** indices count */
  77222. indexCount: number;
  77223. /** @hidden */
  77224. _linesIndexCount: number;
  77225. private _mesh;
  77226. private _renderingMesh;
  77227. private _boundingInfo;
  77228. private _linesIndexBuffer;
  77229. /** @hidden */
  77230. _lastColliderWorldVertices: Nullable<Vector3[]>;
  77231. /** @hidden */
  77232. _trianglePlanes: Plane[];
  77233. /** @hidden */
  77234. _lastColliderTransformMatrix: Matrix;
  77235. /** @hidden */
  77236. _renderId: number;
  77237. /** @hidden */
  77238. _alphaIndex: number;
  77239. /** @hidden */
  77240. _distanceToCamera: number;
  77241. /** @hidden */
  77242. _id: number;
  77243. private _currentMaterial;
  77244. /**
  77245. * Add a new submesh to a mesh
  77246. * @param materialIndex defines the material index to use
  77247. * @param verticesStart defines vertex index start
  77248. * @param verticesCount defines vertices count
  77249. * @param indexStart defines index start
  77250. * @param indexCount defines indices count
  77251. * @param mesh defines the parent mesh
  77252. * @param renderingMesh defines an optional rendering mesh
  77253. * @param createBoundingBox defines if bounding box should be created for this submesh
  77254. * @returns the new submesh
  77255. */
  77256. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  77257. /**
  77258. * Creates a new submesh
  77259. * @param materialIndex defines the material index to use
  77260. * @param verticesStart defines vertex index start
  77261. * @param verticesCount defines vertices count
  77262. * @param indexStart defines index start
  77263. * @param indexCount defines indices count
  77264. * @param mesh defines the parent mesh
  77265. * @param renderingMesh defines an optional rendering mesh
  77266. * @param createBoundingBox defines if bounding box should be created for this submesh
  77267. */
  77268. constructor(
  77269. /** the material index to use */
  77270. materialIndex: number,
  77271. /** vertex index start */
  77272. verticesStart: number,
  77273. /** vertices count */
  77274. verticesCount: number,
  77275. /** index start */
  77276. indexStart: number,
  77277. /** indices count */
  77278. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  77279. /**
  77280. * Returns true if this submesh covers the entire parent mesh
  77281. * @ignorenaming
  77282. */
  77283. readonly IsGlobal: boolean;
  77284. /**
  77285. * Returns the submesh BoudingInfo object
  77286. * @returns current bounding info (or mesh's one if the submesh is global)
  77287. */
  77288. getBoundingInfo(): BoundingInfo;
  77289. /**
  77290. * Sets the submesh BoundingInfo
  77291. * @param boundingInfo defines the new bounding info to use
  77292. * @returns the SubMesh
  77293. */
  77294. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  77295. /**
  77296. * Returns the mesh of the current submesh
  77297. * @return the parent mesh
  77298. */
  77299. getMesh(): AbstractMesh;
  77300. /**
  77301. * Returns the rendering mesh of the submesh
  77302. * @returns the rendering mesh (could be different from parent mesh)
  77303. */
  77304. getRenderingMesh(): Mesh;
  77305. /**
  77306. * Returns the submesh material
  77307. * @returns null or the current material
  77308. */
  77309. getMaterial(): Nullable<Material>;
  77310. /**
  77311. * Sets a new updated BoundingInfo object to the submesh
  77312. * @returns the SubMesh
  77313. */
  77314. refreshBoundingInfo(): SubMesh;
  77315. /** @hidden */
  77316. _checkCollision(collider: Collider): boolean;
  77317. /**
  77318. * Updates the submesh BoundingInfo
  77319. * @param world defines the world matrix to use to update the bounding info
  77320. * @returns the submesh
  77321. */
  77322. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  77323. /**
  77324. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  77325. * @param frustumPlanes defines the frustum planes
  77326. * @returns true if the submesh is intersecting with the frustum
  77327. */
  77328. isInFrustum(frustumPlanes: Plane[]): boolean;
  77329. /**
  77330. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  77331. * @param frustumPlanes defines the frustum planes
  77332. * @returns true if the submesh is inside the frustum
  77333. */
  77334. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  77335. /**
  77336. * Renders the submesh
  77337. * @param enableAlphaMode defines if alpha needs to be used
  77338. * @returns the submesh
  77339. */
  77340. render(enableAlphaMode: boolean): SubMesh;
  77341. /**
  77342. * @hidden
  77343. */
  77344. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  77345. /**
  77346. * Checks if the submesh intersects with a ray
  77347. * @param ray defines the ray to test
  77348. * @returns true is the passed ray intersects the submesh bounding box
  77349. */
  77350. canIntersects(ray: Ray): boolean;
  77351. /**
  77352. * Intersects current submesh with a ray
  77353. * @param ray defines the ray to test
  77354. * @param positions defines mesh's positions array
  77355. * @param indices defines mesh's indices array
  77356. * @param fastCheck defines if only bounding info should be used
  77357. * @returns intersection info or null if no intersection
  77358. */
  77359. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  77360. /** @hidden */
  77361. private _intersectLines;
  77362. /** @hidden */
  77363. private _intersectTriangles;
  77364. /** @hidden */
  77365. _rebuild(): void;
  77366. /**
  77367. * Creates a new submesh from the passed mesh
  77368. * @param newMesh defines the new hosting mesh
  77369. * @param newRenderingMesh defines an optional rendering mesh
  77370. * @returns the new submesh
  77371. */
  77372. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  77373. /**
  77374. * Release associated resources
  77375. */
  77376. dispose(): void;
  77377. /**
  77378. * Gets the class name
  77379. * @returns the string "SubMesh".
  77380. */
  77381. getClassName(): string;
  77382. /**
  77383. * Creates a new submesh from indices data
  77384. * @param materialIndex the index of the main mesh material
  77385. * @param startIndex the index where to start the copy in the mesh indices array
  77386. * @param indexCount the number of indices to copy then from the startIndex
  77387. * @param mesh the main mesh to create the submesh from
  77388. * @param renderingMesh the optional rendering mesh
  77389. * @returns a new submesh
  77390. */
  77391. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  77392. }
  77393. }
  77394. declare module BABYLON {
  77395. /**
  77396. * Class used to store geometry data (vertex buffers + index buffer)
  77397. */
  77398. export class Geometry implements IGetSetVerticesData {
  77399. /**
  77400. * Gets or sets the ID of the geometry
  77401. */
  77402. id: string;
  77403. /**
  77404. * Gets or sets the unique ID of the geometry
  77405. */
  77406. uniqueId: number;
  77407. /**
  77408. * Gets the delay loading state of the geometry (none by default which means not delayed)
  77409. */
  77410. delayLoadState: number;
  77411. /**
  77412. * Gets the file containing the data to load when running in delay load state
  77413. */
  77414. delayLoadingFile: Nullable<string>;
  77415. /**
  77416. * Callback called when the geometry is updated
  77417. */
  77418. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  77419. private _scene;
  77420. private _engine;
  77421. private _meshes;
  77422. private _totalVertices;
  77423. /** @hidden */
  77424. _indices: IndicesArray;
  77425. /** @hidden */
  77426. _vertexBuffers: {
  77427. [key: string]: VertexBuffer;
  77428. };
  77429. private _isDisposed;
  77430. private _extend;
  77431. private _boundingBias;
  77432. /** @hidden */
  77433. _delayInfo: Array<string>;
  77434. private _indexBuffer;
  77435. private _indexBufferIsUpdatable;
  77436. /** @hidden */
  77437. _boundingInfo: Nullable<BoundingInfo>;
  77438. /** @hidden */
  77439. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  77440. /** @hidden */
  77441. _softwareSkinningFrameId: number;
  77442. private _vertexArrayObjects;
  77443. private _updatable;
  77444. /** @hidden */
  77445. _positions: Nullable<Vector3[]>;
  77446. /**
  77447. * 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
  77448. */
  77449. /**
  77450. * 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
  77451. */
  77452. boundingBias: Vector2;
  77453. /**
  77454. * Static function used to attach a new empty geometry to a mesh
  77455. * @param mesh defines the mesh to attach the geometry to
  77456. * @returns the new Geometry
  77457. */
  77458. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  77459. /**
  77460. * Creates a new geometry
  77461. * @param id defines the unique ID
  77462. * @param scene defines the hosting scene
  77463. * @param vertexData defines the VertexData used to get geometry data
  77464. * @param updatable defines if geometry must be updatable (false by default)
  77465. * @param mesh defines the mesh that will be associated with the geometry
  77466. */
  77467. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  77468. /**
  77469. * Gets the current extend of the geometry
  77470. */
  77471. readonly extend: {
  77472. minimum: Vector3;
  77473. maximum: Vector3;
  77474. };
  77475. /**
  77476. * Gets the hosting scene
  77477. * @returns the hosting Scene
  77478. */
  77479. getScene(): Scene;
  77480. /**
  77481. * Gets the hosting engine
  77482. * @returns the hosting Engine
  77483. */
  77484. getEngine(): Engine;
  77485. /**
  77486. * Defines if the geometry is ready to use
  77487. * @returns true if the geometry is ready to be used
  77488. */
  77489. isReady(): boolean;
  77490. /**
  77491. * Gets a value indicating that the geometry should not be serialized
  77492. */
  77493. readonly doNotSerialize: boolean;
  77494. /** @hidden */
  77495. _rebuild(): void;
  77496. /**
  77497. * Affects all geometry data in one call
  77498. * @param vertexData defines the geometry data
  77499. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  77500. */
  77501. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  77502. /**
  77503. * Set specific vertex data
  77504. * @param kind defines the data kind (Position, normal, etc...)
  77505. * @param data defines the vertex data to use
  77506. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  77507. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  77508. */
  77509. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  77510. /**
  77511. * Removes a specific vertex data
  77512. * @param kind defines the data kind (Position, normal, etc...)
  77513. */
  77514. removeVerticesData(kind: string): void;
  77515. /**
  77516. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  77517. * @param buffer defines the vertex buffer to use
  77518. * @param totalVertices defines the total number of vertices for position kind (could be null)
  77519. */
  77520. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  77521. /**
  77522. * Update a specific vertex buffer
  77523. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  77524. * It will do nothing if the buffer is not updatable
  77525. * @param kind defines the data kind (Position, normal, etc...)
  77526. * @param data defines the data to use
  77527. * @param offset defines the offset in the target buffer where to store the data
  77528. * @param useBytes set to true if the offset is in bytes
  77529. */
  77530. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  77531. /**
  77532. * Update a specific vertex buffer
  77533. * This function will create a new buffer if the current one is not updatable
  77534. * @param kind defines the data kind (Position, normal, etc...)
  77535. * @param data defines the data to use
  77536. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  77537. */
  77538. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  77539. private _updateBoundingInfo;
  77540. /** @hidden */
  77541. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  77542. /**
  77543. * Gets total number of vertices
  77544. * @returns the total number of vertices
  77545. */
  77546. getTotalVertices(): number;
  77547. /**
  77548. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  77549. * @param kind defines the data kind (Position, normal, etc...)
  77550. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  77551. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77552. * @returns a float array containing vertex data
  77553. */
  77554. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77555. /**
  77556. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  77557. * @param kind defines the data kind (Position, normal, etc...)
  77558. * @returns true if the vertex buffer with the specified kind is updatable
  77559. */
  77560. isVertexBufferUpdatable(kind: string): boolean;
  77561. /**
  77562. * Gets a specific vertex buffer
  77563. * @param kind defines the data kind (Position, normal, etc...)
  77564. * @returns a VertexBuffer
  77565. */
  77566. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77567. /**
  77568. * Returns all vertex buffers
  77569. * @return an object holding all vertex buffers indexed by kind
  77570. */
  77571. getVertexBuffers(): Nullable<{
  77572. [key: string]: VertexBuffer;
  77573. }>;
  77574. /**
  77575. * Gets a boolean indicating if specific vertex buffer is present
  77576. * @param kind defines the data kind (Position, normal, etc...)
  77577. * @returns true if data is present
  77578. */
  77579. isVerticesDataPresent(kind: string): boolean;
  77580. /**
  77581. * Gets a list of all attached data kinds (Position, normal, etc...)
  77582. * @returns a list of string containing all kinds
  77583. */
  77584. getVerticesDataKinds(): string[];
  77585. /**
  77586. * Update index buffer
  77587. * @param indices defines the indices to store in the index buffer
  77588. * @param offset defines the offset in the target buffer where to store the data
  77589. */
  77590. updateIndices(indices: IndicesArray, offset?: number): void;
  77591. /**
  77592. * Creates a new index buffer
  77593. * @param indices defines the indices to store in the index buffer
  77594. * @param totalVertices defines the total number of vertices (could be null)
  77595. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  77596. */
  77597. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  77598. /**
  77599. * Return the total number of indices
  77600. * @returns the total number of indices
  77601. */
  77602. getTotalIndices(): number;
  77603. /**
  77604. * Gets the index buffer array
  77605. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  77606. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77607. * @returns the index buffer array
  77608. */
  77609. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77610. /**
  77611. * Gets the index buffer
  77612. * @return the index buffer
  77613. */
  77614. getIndexBuffer(): Nullable<WebGLBuffer>;
  77615. /** @hidden */
  77616. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  77617. /**
  77618. * Release the associated resources for a specific mesh
  77619. * @param mesh defines the source mesh
  77620. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  77621. */
  77622. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  77623. /**
  77624. * Apply current geometry to a given mesh
  77625. * @param mesh defines the mesh to apply geometry to
  77626. */
  77627. applyToMesh(mesh: Mesh): void;
  77628. private _updateExtend;
  77629. private _applyToMesh;
  77630. private notifyUpdate;
  77631. /**
  77632. * Load the geometry if it was flagged as delay loaded
  77633. * @param scene defines the hosting scene
  77634. * @param onLoaded defines a callback called when the geometry is loaded
  77635. */
  77636. load(scene: Scene, onLoaded?: () => void): void;
  77637. private _queueLoad;
  77638. /**
  77639. * Invert the geometry to move from a right handed system to a left handed one.
  77640. */
  77641. toLeftHanded(): void;
  77642. /** @hidden */
  77643. _resetPointsArrayCache(): void;
  77644. /** @hidden */
  77645. _generatePointsArray(): boolean;
  77646. /**
  77647. * Gets a value indicating if the geometry is disposed
  77648. * @returns true if the geometry was disposed
  77649. */
  77650. isDisposed(): boolean;
  77651. private _disposeVertexArrayObjects;
  77652. /**
  77653. * Free all associated resources
  77654. */
  77655. dispose(): void;
  77656. /**
  77657. * Clone the current geometry into a new geometry
  77658. * @param id defines the unique ID of the new geometry
  77659. * @returns a new geometry object
  77660. */
  77661. copy(id: string): Geometry;
  77662. /**
  77663. * Serialize the current geometry info (and not the vertices data) into a JSON object
  77664. * @return a JSON representation of the current geometry data (without the vertices data)
  77665. */
  77666. serialize(): any;
  77667. private toNumberArray;
  77668. /**
  77669. * Serialize all vertices data into a JSON oject
  77670. * @returns a JSON representation of the current geometry data
  77671. */
  77672. serializeVerticeData(): any;
  77673. /**
  77674. * Extracts a clone of a mesh geometry
  77675. * @param mesh defines the source mesh
  77676. * @param id defines the unique ID of the new geometry object
  77677. * @returns the new geometry object
  77678. */
  77679. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  77680. /**
  77681. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  77682. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  77683. * Be aware Math.random() could cause collisions, but:
  77684. * "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"
  77685. * @returns a string containing a new GUID
  77686. */
  77687. static RandomId(): string;
  77688. /** @hidden */
  77689. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  77690. private static _CleanMatricesWeights;
  77691. /**
  77692. * Create a new geometry from persisted data (Using .babylon file format)
  77693. * @param parsedVertexData defines the persisted data
  77694. * @param scene defines the hosting scene
  77695. * @param rootUrl defines the root url to use to load assets (like delayed data)
  77696. * @returns the new geometry object
  77697. */
  77698. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  77699. }
  77700. }
  77701. declare module BABYLON {
  77702. /**
  77703. * Define an interface for all classes that will get and set the data on vertices
  77704. */
  77705. export interface IGetSetVerticesData {
  77706. /**
  77707. * Gets a boolean indicating if specific vertex data is present
  77708. * @param kind defines the vertex data kind to use
  77709. * @returns true is data kind is present
  77710. */
  77711. isVerticesDataPresent(kind: string): boolean;
  77712. /**
  77713. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  77714. * @param kind defines the data kind (Position, normal, etc...)
  77715. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  77716. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77717. * @returns a float array containing vertex data
  77718. */
  77719. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77720. /**
  77721. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77722. * @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.
  77723. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77724. * @returns the indices array or an empty array if the mesh has no geometry
  77725. */
  77726. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77727. /**
  77728. * Set specific vertex data
  77729. * @param kind defines the data kind (Position, normal, etc...)
  77730. * @param data defines the vertex data to use
  77731. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  77732. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  77733. */
  77734. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  77735. /**
  77736. * Update a specific associated vertex buffer
  77737. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77738. * - VertexBuffer.PositionKind
  77739. * - VertexBuffer.UVKind
  77740. * - VertexBuffer.UV2Kind
  77741. * - VertexBuffer.UV3Kind
  77742. * - VertexBuffer.UV4Kind
  77743. * - VertexBuffer.UV5Kind
  77744. * - VertexBuffer.UV6Kind
  77745. * - VertexBuffer.ColorKind
  77746. * - VertexBuffer.MatricesIndicesKind
  77747. * - VertexBuffer.MatricesIndicesExtraKind
  77748. * - VertexBuffer.MatricesWeightsKind
  77749. * - VertexBuffer.MatricesWeightsExtraKind
  77750. * @param data defines the data source
  77751. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77752. * @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)
  77753. */
  77754. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  77755. /**
  77756. * Creates a new index buffer
  77757. * @param indices defines the indices to store in the index buffer
  77758. * @param totalVertices defines the total number of vertices (could be null)
  77759. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  77760. */
  77761. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  77762. }
  77763. /**
  77764. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  77765. */
  77766. export class VertexData {
  77767. /**
  77768. * Mesh side orientation : usually the external or front surface
  77769. */
  77770. static readonly FRONTSIDE: number;
  77771. /**
  77772. * Mesh side orientation : usually the internal or back surface
  77773. */
  77774. static readonly BACKSIDE: number;
  77775. /**
  77776. * Mesh side orientation : both internal and external or front and back surfaces
  77777. */
  77778. static readonly DOUBLESIDE: number;
  77779. /**
  77780. * Mesh side orientation : by default, `FRONTSIDE`
  77781. */
  77782. static readonly DEFAULTSIDE: number;
  77783. /**
  77784. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  77785. */
  77786. positions: Nullable<FloatArray>;
  77787. /**
  77788. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  77789. */
  77790. normals: Nullable<FloatArray>;
  77791. /**
  77792. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  77793. */
  77794. tangents: Nullable<FloatArray>;
  77795. /**
  77796. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77797. */
  77798. uvs: Nullable<FloatArray>;
  77799. /**
  77800. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77801. */
  77802. uvs2: Nullable<FloatArray>;
  77803. /**
  77804. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77805. */
  77806. uvs3: Nullable<FloatArray>;
  77807. /**
  77808. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77809. */
  77810. uvs4: Nullable<FloatArray>;
  77811. /**
  77812. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77813. */
  77814. uvs5: Nullable<FloatArray>;
  77815. /**
  77816. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77817. */
  77818. uvs6: Nullable<FloatArray>;
  77819. /**
  77820. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  77821. */
  77822. colors: Nullable<FloatArray>;
  77823. /**
  77824. * 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).
  77825. */
  77826. matricesIndices: Nullable<FloatArray>;
  77827. /**
  77828. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  77829. */
  77830. matricesWeights: Nullable<FloatArray>;
  77831. /**
  77832. * An array extending the number of possible indices
  77833. */
  77834. matricesIndicesExtra: Nullable<FloatArray>;
  77835. /**
  77836. * An array extending the number of possible weights when the number of indices is extended
  77837. */
  77838. matricesWeightsExtra: Nullable<FloatArray>;
  77839. /**
  77840. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  77841. */
  77842. indices: Nullable<IndicesArray>;
  77843. /**
  77844. * Uses the passed data array to set the set the values for the specified kind of data
  77845. * @param data a linear array of floating numbers
  77846. * @param kind the type of data that is being set, eg positions, colors etc
  77847. */
  77848. set(data: FloatArray, kind: string): void;
  77849. /**
  77850. * Associates the vertexData to the passed Mesh.
  77851. * Sets it as updatable or not (default `false`)
  77852. * @param mesh the mesh the vertexData is applied to
  77853. * @param updatable when used and having the value true allows new data to update the vertexData
  77854. * @returns the VertexData
  77855. */
  77856. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  77857. /**
  77858. * Associates the vertexData to the passed Geometry.
  77859. * Sets it as updatable or not (default `false`)
  77860. * @param geometry the geometry the vertexData is applied to
  77861. * @param updatable when used and having the value true allows new data to update the vertexData
  77862. * @returns VertexData
  77863. */
  77864. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  77865. /**
  77866. * Updates the associated mesh
  77867. * @param mesh the mesh to be updated
  77868. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  77869. * @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
  77870. * @returns VertexData
  77871. */
  77872. updateMesh(mesh: Mesh): VertexData;
  77873. /**
  77874. * Updates the associated geometry
  77875. * @param geometry the geometry to be updated
  77876. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  77877. * @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
  77878. * @returns VertexData.
  77879. */
  77880. updateGeometry(geometry: Geometry): VertexData;
  77881. private _applyTo;
  77882. private _update;
  77883. /**
  77884. * Transforms each position and each normal of the vertexData according to the passed Matrix
  77885. * @param matrix the transforming matrix
  77886. * @returns the VertexData
  77887. */
  77888. transform(matrix: Matrix): VertexData;
  77889. /**
  77890. * Merges the passed VertexData into the current one
  77891. * @param other the VertexData to be merged into the current one
  77892. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  77893. * @returns the modified VertexData
  77894. */
  77895. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  77896. private _mergeElement;
  77897. private _validate;
  77898. /**
  77899. * Serializes the VertexData
  77900. * @returns a serialized object
  77901. */
  77902. serialize(): any;
  77903. /**
  77904. * Extracts the vertexData from a mesh
  77905. * @param mesh the mesh from which to extract the VertexData
  77906. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  77907. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  77908. * @returns the object VertexData associated to the passed mesh
  77909. */
  77910. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  77911. /**
  77912. * Extracts the vertexData from the geometry
  77913. * @param geometry the geometry from which to extract the VertexData
  77914. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  77915. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  77916. * @returns the object VertexData associated to the passed mesh
  77917. */
  77918. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  77919. private static _ExtractFrom;
  77920. /**
  77921. * Creates the VertexData for a Ribbon
  77922. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  77923. * * pathArray array of paths, each of which an array of successive Vector3
  77924. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  77925. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  77926. * * 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
  77927. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77928. * * 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)
  77929. * * 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)
  77930. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  77931. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  77932. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  77933. * @returns the VertexData of the ribbon
  77934. */
  77935. static CreateRibbon(options: {
  77936. pathArray: Vector3[][];
  77937. closeArray?: boolean;
  77938. closePath?: boolean;
  77939. offset?: number;
  77940. sideOrientation?: number;
  77941. frontUVs?: Vector4;
  77942. backUVs?: Vector4;
  77943. invertUV?: boolean;
  77944. uvs?: Vector2[];
  77945. colors?: Color4[];
  77946. }): VertexData;
  77947. /**
  77948. * Creates the VertexData for a box
  77949. * @param options an object used to set the following optional parameters for the box, required but can be empty
  77950. * * size sets the width, height and depth of the box to the value of size, optional default 1
  77951. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  77952. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  77953. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  77954. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  77955. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  77956. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77957. * * 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)
  77958. * * 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)
  77959. * @returns the VertexData of the box
  77960. */
  77961. static CreateBox(options: {
  77962. size?: number;
  77963. width?: number;
  77964. height?: number;
  77965. depth?: number;
  77966. faceUV?: Vector4[];
  77967. faceColors?: Color4[];
  77968. sideOrientation?: number;
  77969. frontUVs?: Vector4;
  77970. backUVs?: Vector4;
  77971. }): VertexData;
  77972. /**
  77973. * Creates the VertexData for an ellipsoid, defaults to a sphere
  77974. * @param options an object used to set the following optional parameters for the box, required but can be empty
  77975. * * segments sets the number of horizontal strips optional, default 32
  77976. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  77977. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  77978. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  77979. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  77980. * * 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
  77981. * * 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
  77982. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77983. * * 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)
  77984. * * 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)
  77985. * @returns the VertexData of the ellipsoid
  77986. */
  77987. static CreateSphere(options: {
  77988. segments?: number;
  77989. diameter?: number;
  77990. diameterX?: number;
  77991. diameterY?: number;
  77992. diameterZ?: number;
  77993. arc?: number;
  77994. slice?: number;
  77995. sideOrientation?: number;
  77996. frontUVs?: Vector4;
  77997. backUVs?: Vector4;
  77998. }): VertexData;
  77999. /**
  78000. * Creates the VertexData for a cylinder, cone or prism
  78001. * @param options an object used to set the following optional parameters for the box, required but can be empty
  78002. * * height sets the height (y direction) of the cylinder, optional, default 2
  78003. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  78004. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  78005. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  78006. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  78007. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  78008. * * 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
  78009. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  78010. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  78011. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  78012. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  78013. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78014. * * 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)
  78015. * * 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)
  78016. * @returns the VertexData of the cylinder, cone or prism
  78017. */
  78018. static CreateCylinder(options: {
  78019. height?: number;
  78020. diameterTop?: number;
  78021. diameterBottom?: number;
  78022. diameter?: number;
  78023. tessellation?: number;
  78024. subdivisions?: number;
  78025. arc?: number;
  78026. faceColors?: Color4[];
  78027. faceUV?: Vector4[];
  78028. hasRings?: boolean;
  78029. enclose?: boolean;
  78030. sideOrientation?: number;
  78031. frontUVs?: Vector4;
  78032. backUVs?: Vector4;
  78033. }): VertexData;
  78034. /**
  78035. * Creates the VertexData for a torus
  78036. * @param options an object used to set the following optional parameters for the box, required but can be empty
  78037. * * diameter the diameter of the torus, optional default 1
  78038. * * thickness the diameter of the tube forming the torus, optional default 0.5
  78039. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  78040. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78041. * * 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)
  78042. * * 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)
  78043. * @returns the VertexData of the torus
  78044. */
  78045. static CreateTorus(options: {
  78046. diameter?: number;
  78047. thickness?: number;
  78048. tessellation?: number;
  78049. sideOrientation?: number;
  78050. frontUVs?: Vector4;
  78051. backUVs?: Vector4;
  78052. }): VertexData;
  78053. /**
  78054. * Creates the VertexData of the LineSystem
  78055. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  78056. * - lines an array of lines, each line being an array of successive Vector3
  78057. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  78058. * @returns the VertexData of the LineSystem
  78059. */
  78060. static CreateLineSystem(options: {
  78061. lines: Vector3[][];
  78062. colors?: Nullable<Color4[][]>;
  78063. }): VertexData;
  78064. /**
  78065. * Create the VertexData for a DashedLines
  78066. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  78067. * - points an array successive Vector3
  78068. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  78069. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  78070. * - dashNb the intended total number of dashes, optional, default 200
  78071. * @returns the VertexData for the DashedLines
  78072. */
  78073. static CreateDashedLines(options: {
  78074. points: Vector3[];
  78075. dashSize?: number;
  78076. gapSize?: number;
  78077. dashNb?: number;
  78078. }): VertexData;
  78079. /**
  78080. * Creates the VertexData for a Ground
  78081. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  78082. * - width the width (x direction) of the ground, optional, default 1
  78083. * - height the height (z direction) of the ground, optional, default 1
  78084. * - subdivisions the number of subdivisions per side, optional, default 1
  78085. * @returns the VertexData of the Ground
  78086. */
  78087. static CreateGround(options: {
  78088. width?: number;
  78089. height?: number;
  78090. subdivisions?: number;
  78091. subdivisionsX?: number;
  78092. subdivisionsY?: number;
  78093. }): VertexData;
  78094. /**
  78095. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  78096. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  78097. * * xmin the ground minimum X coordinate, optional, default -1
  78098. * * zmin the ground minimum Z coordinate, optional, default -1
  78099. * * xmax the ground maximum X coordinate, optional, default 1
  78100. * * zmax the ground maximum Z coordinate, optional, default 1
  78101. * * 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}
  78102. * * 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}
  78103. * @returns the VertexData of the TiledGround
  78104. */
  78105. static CreateTiledGround(options: {
  78106. xmin: number;
  78107. zmin: number;
  78108. xmax: number;
  78109. zmax: number;
  78110. subdivisions?: {
  78111. w: number;
  78112. h: number;
  78113. };
  78114. precision?: {
  78115. w: number;
  78116. h: number;
  78117. };
  78118. }): VertexData;
  78119. /**
  78120. * Creates the VertexData of the Ground designed from a heightmap
  78121. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  78122. * * width the width (x direction) of the ground
  78123. * * height the height (z direction) of the ground
  78124. * * subdivisions the number of subdivisions per side
  78125. * * minHeight the minimum altitude on the ground, optional, default 0
  78126. * * maxHeight the maximum altitude on the ground, optional default 1
  78127. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  78128. * * buffer the array holding the image color data
  78129. * * bufferWidth the width of image
  78130. * * bufferHeight the height of image
  78131. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  78132. * @returns the VertexData of the Ground designed from a heightmap
  78133. */
  78134. static CreateGroundFromHeightMap(options: {
  78135. width: number;
  78136. height: number;
  78137. subdivisions: number;
  78138. minHeight: number;
  78139. maxHeight: number;
  78140. colorFilter: Color3;
  78141. buffer: Uint8Array;
  78142. bufferWidth: number;
  78143. bufferHeight: number;
  78144. alphaFilter: number;
  78145. }): VertexData;
  78146. /**
  78147. * Creates the VertexData for a Plane
  78148. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  78149. * * size sets the width and height of the plane to the value of size, optional default 1
  78150. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  78151. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  78152. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78153. * * 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)
  78154. * * 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)
  78155. * @returns the VertexData of the box
  78156. */
  78157. static CreatePlane(options: {
  78158. size?: number;
  78159. width?: number;
  78160. height?: number;
  78161. sideOrientation?: number;
  78162. frontUVs?: Vector4;
  78163. backUVs?: Vector4;
  78164. }): VertexData;
  78165. /**
  78166. * Creates the VertexData of the Disc or regular Polygon
  78167. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  78168. * * radius the radius of the disc, optional default 0.5
  78169. * * tessellation the number of polygon sides, optional, default 64
  78170. * * 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
  78171. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78172. * * 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)
  78173. * * 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)
  78174. * @returns the VertexData of the box
  78175. */
  78176. static CreateDisc(options: {
  78177. radius?: number;
  78178. tessellation?: number;
  78179. arc?: number;
  78180. sideOrientation?: number;
  78181. frontUVs?: Vector4;
  78182. backUVs?: Vector4;
  78183. }): VertexData;
  78184. /**
  78185. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  78186. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  78187. * @param polygon a mesh built from polygonTriangulation.build()
  78188. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78189. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  78190. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  78191. * @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)
  78192. * @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)
  78193. * @returns the VertexData of the Polygon
  78194. */
  78195. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  78196. /**
  78197. * Creates the VertexData of the IcoSphere
  78198. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  78199. * * radius the radius of the IcoSphere, optional default 1
  78200. * * radiusX allows stretching in the x direction, optional, default radius
  78201. * * radiusY allows stretching in the y direction, optional, default radius
  78202. * * radiusZ allows stretching in the z direction, optional, default radius
  78203. * * flat when true creates a flat shaded mesh, optional, default true
  78204. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  78205. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78206. * * 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)
  78207. * * 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)
  78208. * @returns the VertexData of the IcoSphere
  78209. */
  78210. static CreateIcoSphere(options: {
  78211. radius?: number;
  78212. radiusX?: number;
  78213. radiusY?: number;
  78214. radiusZ?: number;
  78215. flat?: boolean;
  78216. subdivisions?: number;
  78217. sideOrientation?: number;
  78218. frontUVs?: Vector4;
  78219. backUVs?: Vector4;
  78220. }): VertexData;
  78221. /**
  78222. * Creates the VertexData for a Polyhedron
  78223. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  78224. * * type provided types are:
  78225. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  78226. * * 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)
  78227. * * size the size of the IcoSphere, optional default 1
  78228. * * sizeX allows stretching in the x direction, optional, default size
  78229. * * sizeY allows stretching in the y direction, optional, default size
  78230. * * sizeZ allows stretching in the z direction, optional, default size
  78231. * * 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
  78232. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  78233. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  78234. * * flat when true creates a flat shaded mesh, optional, default true
  78235. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  78236. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78237. * * 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)
  78238. * * 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)
  78239. * @returns the VertexData of the Polyhedron
  78240. */
  78241. static CreatePolyhedron(options: {
  78242. type?: number;
  78243. size?: number;
  78244. sizeX?: number;
  78245. sizeY?: number;
  78246. sizeZ?: number;
  78247. custom?: any;
  78248. faceUV?: Vector4[];
  78249. faceColors?: Color4[];
  78250. flat?: boolean;
  78251. sideOrientation?: number;
  78252. frontUVs?: Vector4;
  78253. backUVs?: Vector4;
  78254. }): VertexData;
  78255. /**
  78256. * Creates the VertexData for a TorusKnot
  78257. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  78258. * * radius the radius of the torus knot, optional, default 2
  78259. * * tube the thickness of the tube, optional, default 0.5
  78260. * * radialSegments the number of sides on each tube segments, optional, default 32
  78261. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  78262. * * p the number of windings around the z axis, optional, default 2
  78263. * * q the number of windings around the x axis, optional, default 3
  78264. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78265. * * 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)
  78266. * * 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)
  78267. * @returns the VertexData of the Torus Knot
  78268. */
  78269. static CreateTorusKnot(options: {
  78270. radius?: number;
  78271. tube?: number;
  78272. radialSegments?: number;
  78273. tubularSegments?: number;
  78274. p?: number;
  78275. q?: number;
  78276. sideOrientation?: number;
  78277. frontUVs?: Vector4;
  78278. backUVs?: Vector4;
  78279. }): VertexData;
  78280. /**
  78281. * Compute normals for given positions and indices
  78282. * @param positions an array of vertex positions, [...., x, y, z, ......]
  78283. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  78284. * @param normals an array of vertex normals, [...., x, y, z, ......]
  78285. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  78286. * * facetNormals : optional array of facet normals (vector3)
  78287. * * facetPositions : optional array of facet positions (vector3)
  78288. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  78289. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  78290. * * bInfo : optional bounding info, required for facetPartitioning computation
  78291. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  78292. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  78293. * * useRightHandedSystem: optional boolean to for right handed system computation
  78294. * * depthSort : optional boolean to enable the facet depth sort computation
  78295. * * distanceTo : optional Vector3 to compute the facet depth from this location
  78296. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  78297. */
  78298. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  78299. facetNormals?: any;
  78300. facetPositions?: any;
  78301. facetPartitioning?: any;
  78302. ratio?: number;
  78303. bInfo?: any;
  78304. bbSize?: Vector3;
  78305. subDiv?: any;
  78306. useRightHandedSystem?: boolean;
  78307. depthSort?: boolean;
  78308. distanceTo?: Vector3;
  78309. depthSortedFacets?: any;
  78310. }): void;
  78311. /** @hidden */
  78312. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  78313. /**
  78314. * Applies VertexData created from the imported parameters to the geometry
  78315. * @param parsedVertexData the parsed data from an imported file
  78316. * @param geometry the geometry to apply the VertexData to
  78317. */
  78318. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  78319. }
  78320. }
  78321. declare module BABYLON {
  78322. /**
  78323. * Class containing static functions to help procedurally build meshes
  78324. */
  78325. export class DiscBuilder {
  78326. /**
  78327. * Creates a plane polygonal mesh. By default, this is a disc
  78328. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  78329. * * 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
  78330. * * 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
  78331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78332. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  78333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78334. * @param name defines the name of the mesh
  78335. * @param options defines the options used to create the mesh
  78336. * @param scene defines the hosting scene
  78337. * @returns the plane polygonal mesh
  78338. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  78339. */
  78340. static CreateDisc(name: string, options: {
  78341. radius?: number;
  78342. tessellation?: number;
  78343. arc?: number;
  78344. updatable?: boolean;
  78345. sideOrientation?: number;
  78346. frontUVs?: Vector4;
  78347. backUVs?: Vector4;
  78348. }, scene?: Nullable<Scene>): Mesh;
  78349. }
  78350. }
  78351. declare module BABYLON {
  78352. /**
  78353. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  78354. *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.
  78355. * The SPS is also a particle system. It provides some methods to manage the particles.
  78356. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  78357. *
  78358. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  78359. */
  78360. export class SolidParticleSystem implements IDisposable {
  78361. /**
  78362. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  78363. * Example : var p = SPS.particles[i];
  78364. */
  78365. particles: SolidParticle[];
  78366. /**
  78367. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  78368. */
  78369. nbParticles: number;
  78370. /**
  78371. * If the particles must ever face the camera (default false). Useful for planar particles.
  78372. */
  78373. billboard: boolean;
  78374. /**
  78375. * Recompute normals when adding a shape
  78376. */
  78377. recomputeNormals: boolean;
  78378. /**
  78379. * This a counter ofr your own usage. It's not set by any SPS functions.
  78380. */
  78381. counter: number;
  78382. /**
  78383. * The SPS name. This name is also given to the underlying mesh.
  78384. */
  78385. name: string;
  78386. /**
  78387. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  78388. */
  78389. mesh: Mesh;
  78390. /**
  78391. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  78392. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  78393. */
  78394. vars: any;
  78395. /**
  78396. * This array is populated when the SPS is set as 'pickable'.
  78397. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  78398. * Each element of this array is an object `{idx: int, faceId: int}`.
  78399. * `idx` is the picked particle index in the `SPS.particles` array
  78400. * `faceId` is the picked face index counted within this particle.
  78401. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  78402. */
  78403. pickedParticles: {
  78404. idx: number;
  78405. faceId: number;
  78406. }[];
  78407. /**
  78408. * This array is populated when `enableDepthSort` is set to true.
  78409. * Each element of this array is an instance of the class DepthSortedParticle.
  78410. */
  78411. depthSortedParticles: DepthSortedParticle[];
  78412. /**
  78413. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  78414. * @hidden
  78415. */
  78416. _bSphereOnly: boolean;
  78417. /**
  78418. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  78419. * @hidden
  78420. */
  78421. _bSphereRadiusFactor: number;
  78422. private _scene;
  78423. private _positions;
  78424. private _indices;
  78425. private _normals;
  78426. private _colors;
  78427. private _uvs;
  78428. private _indices32;
  78429. private _positions32;
  78430. private _normals32;
  78431. private _fixedNormal32;
  78432. private _colors32;
  78433. private _uvs32;
  78434. private _index;
  78435. private _updatable;
  78436. private _pickable;
  78437. private _isVisibilityBoxLocked;
  78438. private _alwaysVisible;
  78439. private _depthSort;
  78440. private _shapeCounter;
  78441. private _copy;
  78442. private _color;
  78443. private _computeParticleColor;
  78444. private _computeParticleTexture;
  78445. private _computeParticleRotation;
  78446. private _computeParticleVertex;
  78447. private _computeBoundingBox;
  78448. private _depthSortParticles;
  78449. private _camera;
  78450. private _mustUnrotateFixedNormals;
  78451. private _particlesIntersect;
  78452. private _needs32Bits;
  78453. /**
  78454. * Creates a SPS (Solid Particle System) object.
  78455. * @param name (String) is the SPS name, this will be the underlying mesh name.
  78456. * @param scene (Scene) is the scene in which the SPS is added.
  78457. * @param options defines the options of the sps e.g.
  78458. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  78459. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  78460. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  78461. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  78462. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  78463. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  78464. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  78465. */
  78466. constructor(name: string, scene: Scene, options?: {
  78467. updatable?: boolean;
  78468. isPickable?: boolean;
  78469. enableDepthSort?: boolean;
  78470. particleIntersection?: boolean;
  78471. boundingSphereOnly?: boolean;
  78472. bSphereRadiusFactor?: number;
  78473. });
  78474. /**
  78475. * Builds the SPS underlying mesh. Returns a standard Mesh.
  78476. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  78477. * @returns the created mesh
  78478. */
  78479. buildMesh(): Mesh;
  78480. /**
  78481. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  78482. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  78483. * Thus the particles generated from `digest()` have their property `position` set yet.
  78484. * @param mesh ( Mesh ) is the mesh to be digested
  78485. * @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
  78486. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  78487. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  78488. * @returns the current SPS
  78489. */
  78490. digest(mesh: Mesh, options?: {
  78491. facetNb?: number;
  78492. number?: number;
  78493. delta?: number;
  78494. }): SolidParticleSystem;
  78495. private _unrotateFixedNormals;
  78496. private _resetCopy;
  78497. private _meshBuilder;
  78498. private _posToShape;
  78499. private _uvsToShapeUV;
  78500. private _addParticle;
  78501. /**
  78502. * Adds some particles to the SPS from the model shape. Returns the shape id.
  78503. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  78504. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  78505. * @param nb (positive integer) the number of particles to be created from this model
  78506. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  78507. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  78508. * @returns the number of shapes in the system
  78509. */
  78510. addShape(mesh: Mesh, nb: number, options?: {
  78511. positionFunction?: any;
  78512. vertexFunction?: any;
  78513. }): number;
  78514. private _rebuildParticle;
  78515. /**
  78516. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  78517. * @returns the SPS.
  78518. */
  78519. rebuildMesh(): SolidParticleSystem;
  78520. /**
  78521. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  78522. * This method calls `updateParticle()` for each particle of the SPS.
  78523. * For an animated SPS, it is usually called within the render loop.
  78524. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  78525. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  78526. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  78527. * @returns the SPS.
  78528. */
  78529. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  78530. /**
  78531. * Disposes the SPS.
  78532. */
  78533. dispose(): void;
  78534. /**
  78535. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  78536. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78537. * @returns the SPS.
  78538. */
  78539. refreshVisibleSize(): SolidParticleSystem;
  78540. /**
  78541. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  78542. * @param size the size (float) of the visibility box
  78543. * note : this doesn't lock the SPS mesh bounding box.
  78544. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78545. */
  78546. setVisibilityBox(size: number): void;
  78547. /**
  78548. * Gets whether the SPS as always visible or not
  78549. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78550. */
  78551. /**
  78552. * Sets the SPS as always visible or not
  78553. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78554. */
  78555. isAlwaysVisible: boolean;
  78556. /**
  78557. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  78558. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78559. */
  78560. /**
  78561. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  78562. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78563. */
  78564. isVisibilityBoxLocked: boolean;
  78565. /**
  78566. * Tells to `setParticles()` to compute the particle rotations or not.
  78567. * Default value : true. The SPS is faster when it's set to false.
  78568. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  78569. */
  78570. /**
  78571. * Gets if `setParticles()` computes the particle rotations or not.
  78572. * Default value : true. The SPS is faster when it's set to false.
  78573. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  78574. */
  78575. computeParticleRotation: boolean;
  78576. /**
  78577. * Tells to `setParticles()` to compute the particle colors or not.
  78578. * Default value : true. The SPS is faster when it's set to false.
  78579. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  78580. */
  78581. /**
  78582. * Gets if `setParticles()` computes the particle colors or not.
  78583. * Default value : true. The SPS is faster when it's set to false.
  78584. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  78585. */
  78586. computeParticleColor: boolean;
  78587. /**
  78588. * Gets if `setParticles()` computes the particle textures or not.
  78589. * Default value : true. The SPS is faster when it's set to false.
  78590. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  78591. */
  78592. computeParticleTexture: boolean;
  78593. /**
  78594. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  78595. * Default value : false. The SPS is faster when it's set to false.
  78596. * Note : the particle custom vertex positions aren't stored values.
  78597. */
  78598. /**
  78599. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  78600. * Default value : false. The SPS is faster when it's set to false.
  78601. * Note : the particle custom vertex positions aren't stored values.
  78602. */
  78603. computeParticleVertex: boolean;
  78604. /**
  78605. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  78606. */
  78607. /**
  78608. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  78609. */
  78610. computeBoundingBox: boolean;
  78611. /**
  78612. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  78613. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  78614. * Default : `true`
  78615. */
  78616. /**
  78617. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  78618. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  78619. * Default : `true`
  78620. */
  78621. depthSortParticles: boolean;
  78622. /**
  78623. * This function does nothing. It may be overwritten to set all the particle first values.
  78624. * The SPS doesn't call this function, you may have to call it by your own.
  78625. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  78626. */
  78627. initParticles(): void;
  78628. /**
  78629. * This function does nothing. It may be overwritten to recycle a particle.
  78630. * The SPS doesn't call this function, you may have to call it by your own.
  78631. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  78632. * @param particle The particle to recycle
  78633. * @returns the recycled particle
  78634. */
  78635. recycleParticle(particle: SolidParticle): SolidParticle;
  78636. /**
  78637. * Updates a particle : this function should be overwritten by the user.
  78638. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  78639. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  78640. * @example : just set a particle position or velocity and recycle conditions
  78641. * @param particle The particle to update
  78642. * @returns the updated particle
  78643. */
  78644. updateParticle(particle: SolidParticle): SolidParticle;
  78645. /**
  78646. * Updates a vertex of a particle : it can be overwritten by the user.
  78647. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  78648. * @param particle the current particle
  78649. * @param vertex the current index of the current particle
  78650. * @param pt the index of the current vertex in the particle shape
  78651. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  78652. * @example : just set a vertex particle position
  78653. * @returns the updated vertex
  78654. */
  78655. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  78656. /**
  78657. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  78658. * This does nothing and may be overwritten by the user.
  78659. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  78660. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  78661. * @param update the boolean update value actually passed to setParticles()
  78662. */
  78663. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  78664. /**
  78665. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  78666. * This will be passed three parameters.
  78667. * This does nothing and may be overwritten by the user.
  78668. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  78669. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  78670. * @param update the boolean update value actually passed to setParticles()
  78671. */
  78672. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  78673. }
  78674. }
  78675. declare module BABYLON {
  78676. /**
  78677. * Represents one particle of a solid particle system.
  78678. */
  78679. export class SolidParticle {
  78680. /**
  78681. * particle global index
  78682. */
  78683. idx: number;
  78684. /**
  78685. * The color of the particle
  78686. */
  78687. color: Nullable<Color4>;
  78688. /**
  78689. * The world space position of the particle.
  78690. */
  78691. position: Vector3;
  78692. /**
  78693. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  78694. */
  78695. rotation: Vector3;
  78696. /**
  78697. * The world space rotation quaternion of the particle.
  78698. */
  78699. rotationQuaternion: Nullable<Quaternion>;
  78700. /**
  78701. * The scaling of the particle.
  78702. */
  78703. scaling: Vector3;
  78704. /**
  78705. * The uvs of the particle.
  78706. */
  78707. uvs: Vector4;
  78708. /**
  78709. * The current speed of the particle.
  78710. */
  78711. velocity: Vector3;
  78712. /**
  78713. * The pivot point in the particle local space.
  78714. */
  78715. pivot: Vector3;
  78716. /**
  78717. * Must the particle be translated from its pivot point in its local space ?
  78718. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  78719. * Default : false
  78720. */
  78721. translateFromPivot: boolean;
  78722. /**
  78723. * Is the particle active or not ?
  78724. */
  78725. alive: boolean;
  78726. /**
  78727. * Is the particle visible or not ?
  78728. */
  78729. isVisible: boolean;
  78730. /**
  78731. * Index of this particle in the global "positions" array (Internal use)
  78732. * @hidden
  78733. */
  78734. _pos: number;
  78735. /**
  78736. * @hidden Index of this particle in the global "indices" array (Internal use)
  78737. */
  78738. _ind: number;
  78739. /**
  78740. * @hidden ModelShape of this particle (Internal use)
  78741. */
  78742. _model: ModelShape;
  78743. /**
  78744. * ModelShape id of this particle
  78745. */
  78746. shapeId: number;
  78747. /**
  78748. * Index of the particle in its shape id (Internal use)
  78749. */
  78750. idxInShape: number;
  78751. /**
  78752. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  78753. */
  78754. _modelBoundingInfo: BoundingInfo;
  78755. /**
  78756. * @hidden Particle BoundingInfo object (Internal use)
  78757. */
  78758. _boundingInfo: BoundingInfo;
  78759. /**
  78760. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  78761. */
  78762. _sps: SolidParticleSystem;
  78763. /**
  78764. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  78765. */
  78766. _stillInvisible: boolean;
  78767. /**
  78768. * @hidden Last computed particle rotation matrix
  78769. */
  78770. _rotationMatrix: number[];
  78771. /**
  78772. * Parent particle Id, if any.
  78773. * Default null.
  78774. */
  78775. parentId: Nullable<number>;
  78776. /**
  78777. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  78778. * The possible values are :
  78779. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  78780. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  78781. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  78782. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  78783. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  78784. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  78785. * */
  78786. cullingStrategy: number;
  78787. /**
  78788. * @hidden Internal global position in the SPS.
  78789. */
  78790. _globalPosition: Vector3;
  78791. /**
  78792. * Creates a Solid Particle object.
  78793. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  78794. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  78795. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  78796. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  78797. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  78798. * @param shapeId (integer) is the model shape identifier in the SPS.
  78799. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  78800. * @param sps defines the sps it is associated to
  78801. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  78802. */
  78803. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  78804. /**
  78805. * Legacy support, changed scale to scaling
  78806. */
  78807. /**
  78808. * Legacy support, changed scale to scaling
  78809. */
  78810. scale: Vector3;
  78811. /**
  78812. * Legacy support, changed quaternion to rotationQuaternion
  78813. */
  78814. /**
  78815. * Legacy support, changed quaternion to rotationQuaternion
  78816. */
  78817. quaternion: Nullable<Quaternion>;
  78818. /**
  78819. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  78820. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  78821. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  78822. * @returns true if it intersects
  78823. */
  78824. intersectsMesh(target: Mesh | SolidParticle): boolean;
  78825. /**
  78826. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  78827. * A particle is in the frustum if its bounding box intersects the frustum
  78828. * @param frustumPlanes defines the frustum to test
  78829. * @returns true if the particle is in the frustum planes
  78830. */
  78831. isInFrustum(frustumPlanes: Plane[]): boolean;
  78832. /**
  78833. * get the rotation matrix of the particle
  78834. * @hidden
  78835. */
  78836. getRotationMatrix(m: Matrix): void;
  78837. }
  78838. /**
  78839. * Represents the shape of the model used by one particle of a solid particle system.
  78840. * SPS internal tool, don't use it manually.
  78841. */
  78842. export class ModelShape {
  78843. /**
  78844. * The shape id
  78845. * @hidden
  78846. */
  78847. shapeID: number;
  78848. /**
  78849. * flat array of model positions (internal use)
  78850. * @hidden
  78851. */
  78852. _shape: Vector3[];
  78853. /**
  78854. * flat array of model UVs (internal use)
  78855. * @hidden
  78856. */
  78857. _shapeUV: number[];
  78858. /**
  78859. * length of the shape in the model indices array (internal use)
  78860. * @hidden
  78861. */
  78862. _indicesLength: number;
  78863. /**
  78864. * Custom position function (internal use)
  78865. * @hidden
  78866. */
  78867. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  78868. /**
  78869. * Custom vertex function (internal use)
  78870. * @hidden
  78871. */
  78872. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  78873. /**
  78874. * 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.
  78875. * SPS internal tool, don't use it manually.
  78876. * @hidden
  78877. */
  78878. 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>);
  78879. }
  78880. /**
  78881. * Represents a Depth Sorted Particle in the solid particle system.
  78882. */
  78883. export class DepthSortedParticle {
  78884. /**
  78885. * Index of the particle in the "indices" array
  78886. */
  78887. ind: number;
  78888. /**
  78889. * Length of the particle shape in the "indices" array
  78890. */
  78891. indicesLength: number;
  78892. /**
  78893. * Squared distance from the particle to the camera
  78894. */
  78895. sqDistance: number;
  78896. }
  78897. }
  78898. declare module BABYLON {
  78899. /**
  78900. * Class used to store all common mesh properties
  78901. */
  78902. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  78903. /** No occlusion */
  78904. static OCCLUSION_TYPE_NONE: number;
  78905. /** Occlusion set to optimisitic */
  78906. static OCCLUSION_TYPE_OPTIMISTIC: number;
  78907. /** Occlusion set to strict */
  78908. static OCCLUSION_TYPE_STRICT: number;
  78909. /** Use an accurante occlusion algorithm */
  78910. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  78911. /** Use a conservative occlusion algorithm */
  78912. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  78913. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  78914. * Test order :
  78915. * Is the bounding sphere outside the frustum ?
  78916. * If not, are the bounding box vertices outside the frustum ?
  78917. * It not, then the cullable object is in the frustum.
  78918. */
  78919. static readonly CULLINGSTRATEGY_STANDARD: number;
  78920. /** Culling strategy : Bounding Sphere Only.
  78921. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  78922. * It's also less accurate than the standard because some not visible objects can still be selected.
  78923. * Test : is the bounding sphere outside the frustum ?
  78924. * If not, then the cullable object is in the frustum.
  78925. */
  78926. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  78927. /** Culling strategy : Optimistic Inclusion.
  78928. * This in an inclusion test first, then the standard exclusion test.
  78929. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  78930. * 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.
  78931. * Anyway, it's as accurate as the standard strategy.
  78932. * Test :
  78933. * Is the cullable object bounding sphere center in the frustum ?
  78934. * If not, apply the default culling strategy.
  78935. */
  78936. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  78937. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  78938. * This in an inclusion test first, then the bounding sphere only exclusion test.
  78939. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  78940. * 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.
  78941. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  78942. * Test :
  78943. * Is the cullable object bounding sphere center in the frustum ?
  78944. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  78945. */
  78946. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  78947. /**
  78948. * No billboard
  78949. */
  78950. static readonly BILLBOARDMODE_NONE: number;
  78951. /** Billboard on X axis */
  78952. static readonly BILLBOARDMODE_X: number;
  78953. /** Billboard on Y axis */
  78954. static readonly BILLBOARDMODE_Y: number;
  78955. /** Billboard on Z axis */
  78956. static readonly BILLBOARDMODE_Z: number;
  78957. /** Billboard on all axes */
  78958. static readonly BILLBOARDMODE_ALL: number;
  78959. private _facetData;
  78960. /**
  78961. * The culling strategy to use to check whether the mesh must be rendered or not.
  78962. * This value can be changed at any time and will be used on the next render mesh selection.
  78963. * The possible values are :
  78964. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  78965. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  78966. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  78967. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  78968. * Please read each static variable documentation to get details about the culling process.
  78969. * */
  78970. cullingStrategy: number;
  78971. /**
  78972. * Gets the number of facets in the mesh
  78973. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  78974. */
  78975. readonly facetNb: number;
  78976. /**
  78977. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  78978. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  78979. */
  78980. partitioningSubdivisions: number;
  78981. /**
  78982. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  78983. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  78984. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  78985. */
  78986. partitioningBBoxRatio: number;
  78987. /**
  78988. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  78989. * Works only for updatable meshes.
  78990. * Doesn't work with multi-materials
  78991. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  78992. */
  78993. mustDepthSortFacets: boolean;
  78994. /**
  78995. * The location (Vector3) where the facet depth sort must be computed from.
  78996. * By default, the active camera position.
  78997. * Used only when facet depth sort is enabled
  78998. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  78999. */
  79000. facetDepthSortFrom: Vector3;
  79001. /**
  79002. * gets a boolean indicating if facetData is enabled
  79003. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  79004. */
  79005. readonly isFacetDataEnabled: boolean;
  79006. /** @hidden */
  79007. _updateNonUniformScalingState(value: boolean): boolean;
  79008. /**
  79009. * An event triggered when this mesh collides with another one
  79010. */
  79011. onCollideObservable: Observable<AbstractMesh>;
  79012. private _onCollideObserver;
  79013. /** Set a function to call when this mesh collides with another one */
  79014. onCollide: () => void;
  79015. /**
  79016. * An event triggered when the collision's position changes
  79017. */
  79018. onCollisionPositionChangeObservable: Observable<Vector3>;
  79019. private _onCollisionPositionChangeObserver;
  79020. /** Set a function to call when the collision's position changes */
  79021. onCollisionPositionChange: () => void;
  79022. /**
  79023. * An event triggered when material is changed
  79024. */
  79025. onMaterialChangedObservable: Observable<AbstractMesh>;
  79026. /**
  79027. * Gets or sets the orientation for POV movement & rotation
  79028. */
  79029. definedFacingForward: boolean;
  79030. /** @hidden */
  79031. _occlusionQuery: Nullable<WebGLQuery>;
  79032. private _visibility;
  79033. /**
  79034. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  79035. */
  79036. /**
  79037. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  79038. */
  79039. visibility: number;
  79040. /** Gets or sets the alpha index used to sort transparent meshes
  79041. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  79042. */
  79043. alphaIndex: number;
  79044. /**
  79045. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  79046. */
  79047. isVisible: boolean;
  79048. /**
  79049. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79050. */
  79051. isPickable: boolean;
  79052. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  79053. showSubMeshesBoundingBox: boolean;
  79054. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  79055. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  79056. */
  79057. isBlocker: boolean;
  79058. /**
  79059. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  79060. */
  79061. enablePointerMoveEvents: boolean;
  79062. /**
  79063. * Specifies the rendering group id for this mesh (0 by default)
  79064. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79065. */
  79066. renderingGroupId: number;
  79067. private _material;
  79068. /** Gets or sets current material */
  79069. material: Nullable<Material>;
  79070. private _receiveShadows;
  79071. /**
  79072. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  79073. * @see http://doc.babylonjs.com/babylon101/shadows
  79074. */
  79075. receiveShadows: boolean;
  79076. /** Defines color to use when rendering outline */
  79077. outlineColor: Color3;
  79078. /** Define width to use when rendering outline */
  79079. outlineWidth: number;
  79080. /** Defines color to use when rendering overlay */
  79081. overlayColor: Color3;
  79082. /** Defines alpha to use when rendering overlay */
  79083. overlayAlpha: number;
  79084. private _hasVertexAlpha;
  79085. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  79086. hasVertexAlpha: boolean;
  79087. private _useVertexColors;
  79088. /** 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) */
  79089. useVertexColors: boolean;
  79090. private _computeBonesUsingShaders;
  79091. /**
  79092. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  79093. */
  79094. computeBonesUsingShaders: boolean;
  79095. private _numBoneInfluencers;
  79096. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  79097. numBoneInfluencers: number;
  79098. private _applyFog;
  79099. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  79100. applyFog: boolean;
  79101. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  79102. useOctreeForRenderingSelection: boolean;
  79103. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  79104. useOctreeForPicking: boolean;
  79105. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  79106. useOctreeForCollisions: boolean;
  79107. private _layerMask;
  79108. /**
  79109. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  79110. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  79111. */
  79112. layerMask: number;
  79113. /**
  79114. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  79115. */
  79116. alwaysSelectAsActiveMesh: boolean;
  79117. /**
  79118. * Gets or sets the current action manager
  79119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79120. */
  79121. actionManager: Nullable<AbstractActionManager>;
  79122. private _checkCollisions;
  79123. private _collisionMask;
  79124. private _collisionGroup;
  79125. /**
  79126. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  79127. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79128. */
  79129. ellipsoid: Vector3;
  79130. /**
  79131. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  79132. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79133. */
  79134. ellipsoidOffset: Vector3;
  79135. private _collider;
  79136. private _oldPositionForCollisions;
  79137. private _diffPositionForCollisions;
  79138. /**
  79139. * Gets or sets a collision mask used to mask collisions (default is -1).
  79140. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  79141. */
  79142. collisionMask: number;
  79143. /**
  79144. * Gets or sets the current collision group mask (-1 by default).
  79145. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  79146. */
  79147. collisionGroup: number;
  79148. /**
  79149. * Defines edge width used when edgesRenderer is enabled
  79150. * @see https://www.babylonjs-playground.com/#10OJSG#13
  79151. */
  79152. edgesWidth: number;
  79153. /**
  79154. * Defines edge color used when edgesRenderer is enabled
  79155. * @see https://www.babylonjs-playground.com/#10OJSG#13
  79156. */
  79157. edgesColor: Color4;
  79158. /** @hidden */
  79159. _edgesRenderer: Nullable<IEdgesRenderer>;
  79160. /** @hidden */
  79161. _masterMesh: Nullable<AbstractMesh>;
  79162. /** @hidden */
  79163. _boundingInfo: Nullable<BoundingInfo>;
  79164. /** @hidden */
  79165. _renderId: number;
  79166. /**
  79167. * Gets or sets the list of subMeshes
  79168. * @see http://doc.babylonjs.com/how_to/multi_materials
  79169. */
  79170. subMeshes: SubMesh[];
  79171. /** @hidden */
  79172. _intersectionsInProgress: AbstractMesh[];
  79173. /** @hidden */
  79174. _unIndexed: boolean;
  79175. /** @hidden */
  79176. _lightSources: Light[];
  79177. /** @hidden */
  79178. readonly _positions: Nullable<Vector3[]>;
  79179. /** @hidden */
  79180. _waitingActions: any;
  79181. /** @hidden */
  79182. _waitingFreezeWorldMatrix: Nullable<boolean>;
  79183. private _skeleton;
  79184. /** @hidden */
  79185. _bonesTransformMatrices: Nullable<Float32Array>;
  79186. /**
  79187. * Gets or sets a skeleton to apply skining transformations
  79188. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79189. */
  79190. skeleton: Nullable<Skeleton>;
  79191. /**
  79192. * An event triggered when the mesh is rebuilt.
  79193. */
  79194. onRebuildObservable: Observable<AbstractMesh>;
  79195. /**
  79196. * Creates a new AbstractMesh
  79197. * @param name defines the name of the mesh
  79198. * @param scene defines the hosting scene
  79199. */
  79200. constructor(name: string, scene?: Nullable<Scene>);
  79201. /**
  79202. * Returns the string "AbstractMesh"
  79203. * @returns "AbstractMesh"
  79204. */
  79205. getClassName(): string;
  79206. /**
  79207. * Gets a string representation of the current mesh
  79208. * @param fullDetails defines a boolean indicating if full details must be included
  79209. * @returns a string representation of the current mesh
  79210. */
  79211. toString(fullDetails?: boolean): string;
  79212. /** @hidden */
  79213. _rebuild(): void;
  79214. /** @hidden */
  79215. _resyncLightSources(): void;
  79216. /** @hidden */
  79217. _resyncLighSource(light: Light): void;
  79218. /** @hidden */
  79219. _unBindEffect(): void;
  79220. /** @hidden */
  79221. _removeLightSource(light: Light): void;
  79222. private _markSubMeshesAsDirty;
  79223. /** @hidden */
  79224. _markSubMeshesAsLightDirty(): void;
  79225. /** @hidden */
  79226. _markSubMeshesAsAttributesDirty(): void;
  79227. /** @hidden */
  79228. _markSubMeshesAsMiscDirty(): void;
  79229. /**
  79230. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  79231. */
  79232. scaling: Vector3;
  79233. /**
  79234. * Returns true if the mesh is blocked. Implemented by child classes
  79235. */
  79236. readonly isBlocked: boolean;
  79237. /**
  79238. * Returns the mesh itself by default. Implemented by child classes
  79239. * @param camera defines the camera to use to pick the right LOD level
  79240. * @returns the currentAbstractMesh
  79241. */
  79242. getLOD(camera: Camera): Nullable<AbstractMesh>;
  79243. /**
  79244. * Returns 0 by default. Implemented by child classes
  79245. * @returns an integer
  79246. */
  79247. getTotalVertices(): number;
  79248. /**
  79249. * Returns a positive integer : the total number of indices in this mesh geometry.
  79250. * @returns the numner of indices or zero if the mesh has no geometry.
  79251. */
  79252. getTotalIndices(): number;
  79253. /**
  79254. * Returns null by default. Implemented by child classes
  79255. * @returns null
  79256. */
  79257. getIndices(): Nullable<IndicesArray>;
  79258. /**
  79259. * Returns the array of the requested vertex data kind. Implemented by child classes
  79260. * @param kind defines the vertex data kind to use
  79261. * @returns null
  79262. */
  79263. getVerticesData(kind: string): Nullable<FloatArray>;
  79264. /**
  79265. * Sets the vertex data of the mesh geometry for the requested `kind`.
  79266. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  79267. * Note that a new underlying VertexBuffer object is created each call.
  79268. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  79269. * @param kind defines vertex data kind:
  79270. * * VertexBuffer.PositionKind
  79271. * * VertexBuffer.UVKind
  79272. * * VertexBuffer.UV2Kind
  79273. * * VertexBuffer.UV3Kind
  79274. * * VertexBuffer.UV4Kind
  79275. * * VertexBuffer.UV5Kind
  79276. * * VertexBuffer.UV6Kind
  79277. * * VertexBuffer.ColorKind
  79278. * * VertexBuffer.MatricesIndicesKind
  79279. * * VertexBuffer.MatricesIndicesExtraKind
  79280. * * VertexBuffer.MatricesWeightsKind
  79281. * * VertexBuffer.MatricesWeightsExtraKind
  79282. * @param data defines the data source
  79283. * @param updatable defines if the data must be flagged as updatable (or static)
  79284. * @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
  79285. * @returns the current mesh
  79286. */
  79287. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  79288. /**
  79289. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  79290. * If the mesh has no geometry, it is simply returned as it is.
  79291. * @param kind defines vertex data kind:
  79292. * * VertexBuffer.PositionKind
  79293. * * VertexBuffer.UVKind
  79294. * * VertexBuffer.UV2Kind
  79295. * * VertexBuffer.UV3Kind
  79296. * * VertexBuffer.UV4Kind
  79297. * * VertexBuffer.UV5Kind
  79298. * * VertexBuffer.UV6Kind
  79299. * * VertexBuffer.ColorKind
  79300. * * VertexBuffer.MatricesIndicesKind
  79301. * * VertexBuffer.MatricesIndicesExtraKind
  79302. * * VertexBuffer.MatricesWeightsKind
  79303. * * VertexBuffer.MatricesWeightsExtraKind
  79304. * @param data defines the data source
  79305. * @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
  79306. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  79307. * @returns the current mesh
  79308. */
  79309. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  79310. /**
  79311. * Sets the mesh indices,
  79312. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  79313. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  79314. * @param totalVertices Defines the total number of vertices
  79315. * @returns the current mesh
  79316. */
  79317. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  79318. /**
  79319. * Gets a boolean indicating if specific vertex data is present
  79320. * @param kind defines the vertex data kind to use
  79321. * @returns true is data kind is present
  79322. */
  79323. isVerticesDataPresent(kind: string): boolean;
  79324. /**
  79325. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  79326. * @returns a BoundingInfo
  79327. */
  79328. getBoundingInfo(): BoundingInfo;
  79329. /**
  79330. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79331. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  79332. * @returns the current mesh
  79333. */
  79334. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  79335. /**
  79336. * Overwrite the current bounding info
  79337. * @param boundingInfo defines the new bounding info
  79338. * @returns the current mesh
  79339. */
  79340. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  79341. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  79342. readonly useBones: boolean;
  79343. /** @hidden */
  79344. _preActivate(): void;
  79345. /** @hidden */
  79346. _preActivateForIntermediateRendering(renderId: number): void;
  79347. /** @hidden */
  79348. _activate(renderId: number): void;
  79349. /**
  79350. * Gets the current world matrix
  79351. * @returns a Matrix
  79352. */
  79353. getWorldMatrix(): Matrix;
  79354. /** @hidden */
  79355. _getWorldMatrixDeterminant(): number;
  79356. /**
  79357. * Perform relative position change from the point of view of behind the front of the mesh.
  79358. * This is performed taking into account the meshes current rotation, so you do not have to care.
  79359. * Supports definition of mesh facing forward or backward
  79360. * @param amountRight defines the distance on the right axis
  79361. * @param amountUp defines the distance on the up axis
  79362. * @param amountForward defines the distance on the forward axis
  79363. * @returns the current mesh
  79364. */
  79365. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  79366. /**
  79367. * Calculate relative position change from the point of view of behind the front of the mesh.
  79368. * This is performed taking into account the meshes current rotation, so you do not have to care.
  79369. * Supports definition of mesh facing forward or backward
  79370. * @param amountRight defines the distance on the right axis
  79371. * @param amountUp defines the distance on the up axis
  79372. * @param amountForward defines the distance on the forward axis
  79373. * @returns the new displacement vector
  79374. */
  79375. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  79376. /**
  79377. * Perform relative rotation change from the point of view of behind the front of the mesh.
  79378. * Supports definition of mesh facing forward or backward
  79379. * @param flipBack defines the flip
  79380. * @param twirlClockwise defines the twirl
  79381. * @param tiltRight defines the tilt
  79382. * @returns the current mesh
  79383. */
  79384. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  79385. /**
  79386. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  79387. * Supports definition of mesh facing forward or backward.
  79388. * @param flipBack defines the flip
  79389. * @param twirlClockwise defines the twirl
  79390. * @param tiltRight defines the tilt
  79391. * @returns the new rotation vector
  79392. */
  79393. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  79394. /**
  79395. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  79396. * @param includeDescendants Include bounding info from descendants as well (true by default)
  79397. * @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
  79398. * @returns the new bounding vectors
  79399. */
  79400. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  79401. min: Vector3;
  79402. max: Vector3;
  79403. };
  79404. /**
  79405. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79406. * This means the mesh underlying bounding box and sphere are recomputed.
  79407. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79408. * @returns the current mesh
  79409. */
  79410. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  79411. /** @hidden */
  79412. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  79413. /** @hidden */
  79414. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  79415. /** @hidden */
  79416. _updateBoundingInfo(): AbstractMesh;
  79417. /** @hidden */
  79418. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  79419. /** @hidden */
  79420. protected _afterComputeWorldMatrix(): void;
  79421. /**
  79422. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  79423. * A mesh is in the frustum if its bounding box intersects the frustum
  79424. * @param frustumPlanes defines the frustum to test
  79425. * @returns true if the mesh is in the frustum planes
  79426. */
  79427. isInFrustum(frustumPlanes: Plane[]): boolean;
  79428. /**
  79429. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  79430. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  79431. * @param frustumPlanes defines the frustum to test
  79432. * @returns true if the mesh is completely in the frustum planes
  79433. */
  79434. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79435. /**
  79436. * True if the mesh intersects another mesh or a SolidParticle object
  79437. * @param mesh defines a target mesh or SolidParticle to test
  79438. * @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)
  79439. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  79440. * @returns true if there is an intersection
  79441. */
  79442. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  79443. /**
  79444. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  79445. * @param point defines the point to test
  79446. * @returns true if there is an intersection
  79447. */
  79448. intersectsPoint(point: Vector3): boolean;
  79449. /**
  79450. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  79451. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79452. */
  79453. checkCollisions: boolean;
  79454. /**
  79455. * Gets Collider object used to compute collisions (not physics)
  79456. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79457. */
  79458. readonly collider: Collider;
  79459. /**
  79460. * Move the mesh using collision engine
  79461. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79462. * @param displacement defines the requested displacement vector
  79463. * @returns the current mesh
  79464. */
  79465. moveWithCollisions(displacement: Vector3): AbstractMesh;
  79466. private _onCollisionPositionChange;
  79467. /** @hidden */
  79468. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  79469. /** @hidden */
  79470. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  79471. /** @hidden */
  79472. _checkCollision(collider: Collider): AbstractMesh;
  79473. /** @hidden */
  79474. _generatePointsArray(): boolean;
  79475. /**
  79476. * Checks if the passed Ray intersects with the mesh
  79477. * @param ray defines the ray to use
  79478. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  79479. * @returns the picking info
  79480. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  79481. */
  79482. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  79483. /**
  79484. * Clones the current mesh
  79485. * @param name defines the mesh name
  79486. * @param newParent defines the new mesh parent
  79487. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  79488. * @returns the new mesh
  79489. */
  79490. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  79491. /**
  79492. * Disposes all the submeshes of the current meshnp
  79493. * @returns the current mesh
  79494. */
  79495. releaseSubMeshes(): AbstractMesh;
  79496. /**
  79497. * Releases resources associated with this abstract mesh.
  79498. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79499. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79500. */
  79501. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79502. /**
  79503. * Adds the passed mesh as a child to the current mesh
  79504. * @param mesh defines the child mesh
  79505. * @returns the current mesh
  79506. */
  79507. addChild(mesh: AbstractMesh): AbstractMesh;
  79508. /**
  79509. * Removes the passed mesh from the current mesh children list
  79510. * @param mesh defines the child mesh
  79511. * @returns the current mesh
  79512. */
  79513. removeChild(mesh: AbstractMesh): AbstractMesh;
  79514. /** @hidden */
  79515. private _initFacetData;
  79516. /**
  79517. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  79518. * This method can be called within the render loop.
  79519. * 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
  79520. * @returns the current mesh
  79521. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79522. */
  79523. updateFacetData(): AbstractMesh;
  79524. /**
  79525. * Returns the facetLocalNormals array.
  79526. * The normals are expressed in the mesh local spac
  79527. * @returns an array of Vector3
  79528. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79529. */
  79530. getFacetLocalNormals(): Vector3[];
  79531. /**
  79532. * Returns the facetLocalPositions array.
  79533. * The facet positions are expressed in the mesh local space
  79534. * @returns an array of Vector3
  79535. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79536. */
  79537. getFacetLocalPositions(): Vector3[];
  79538. /**
  79539. * Returns the facetLocalPartioning array
  79540. * @returns an array of array of numbers
  79541. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79542. */
  79543. getFacetLocalPartitioning(): number[][];
  79544. /**
  79545. * Returns the i-th facet position in the world system.
  79546. * This method allocates a new Vector3 per call
  79547. * @param i defines the facet index
  79548. * @returns a new Vector3
  79549. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79550. */
  79551. getFacetPosition(i: number): Vector3;
  79552. /**
  79553. * Sets the reference Vector3 with the i-th facet position in the world system
  79554. * @param i defines the facet index
  79555. * @param ref defines the target vector
  79556. * @returns the current mesh
  79557. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79558. */
  79559. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  79560. /**
  79561. * Returns the i-th facet normal in the world system.
  79562. * This method allocates a new Vector3 per call
  79563. * @param i defines the facet index
  79564. * @returns a new Vector3
  79565. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79566. */
  79567. getFacetNormal(i: number): Vector3;
  79568. /**
  79569. * Sets the reference Vector3 with the i-th facet normal in the world system
  79570. * @param i defines the facet index
  79571. * @param ref defines the target vector
  79572. * @returns the current mesh
  79573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79574. */
  79575. getFacetNormalToRef(i: number, ref: Vector3): this;
  79576. /**
  79577. * 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)
  79578. * @param x defines x coordinate
  79579. * @param y defines y coordinate
  79580. * @param z defines z coordinate
  79581. * @returns the array of facet indexes
  79582. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79583. */
  79584. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  79585. /**
  79586. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  79587. * @param projected sets as the (x,y,z) world projection on the facet
  79588. * @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
  79589. * @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
  79590. * @param x defines x coordinate
  79591. * @param y defines y coordinate
  79592. * @param z defines z coordinate
  79593. * @returns the face index if found (or null instead)
  79594. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79595. */
  79596. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  79597. /**
  79598. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  79599. * @param projected sets as the (x,y,z) local projection on the facet
  79600. * @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
  79601. * @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
  79602. * @param x defines x coordinate
  79603. * @param y defines y coordinate
  79604. * @param z defines z coordinate
  79605. * @returns the face index if found (or null instead)
  79606. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79607. */
  79608. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  79609. /**
  79610. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  79611. * @returns the parameters
  79612. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79613. */
  79614. getFacetDataParameters(): any;
  79615. /**
  79616. * Disables the feature FacetData and frees the related memory
  79617. * @returns the current mesh
  79618. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79619. */
  79620. disableFacetData(): AbstractMesh;
  79621. /**
  79622. * Updates the AbstractMesh indices array
  79623. * @param indices defines the data source
  79624. * @returns the current mesh
  79625. */
  79626. updateIndices(indices: IndicesArray): AbstractMesh;
  79627. /**
  79628. * Creates new normals data for the mesh
  79629. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  79630. * @returns the current mesh
  79631. */
  79632. createNormals(updatable: boolean): AbstractMesh;
  79633. /**
  79634. * Align the mesh with a normal
  79635. * @param normal defines the normal to use
  79636. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  79637. * @returns the current mesh
  79638. */
  79639. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  79640. /** @hidden */
  79641. _checkOcclusionQuery(): boolean;
  79642. }
  79643. }
  79644. declare module BABYLON {
  79645. /**
  79646. * Class used to handle skinning animations
  79647. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79648. */
  79649. export class Skeleton implements IAnimatable {
  79650. /** defines the skeleton name */
  79651. name: string;
  79652. /** defines the skeleton Id */
  79653. id: string;
  79654. /**
  79655. * Defines the list of child bones
  79656. */
  79657. bones: Bone[];
  79658. /**
  79659. * Defines an estimate of the dimension of the skeleton at rest
  79660. */
  79661. dimensionsAtRest: Vector3;
  79662. /**
  79663. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79664. */
  79665. needInitialSkinMatrix: boolean;
  79666. /**
  79667. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79668. */
  79669. overrideMesh: Nullable<AbstractMesh>;
  79670. /**
  79671. * Gets the list of animations attached to this skeleton
  79672. */
  79673. animations: Array<Animation>;
  79674. private _scene;
  79675. private _isDirty;
  79676. private _transformMatrices;
  79677. private _transformMatrixTexture;
  79678. private _meshesWithPoseMatrix;
  79679. private _animatables;
  79680. private _identity;
  79681. private _synchronizedWithMesh;
  79682. private _ranges;
  79683. private _lastAbsoluteTransformsUpdateId;
  79684. private _canUseTextureForBones;
  79685. /** @hidden */
  79686. _numBonesWithLinkedTransformNode: number;
  79687. /**
  79688. * Specifies if the skeleton should be serialized
  79689. */
  79690. doNotSerialize: boolean;
  79691. /**
  79692. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79693. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  79694. */
  79695. useTextureToStoreBoneMatrices: boolean;
  79696. private _animationPropertiesOverride;
  79697. /**
  79698. * Gets or sets the animation properties override
  79699. */
  79700. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79701. /**
  79702. * An observable triggered before computing the skeleton's matrices
  79703. */
  79704. onBeforeComputeObservable: Observable<Skeleton>;
  79705. /**
  79706. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79707. */
  79708. readonly isUsingTextureForMatrices: boolean;
  79709. /**
  79710. * Creates a new skeleton
  79711. * @param name defines the skeleton name
  79712. * @param id defines the skeleton Id
  79713. * @param scene defines the hosting scene
  79714. */
  79715. constructor(
  79716. /** defines the skeleton name */
  79717. name: string,
  79718. /** defines the skeleton Id */
  79719. id: string, scene: Scene);
  79720. /**
  79721. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79722. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79723. * @returns a Float32Array containing matrices data
  79724. */
  79725. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79726. /**
  79727. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79728. * @returns a raw texture containing the data
  79729. */
  79730. getTransformMatrixTexture(): Nullable<RawTexture>;
  79731. /**
  79732. * Gets the current hosting scene
  79733. * @returns a scene object
  79734. */
  79735. getScene(): Scene;
  79736. /**
  79737. * Gets a string representing the current skeleton data
  79738. * @param fullDetails defines a boolean indicating if we want a verbose version
  79739. * @returns a string representing the current skeleton data
  79740. */
  79741. toString(fullDetails?: boolean): string;
  79742. /**
  79743. * Get bone's index searching by name
  79744. * @param name defines bone's name to search for
  79745. * @return the indice of the bone. Returns -1 if not found
  79746. */
  79747. getBoneIndexByName(name: string): number;
  79748. /**
  79749. * Creater a new animation range
  79750. * @param name defines the name of the range
  79751. * @param from defines the start key
  79752. * @param to defines the end key
  79753. */
  79754. createAnimationRange(name: string, from: number, to: number): void;
  79755. /**
  79756. * Delete a specific animation range
  79757. * @param name defines the name of the range
  79758. * @param deleteFrames defines if frames must be removed as well
  79759. */
  79760. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79761. /**
  79762. * Gets a specific animation range
  79763. * @param name defines the name of the range to look for
  79764. * @returns the requested animation range or null if not found
  79765. */
  79766. getAnimationRange(name: string): Nullable<AnimationRange>;
  79767. /**
  79768. * Gets the list of all animation ranges defined on this skeleton
  79769. * @returns an array
  79770. */
  79771. getAnimationRanges(): Nullable<AnimationRange>[];
  79772. /**
  79773. * Copy animation range from a source skeleton.
  79774. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79775. * @param source defines the source skeleton
  79776. * @param name defines the name of the range to copy
  79777. * @param rescaleAsRequired defines if rescaling must be applied if required
  79778. * @returns true if operation was successful
  79779. */
  79780. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79781. /**
  79782. * Forces the skeleton to go to rest pose
  79783. */
  79784. returnToRest(): void;
  79785. private _getHighestAnimationFrame;
  79786. /**
  79787. * Begin a specific animation range
  79788. * @param name defines the name of the range to start
  79789. * @param loop defines if looping must be turned on (false by default)
  79790. * @param speedRatio defines the speed ratio to apply (1 by default)
  79791. * @param onAnimationEnd defines a callback which will be called when animation will end
  79792. * @returns a new animatable
  79793. */
  79794. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79795. /** @hidden */
  79796. _markAsDirty(): void;
  79797. /** @hidden */
  79798. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79799. /** @hidden */
  79800. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79801. private _computeTransformMatrices;
  79802. /**
  79803. * Build all resources required to render a skeleton
  79804. */
  79805. prepare(): void;
  79806. /**
  79807. * Gets the list of animatables currently running for this skeleton
  79808. * @returns an array of animatables
  79809. */
  79810. getAnimatables(): IAnimatable[];
  79811. /**
  79812. * Clone the current skeleton
  79813. * @param name defines the name of the new skeleton
  79814. * @param id defines the id of the enw skeleton
  79815. * @returns the new skeleton
  79816. */
  79817. clone(name: string, id: string): Skeleton;
  79818. /**
  79819. * Enable animation blending for this skeleton
  79820. * @param blendingSpeed defines the blending speed to apply
  79821. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79822. */
  79823. enableBlending(blendingSpeed?: number): void;
  79824. /**
  79825. * Releases all resources associated with the current skeleton
  79826. */
  79827. dispose(): void;
  79828. /**
  79829. * Serialize the skeleton in a JSON object
  79830. * @returns a JSON object
  79831. */
  79832. serialize(): any;
  79833. /**
  79834. * Creates a new skeleton from serialized data
  79835. * @param parsedSkeleton defines the serialized data
  79836. * @param scene defines the hosting scene
  79837. * @returns a new skeleton
  79838. */
  79839. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79840. /**
  79841. * Compute all node absolute transforms
  79842. * @param forceUpdate defines if computation must be done even if cache is up to date
  79843. */
  79844. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79845. /**
  79846. * Gets the root pose matrix
  79847. * @returns a matrix
  79848. */
  79849. getPoseMatrix(): Nullable<Matrix>;
  79850. /**
  79851. * Sorts bones per internal index
  79852. */
  79853. sortBones(): void;
  79854. private _sortBones;
  79855. }
  79856. }
  79857. declare module BABYLON {
  79858. /**
  79859. * Class used to store bone information
  79860. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79861. */
  79862. export class Bone extends Node {
  79863. /**
  79864. * defines the bone name
  79865. */
  79866. name: string;
  79867. private static _tmpVecs;
  79868. private static _tmpQuat;
  79869. private static _tmpMats;
  79870. /**
  79871. * Gets the list of child bones
  79872. */
  79873. children: Bone[];
  79874. /** Gets the animations associated with this bone */
  79875. animations: Animation[];
  79876. /**
  79877. * Gets or sets bone length
  79878. */
  79879. length: number;
  79880. /**
  79881. * @hidden Internal only
  79882. * Set this value to map this bone to a different index in the transform matrices
  79883. * Set this value to -1 to exclude the bone from the transform matrices
  79884. */
  79885. _index: Nullable<number>;
  79886. private _skeleton;
  79887. private _localMatrix;
  79888. private _restPose;
  79889. private _baseMatrix;
  79890. private _absoluteTransform;
  79891. private _invertedAbsoluteTransform;
  79892. private _parent;
  79893. private _scalingDeterminant;
  79894. private _worldTransform;
  79895. private _localScaling;
  79896. private _localRotation;
  79897. private _localPosition;
  79898. private _needToDecompose;
  79899. private _needToCompose;
  79900. /** @hidden */
  79901. _linkedTransformNode: Nullable<TransformNode>;
  79902. /** @hidden */
  79903. /** @hidden */
  79904. _matrix: Matrix;
  79905. /**
  79906. * Create a new bone
  79907. * @param name defines the bone name
  79908. * @param skeleton defines the parent skeleton
  79909. * @param parentBone defines the parent (can be null if the bone is the root)
  79910. * @param localMatrix defines the local matrix
  79911. * @param restPose defines the rest pose matrix
  79912. * @param baseMatrix defines the base matrix
  79913. * @param index defines index of the bone in the hiearchy
  79914. */
  79915. constructor(
  79916. /**
  79917. * defines the bone name
  79918. */
  79919. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  79920. /**
  79921. * Gets the parent skeleton
  79922. * @returns a skeleton
  79923. */
  79924. getSkeleton(): Skeleton;
  79925. /**
  79926. * Gets parent bone
  79927. * @returns a bone or null if the bone is the root of the bone hierarchy
  79928. */
  79929. getParent(): Nullable<Bone>;
  79930. /**
  79931. * Sets the parent bone
  79932. * @param parent defines the parent (can be null if the bone is the root)
  79933. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79934. */
  79935. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  79936. /**
  79937. * Gets the local matrix
  79938. * @returns a matrix
  79939. */
  79940. getLocalMatrix(): Matrix;
  79941. /**
  79942. * Gets the base matrix (initial matrix which remains unchanged)
  79943. * @returns a matrix
  79944. */
  79945. getBaseMatrix(): Matrix;
  79946. /**
  79947. * Gets the rest pose matrix
  79948. * @returns a matrix
  79949. */
  79950. getRestPose(): Matrix;
  79951. /**
  79952. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  79953. */
  79954. getWorldMatrix(): Matrix;
  79955. /**
  79956. * Sets the local matrix to rest pose matrix
  79957. */
  79958. returnToRest(): void;
  79959. /**
  79960. * Gets the inverse of the absolute transform matrix.
  79961. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  79962. * @returns a matrix
  79963. */
  79964. getInvertedAbsoluteTransform(): Matrix;
  79965. /**
  79966. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  79967. * @returns a matrix
  79968. */
  79969. getAbsoluteTransform(): Matrix;
  79970. /**
  79971. * Links with the given transform node.
  79972. * The local matrix of this bone is copied from the transform node every frame.
  79973. * @param transformNode defines the transform node to link to
  79974. */
  79975. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  79976. /** Gets or sets current position (in local space) */
  79977. position: Vector3;
  79978. /** Gets or sets current rotation (in local space) */
  79979. rotation: Vector3;
  79980. /** Gets or sets current rotation quaternion (in local space) */
  79981. rotationQuaternion: Quaternion;
  79982. /** Gets or sets current scaling (in local space) */
  79983. scaling: Vector3;
  79984. /**
  79985. * Gets the animation properties override
  79986. */
  79987. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79988. private _decompose;
  79989. private _compose;
  79990. /**
  79991. * Update the base and local matrices
  79992. * @param matrix defines the new base or local matrix
  79993. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79994. * @param updateLocalMatrix defines if the local matrix should be updated
  79995. */
  79996. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  79997. /** @hidden */
  79998. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  79999. /**
  80000. * Flag the bone as dirty (Forcing it to update everything)
  80001. */
  80002. markAsDirty(): void;
  80003. private _markAsDirtyAndCompose;
  80004. private _markAsDirtyAndDecompose;
  80005. /**
  80006. * Translate the bone in local or world space
  80007. * @param vec The amount to translate the bone
  80008. * @param space The space that the translation is in
  80009. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80010. */
  80011. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80012. /**
  80013. * Set the postion of the bone in local or world space
  80014. * @param position The position to set the bone
  80015. * @param space The space that the position is in
  80016. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80017. */
  80018. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80019. /**
  80020. * Set the absolute position of the bone (world space)
  80021. * @param position The position to set the bone
  80022. * @param mesh The mesh that this bone is attached to
  80023. */
  80024. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  80025. /**
  80026. * Scale the bone on the x, y and z axes (in local space)
  80027. * @param x The amount to scale the bone on the x axis
  80028. * @param y The amount to scale the bone on the y axis
  80029. * @param z The amount to scale the bone on the z axis
  80030. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  80031. */
  80032. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  80033. /**
  80034. * Set the bone scaling in local space
  80035. * @param scale defines the scaling vector
  80036. */
  80037. setScale(scale: Vector3): void;
  80038. /**
  80039. * Gets the current scaling in local space
  80040. * @returns the current scaling vector
  80041. */
  80042. getScale(): Vector3;
  80043. /**
  80044. * Gets the current scaling in local space and stores it in a target vector
  80045. * @param result defines the target vector
  80046. */
  80047. getScaleToRef(result: Vector3): void;
  80048. /**
  80049. * Set the yaw, pitch, and roll of the bone in local or world space
  80050. * @param yaw The rotation of the bone on the y axis
  80051. * @param pitch The rotation of the bone on the x axis
  80052. * @param roll The rotation of the bone on the z axis
  80053. * @param space The space that the axes of rotation are in
  80054. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80055. */
  80056. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  80057. /**
  80058. * Add a rotation to the bone on an axis in local or world space
  80059. * @param axis The axis to rotate the bone on
  80060. * @param amount The amount to rotate the bone
  80061. * @param space The space that the axis is in
  80062. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80063. */
  80064. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  80065. /**
  80066. * Set the rotation of the bone to a particular axis angle in local or world space
  80067. * @param axis The axis to rotate the bone on
  80068. * @param angle The angle that the bone should be rotated to
  80069. * @param space The space that the axis is in
  80070. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80071. */
  80072. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  80073. /**
  80074. * Set the euler rotation of the bone in local of world space
  80075. * @param rotation The euler rotation that the bone should be set to
  80076. * @param space The space that the rotation is in
  80077. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80078. */
  80079. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80080. /**
  80081. * Set the quaternion rotation of the bone in local of world space
  80082. * @param quat The quaternion rotation that the bone should be set to
  80083. * @param space The space that the rotation is in
  80084. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80085. */
  80086. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  80087. /**
  80088. * Set the rotation matrix of the bone in local of world space
  80089. * @param rotMat The rotation matrix that the bone should be set to
  80090. * @param space The space that the rotation is in
  80091. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80092. */
  80093. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  80094. private _rotateWithMatrix;
  80095. private _getNegativeRotationToRef;
  80096. /**
  80097. * Get the position of the bone in local or world space
  80098. * @param space The space that the returned position is in
  80099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80100. * @returns The position of the bone
  80101. */
  80102. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80103. /**
  80104. * Copy the position of the bone to a vector3 in local or world space
  80105. * @param space The space that the returned position is in
  80106. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80107. * @param result The vector3 to copy the position to
  80108. */
  80109. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  80110. /**
  80111. * Get the absolute position of the bone (world space)
  80112. * @param mesh The mesh that this bone is attached to
  80113. * @returns The absolute position of the bone
  80114. */
  80115. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  80116. /**
  80117. * Copy the absolute position of the bone (world space) to the result param
  80118. * @param mesh The mesh that this bone is attached to
  80119. * @param result The vector3 to copy the absolute position to
  80120. */
  80121. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  80122. /**
  80123. * Compute the absolute transforms of this bone and its children
  80124. */
  80125. computeAbsoluteTransforms(): void;
  80126. /**
  80127. * Get the world direction from an axis that is in the local space of the bone
  80128. * @param localAxis The local direction that is used to compute the world direction
  80129. * @param mesh The mesh that this bone is attached to
  80130. * @returns The world direction
  80131. */
  80132. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80133. /**
  80134. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  80135. * @param localAxis The local direction that is used to compute the world direction
  80136. * @param mesh The mesh that this bone is attached to
  80137. * @param result The vector3 that the world direction will be copied to
  80138. */
  80139. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80140. /**
  80141. * Get the euler rotation of the bone in local or world space
  80142. * @param space The space that the rotation should be in
  80143. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80144. * @returns The euler rotation
  80145. */
  80146. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80147. /**
  80148. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  80149. * @param space The space that the rotation should be in
  80150. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80151. * @param result The vector3 that the rotation should be copied to
  80152. */
  80153. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80154. /**
  80155. * Get the quaternion rotation of the bone in either local or world space
  80156. * @param space The space that the rotation should be in
  80157. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80158. * @returns The quaternion rotation
  80159. */
  80160. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  80161. /**
  80162. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  80163. * @param space The space that the rotation should be in
  80164. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80165. * @param result The quaternion that the rotation should be copied to
  80166. */
  80167. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  80168. /**
  80169. * Get the rotation matrix of the bone in local or world space
  80170. * @param space The space that the rotation should be in
  80171. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80172. * @returns The rotation matrix
  80173. */
  80174. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  80175. /**
  80176. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  80177. * @param space The space that the rotation should be in
  80178. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80179. * @param result The quaternion that the rotation should be copied to
  80180. */
  80181. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  80182. /**
  80183. * Get the world position of a point that is in the local space of the bone
  80184. * @param position The local position
  80185. * @param mesh The mesh that this bone is attached to
  80186. * @returns The world position
  80187. */
  80188. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80189. /**
  80190. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  80191. * @param position The local position
  80192. * @param mesh The mesh that this bone is attached to
  80193. * @param result The vector3 that the world position should be copied to
  80194. */
  80195. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80196. /**
  80197. * Get the local position of a point that is in world space
  80198. * @param position The world position
  80199. * @param mesh The mesh that this bone is attached to
  80200. * @returns The local position
  80201. */
  80202. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80203. /**
  80204. * Get the local position of a point that is in world space and copy it to the result param
  80205. * @param position The world position
  80206. * @param mesh The mesh that this bone is attached to
  80207. * @param result The vector3 that the local position should be copied to
  80208. */
  80209. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80210. }
  80211. }
  80212. declare module BABYLON {
  80213. /**
  80214. * Class used to store an actual running animation
  80215. */
  80216. export class Animatable {
  80217. /** defines the target object */
  80218. target: any;
  80219. /** defines the starting frame number (default is 0) */
  80220. fromFrame: number;
  80221. /** defines the ending frame number (default is 100) */
  80222. toFrame: number;
  80223. /** defines if the animation must loop (default is false) */
  80224. loopAnimation: boolean;
  80225. /** defines a callback to call when animation ends if it is not looping */
  80226. onAnimationEnd?: (() => void) | null | undefined;
  80227. /** defines a callback to call when animation loops */
  80228. onAnimationLoop?: (() => void) | null | undefined;
  80229. private _localDelayOffset;
  80230. private _pausedDelay;
  80231. private _runtimeAnimations;
  80232. private _paused;
  80233. private _scene;
  80234. private _speedRatio;
  80235. private _weight;
  80236. private _syncRoot;
  80237. /**
  80238. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  80239. * This will only apply for non looping animation (default is true)
  80240. */
  80241. disposeOnEnd: boolean;
  80242. /**
  80243. * Gets a boolean indicating if the animation has started
  80244. */
  80245. animationStarted: boolean;
  80246. /**
  80247. * Observer raised when the animation ends
  80248. */
  80249. onAnimationEndObservable: Observable<Animatable>;
  80250. /**
  80251. * Observer raised when the animation loops
  80252. */
  80253. onAnimationLoopObservable: Observable<Animatable>;
  80254. /**
  80255. * Gets the root Animatable used to synchronize and normalize animations
  80256. */
  80257. readonly syncRoot: Animatable;
  80258. /**
  80259. * Gets the current frame of the first RuntimeAnimation
  80260. * Used to synchronize Animatables
  80261. */
  80262. readonly masterFrame: number;
  80263. /**
  80264. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  80265. */
  80266. weight: number;
  80267. /**
  80268. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  80269. */
  80270. speedRatio: number;
  80271. /**
  80272. * Creates a new Animatable
  80273. * @param scene defines the hosting scene
  80274. * @param target defines the target object
  80275. * @param fromFrame defines the starting frame number (default is 0)
  80276. * @param toFrame defines the ending frame number (default is 100)
  80277. * @param loopAnimation defines if the animation must loop (default is false)
  80278. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  80279. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  80280. * @param animations defines a group of animation to add to the new Animatable
  80281. * @param onAnimationLoop defines a callback to call when animation loops
  80282. */
  80283. constructor(scene: Scene,
  80284. /** defines the target object */
  80285. target: any,
  80286. /** defines the starting frame number (default is 0) */
  80287. fromFrame?: number,
  80288. /** defines the ending frame number (default is 100) */
  80289. toFrame?: number,
  80290. /** defines if the animation must loop (default is false) */
  80291. loopAnimation?: boolean, speedRatio?: number,
  80292. /** defines a callback to call when animation ends if it is not looping */
  80293. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  80294. /** defines a callback to call when animation loops */
  80295. onAnimationLoop?: (() => void) | null | undefined);
  80296. /**
  80297. * Synchronize and normalize current Animatable with a source Animatable
  80298. * This is useful when using animation weights and when animations are not of the same length
  80299. * @param root defines the root Animatable to synchronize with
  80300. * @returns the current Animatable
  80301. */
  80302. syncWith(root: Animatable): Animatable;
  80303. /**
  80304. * Gets the list of runtime animations
  80305. * @returns an array of RuntimeAnimation
  80306. */
  80307. getAnimations(): RuntimeAnimation[];
  80308. /**
  80309. * Adds more animations to the current animatable
  80310. * @param target defines the target of the animations
  80311. * @param animations defines the new animations to add
  80312. */
  80313. appendAnimations(target: any, animations: Animation[]): void;
  80314. /**
  80315. * Gets the source animation for a specific property
  80316. * @param property defines the propertyu to look for
  80317. * @returns null or the source animation for the given property
  80318. */
  80319. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  80320. /**
  80321. * Gets the runtime animation for a specific property
  80322. * @param property defines the propertyu to look for
  80323. * @returns null or the runtime animation for the given property
  80324. */
  80325. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  80326. /**
  80327. * Resets the animatable to its original state
  80328. */
  80329. reset(): void;
  80330. /**
  80331. * Allows the animatable to blend with current running animations
  80332. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80333. * @param blendingSpeed defines the blending speed to use
  80334. */
  80335. enableBlending(blendingSpeed: number): void;
  80336. /**
  80337. * Disable animation blending
  80338. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80339. */
  80340. disableBlending(): void;
  80341. /**
  80342. * Jump directly to a given frame
  80343. * @param frame defines the frame to jump to
  80344. */
  80345. goToFrame(frame: number): void;
  80346. /**
  80347. * Pause the animation
  80348. */
  80349. pause(): void;
  80350. /**
  80351. * Restart the animation
  80352. */
  80353. restart(): void;
  80354. private _raiseOnAnimationEnd;
  80355. /**
  80356. * Stop and delete the current animation
  80357. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  80358. * @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)
  80359. */
  80360. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  80361. /**
  80362. * Wait asynchronously for the animation to end
  80363. * @returns a promise which will be fullfilled when the animation ends
  80364. */
  80365. waitAsync(): Promise<Animatable>;
  80366. /** @hidden */
  80367. _animate(delay: number): boolean;
  80368. }
  80369. interface Scene {
  80370. /** @hidden */
  80371. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  80372. /** @hidden */
  80373. _processLateAnimationBindingsForMatrices(holder: {
  80374. totalWeight: number;
  80375. animations: RuntimeAnimation[];
  80376. originalValue: Matrix;
  80377. }): any;
  80378. /** @hidden */
  80379. _processLateAnimationBindingsForQuaternions(holder: {
  80380. totalWeight: number;
  80381. animations: RuntimeAnimation[];
  80382. originalValue: Quaternion;
  80383. }, refQuaternion: Quaternion): Quaternion;
  80384. /** @hidden */
  80385. _processLateAnimationBindings(): void;
  80386. /**
  80387. * Will start the animation sequence of a given target
  80388. * @param target defines the target
  80389. * @param from defines from which frame should animation start
  80390. * @param to defines until which frame should animation run.
  80391. * @param weight defines the weight to apply to the animation (1.0 by default)
  80392. * @param loop defines if the animation loops
  80393. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80394. * @param onAnimationEnd defines the function to be executed when the animation ends
  80395. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80396. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80397. * @param onAnimationLoop defines the callback to call when an animation loops
  80398. * @returns the animatable object created for this animation
  80399. */
  80400. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80401. /**
  80402. * Will start the animation sequence of a given target
  80403. * @param target defines the target
  80404. * @param from defines from which frame should animation start
  80405. * @param to defines until which frame should animation run.
  80406. * @param loop defines if the animation loops
  80407. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80408. * @param onAnimationEnd defines the function to be executed when the animation ends
  80409. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80410. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80411. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  80412. * @param onAnimationLoop defines the callback to call when an animation loops
  80413. * @returns the animatable object created for this animation
  80414. */
  80415. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80416. /**
  80417. * Will start the animation sequence of a given target and its hierarchy
  80418. * @param target defines the target
  80419. * @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.
  80420. * @param from defines from which frame should animation start
  80421. * @param to defines until which frame should animation run.
  80422. * @param loop defines if the animation loops
  80423. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80424. * @param onAnimationEnd defines the function to be executed when the animation ends
  80425. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80426. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80427. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80428. * @param onAnimationLoop defines the callback to call when an animation loops
  80429. * @returns the list of created animatables
  80430. */
  80431. 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[];
  80432. /**
  80433. * Begin a new animation on a given node
  80434. * @param target defines the target where the animation will take place
  80435. * @param animations defines the list of animations to start
  80436. * @param from defines the initial value
  80437. * @param to defines the final value
  80438. * @param loop defines if you want animation to loop (off by default)
  80439. * @param speedRatio defines the speed ratio to apply to all animations
  80440. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80441. * @param onAnimationLoop defines the callback to call when an animation loops
  80442. * @returns the list of created animatables
  80443. */
  80444. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  80445. /**
  80446. * Begin a new animation on a given node and its hierarchy
  80447. * @param target defines the root node where the animation will take place
  80448. * @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.
  80449. * @param animations defines the list of animations to start
  80450. * @param from defines the initial value
  80451. * @param to defines the final value
  80452. * @param loop defines if you want animation to loop (off by default)
  80453. * @param speedRatio defines the speed ratio to apply to all animations
  80454. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80455. * @param onAnimationLoop defines the callback to call when an animation loops
  80456. * @returns the list of animatables created for all nodes
  80457. */
  80458. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  80459. /**
  80460. * Gets the animatable associated with a specific target
  80461. * @param target defines the target of the animatable
  80462. * @returns the required animatable if found
  80463. */
  80464. getAnimatableByTarget(target: any): Nullable<Animatable>;
  80465. /**
  80466. * Gets all animatables associated with a given target
  80467. * @param target defines the target to look animatables for
  80468. * @returns an array of Animatables
  80469. */
  80470. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  80471. /**
  80472. * Will stop the animation of the given target
  80473. * @param target - the target
  80474. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  80475. * @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)
  80476. */
  80477. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  80478. /**
  80479. * Stops and removes all animations that have been applied to the scene
  80480. */
  80481. stopAllAnimations(): void;
  80482. }
  80483. interface Bone {
  80484. /**
  80485. * Copy an animation range from another bone
  80486. * @param source defines the source bone
  80487. * @param rangeName defines the range name to copy
  80488. * @param frameOffset defines the frame offset
  80489. * @param rescaleAsRequired defines if rescaling must be applied if required
  80490. * @param skelDimensionsRatio defines the scaling ratio
  80491. * @returns true if operation was successful
  80492. */
  80493. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  80494. }
  80495. }
  80496. declare module BABYLON {
  80497. /**
  80498. * Defines how a node can be built from a string name.
  80499. */
  80500. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  80501. /**
  80502. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  80503. */
  80504. export class Node implements IBehaviorAware<Node> {
  80505. /** @hidden */
  80506. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  80507. private static _NodeConstructors;
  80508. /**
  80509. * Add a new node constructor
  80510. * @param type defines the type name of the node to construct
  80511. * @param constructorFunc defines the constructor function
  80512. */
  80513. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  80514. /**
  80515. * Returns a node constructor based on type name
  80516. * @param type defines the type name
  80517. * @param name defines the new node name
  80518. * @param scene defines the hosting scene
  80519. * @param options defines optional options to transmit to constructors
  80520. * @returns the new constructor or null
  80521. */
  80522. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  80523. /**
  80524. * Gets or sets the name of the node
  80525. */
  80526. name: string;
  80527. /**
  80528. * Gets or sets the id of the node
  80529. */
  80530. id: string;
  80531. /**
  80532. * Gets or sets the unique id of the node
  80533. */
  80534. uniqueId: number;
  80535. /**
  80536. * Gets or sets a string used to store user defined state for the node
  80537. */
  80538. state: string;
  80539. /**
  80540. * Gets or sets an object used to store user defined information for the node
  80541. */
  80542. metadata: any;
  80543. /**
  80544. * For internal use only. Please do not use.
  80545. */
  80546. reservedDataStore: any;
  80547. /**
  80548. * Gets or sets a boolean used to define if the node must be serialized
  80549. */
  80550. doNotSerialize: boolean;
  80551. /** @hidden */
  80552. _isDisposed: boolean;
  80553. /**
  80554. * Gets a list of Animations associated with the node
  80555. */
  80556. animations: Animation[];
  80557. protected _ranges: {
  80558. [name: string]: Nullable<AnimationRange>;
  80559. };
  80560. /**
  80561. * Callback raised when the node is ready to be used
  80562. */
  80563. onReady: (node: Node) => void;
  80564. private _isEnabled;
  80565. private _isParentEnabled;
  80566. private _isReady;
  80567. /** @hidden */
  80568. _currentRenderId: number;
  80569. private _parentRenderId;
  80570. protected _childRenderId: number;
  80571. /** @hidden */
  80572. _waitingParentId: Nullable<string>;
  80573. /** @hidden */
  80574. _scene: Scene;
  80575. /** @hidden */
  80576. _cache: any;
  80577. private _parentNode;
  80578. private _children;
  80579. /** @hidden */
  80580. _worldMatrix: Matrix;
  80581. /** @hidden */
  80582. _worldMatrixDeterminant: number;
  80583. /** @hidden */
  80584. private _sceneRootNodesIndex;
  80585. /**
  80586. * Gets a boolean indicating if the node has been disposed
  80587. * @returns true if the node was disposed
  80588. */
  80589. isDisposed(): boolean;
  80590. /**
  80591. * Gets or sets the parent of the node
  80592. */
  80593. parent: Nullable<Node>;
  80594. private addToSceneRootNodes;
  80595. private removeFromSceneRootNodes;
  80596. private _animationPropertiesOverride;
  80597. /**
  80598. * Gets or sets the animation properties override
  80599. */
  80600. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80601. /**
  80602. * Gets a string idenfifying the name of the class
  80603. * @returns "Node" string
  80604. */
  80605. getClassName(): string;
  80606. /** @hidden */
  80607. readonly _isNode: boolean;
  80608. /**
  80609. * An event triggered when the mesh is disposed
  80610. */
  80611. onDisposeObservable: Observable<Node>;
  80612. private _onDisposeObserver;
  80613. /**
  80614. * Sets a callback that will be raised when the node will be disposed
  80615. */
  80616. onDispose: () => void;
  80617. /**
  80618. * Creates a new Node
  80619. * @param name the name and id to be given to this node
  80620. * @param scene the scene this node will be added to
  80621. * @param addToRootNodes the node will be added to scene.rootNodes
  80622. */
  80623. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  80624. /**
  80625. * Gets the scene of the node
  80626. * @returns a scene
  80627. */
  80628. getScene(): Scene;
  80629. /**
  80630. * Gets the engine of the node
  80631. * @returns a Engine
  80632. */
  80633. getEngine(): Engine;
  80634. private _behaviors;
  80635. /**
  80636. * Attach a behavior to the node
  80637. * @see http://doc.babylonjs.com/features/behaviour
  80638. * @param behavior defines the behavior to attach
  80639. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  80640. * @returns the current Node
  80641. */
  80642. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  80643. /**
  80644. * Remove an attached behavior
  80645. * @see http://doc.babylonjs.com/features/behaviour
  80646. * @param behavior defines the behavior to attach
  80647. * @returns the current Node
  80648. */
  80649. removeBehavior(behavior: Behavior<Node>): Node;
  80650. /**
  80651. * Gets the list of attached behaviors
  80652. * @see http://doc.babylonjs.com/features/behaviour
  80653. */
  80654. readonly behaviors: Behavior<Node>[];
  80655. /**
  80656. * Gets an attached behavior by name
  80657. * @param name defines the name of the behavior to look for
  80658. * @see http://doc.babylonjs.com/features/behaviour
  80659. * @returns null if behavior was not found else the requested behavior
  80660. */
  80661. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  80662. /**
  80663. * Returns the latest update of the World matrix
  80664. * @returns a Matrix
  80665. */
  80666. getWorldMatrix(): Matrix;
  80667. /** @hidden */
  80668. _getWorldMatrixDeterminant(): number;
  80669. /**
  80670. * Returns directly the latest state of the mesh World matrix.
  80671. * A Matrix is returned.
  80672. */
  80673. readonly worldMatrixFromCache: Matrix;
  80674. /** @hidden */
  80675. _initCache(): void;
  80676. /** @hidden */
  80677. updateCache(force?: boolean): void;
  80678. /** @hidden */
  80679. _updateCache(ignoreParentClass?: boolean): void;
  80680. /** @hidden */
  80681. _isSynchronized(): boolean;
  80682. /** @hidden */
  80683. _markSyncedWithParent(): void;
  80684. /** @hidden */
  80685. isSynchronizedWithParent(): boolean;
  80686. /** @hidden */
  80687. isSynchronized(): boolean;
  80688. /**
  80689. * Is this node ready to be used/rendered
  80690. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  80691. * @return true if the node is ready
  80692. */
  80693. isReady(completeCheck?: boolean): boolean;
  80694. /**
  80695. * Is this node enabled?
  80696. * 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
  80697. * @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
  80698. * @return whether this node (and its parent) is enabled
  80699. */
  80700. isEnabled(checkAncestors?: boolean): boolean;
  80701. /** @hidden */
  80702. protected _syncParentEnabledState(): void;
  80703. /**
  80704. * Set the enabled state of this node
  80705. * @param value defines the new enabled state
  80706. */
  80707. setEnabled(value: boolean): void;
  80708. /**
  80709. * Is this node a descendant of the given node?
  80710. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  80711. * @param ancestor defines the parent node to inspect
  80712. * @returns a boolean indicating if this node is a descendant of the given node
  80713. */
  80714. isDescendantOf(ancestor: Node): boolean;
  80715. /** @hidden */
  80716. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  80717. /**
  80718. * Will return all nodes that have this node as ascendant
  80719. * @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
  80720. * @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
  80721. * @return all children nodes of all types
  80722. */
  80723. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  80724. /**
  80725. * Get all child-meshes of this node
  80726. * @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
  80727. * @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
  80728. * @returns an array of AbstractMesh
  80729. */
  80730. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  80731. /**
  80732. * Get all direct children of this node
  80733. * @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
  80734. * @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)
  80735. * @returns an array of Node
  80736. */
  80737. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  80738. /** @hidden */
  80739. _setReady(state: boolean): void;
  80740. /**
  80741. * Get an animation by name
  80742. * @param name defines the name of the animation to look for
  80743. * @returns null if not found else the requested animation
  80744. */
  80745. getAnimationByName(name: string): Nullable<Animation>;
  80746. /**
  80747. * Creates an animation range for this node
  80748. * @param name defines the name of the range
  80749. * @param from defines the starting key
  80750. * @param to defines the end key
  80751. */
  80752. createAnimationRange(name: string, from: number, to: number): void;
  80753. /**
  80754. * Delete a specific animation range
  80755. * @param name defines the name of the range to delete
  80756. * @param deleteFrames defines if animation frames from the range must be deleted as well
  80757. */
  80758. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80759. /**
  80760. * Get an animation range by name
  80761. * @param name defines the name of the animation range to look for
  80762. * @returns null if not found else the requested animation range
  80763. */
  80764. getAnimationRange(name: string): Nullable<AnimationRange>;
  80765. /**
  80766. * Will start the animation sequence
  80767. * @param name defines the range frames for animation sequence
  80768. * @param loop defines if the animation should loop (false by default)
  80769. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  80770. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  80771. * @returns the object created for this animation. If range does not exist, it will return null
  80772. */
  80773. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80774. /**
  80775. * Serialize animation ranges into a JSON compatible object
  80776. * @returns serialization object
  80777. */
  80778. serializeAnimationRanges(): any;
  80779. /**
  80780. * Computes the world matrix of the node
  80781. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80782. * @returns the world matrix
  80783. */
  80784. computeWorldMatrix(force?: boolean): Matrix;
  80785. /**
  80786. * Releases resources associated with this node.
  80787. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80788. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80789. */
  80790. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80791. /**
  80792. * Parse animation range data from a serialization object and store them into a given node
  80793. * @param node defines where to store the animation ranges
  80794. * @param parsedNode defines the serialization object to read data from
  80795. * @param scene defines the hosting scene
  80796. */
  80797. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  80798. }
  80799. }
  80800. declare module BABYLON {
  80801. /**
  80802. * Class used to store any kind of animation
  80803. */
  80804. export class Animation {
  80805. /**Name of the animation */
  80806. name: string;
  80807. /**Property to animate */
  80808. targetProperty: string;
  80809. /**The frames per second of the animation */
  80810. framePerSecond: number;
  80811. /**The data type of the animation */
  80812. dataType: number;
  80813. /**The loop mode of the animation */
  80814. loopMode?: number | undefined;
  80815. /**Specifies if blending should be enabled */
  80816. enableBlending?: boolean | undefined;
  80817. /**
  80818. * Use matrix interpolation instead of using direct key value when animating matrices
  80819. */
  80820. static AllowMatricesInterpolation: boolean;
  80821. /**
  80822. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  80823. */
  80824. static AllowMatrixDecomposeForInterpolation: boolean;
  80825. /**
  80826. * Stores the key frames of the animation
  80827. */
  80828. private _keys;
  80829. /**
  80830. * Stores the easing function of the animation
  80831. */
  80832. private _easingFunction;
  80833. /**
  80834. * @hidden Internal use only
  80835. */
  80836. _runtimeAnimations: RuntimeAnimation[];
  80837. /**
  80838. * The set of event that will be linked to this animation
  80839. */
  80840. private _events;
  80841. /**
  80842. * Stores an array of target property paths
  80843. */
  80844. targetPropertyPath: string[];
  80845. /**
  80846. * Stores the blending speed of the animation
  80847. */
  80848. blendingSpeed: number;
  80849. /**
  80850. * Stores the animation ranges for the animation
  80851. */
  80852. private _ranges;
  80853. /**
  80854. * @hidden Internal use
  80855. */
  80856. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  80857. /**
  80858. * Sets up an animation
  80859. * @param property The property to animate
  80860. * @param animationType The animation type to apply
  80861. * @param framePerSecond The frames per second of the animation
  80862. * @param easingFunction The easing function used in the animation
  80863. * @returns The created animation
  80864. */
  80865. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  80866. /**
  80867. * Create and start an animation on a node
  80868. * @param name defines the name of the global animation that will be run on all nodes
  80869. * @param node defines the root node where the animation will take place
  80870. * @param targetProperty defines property to animate
  80871. * @param framePerSecond defines the number of frame per second yo use
  80872. * @param totalFrame defines the number of frames in total
  80873. * @param from defines the initial value
  80874. * @param to defines the final value
  80875. * @param loopMode defines which loop mode you want to use (off by default)
  80876. * @param easingFunction defines the easing function to use (linear by default)
  80877. * @param onAnimationEnd defines the callback to call when animation end
  80878. * @returns the animatable created for this animation
  80879. */
  80880. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  80881. /**
  80882. * Create and start an animation on a node and its descendants
  80883. * @param name defines the name of the global animation that will be run on all nodes
  80884. * @param node defines the root node where the animation will take place
  80885. * @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
  80886. * @param targetProperty defines property to animate
  80887. * @param framePerSecond defines the number of frame per second to use
  80888. * @param totalFrame defines the number of frames in total
  80889. * @param from defines the initial value
  80890. * @param to defines the final value
  80891. * @param loopMode defines which loop mode you want to use (off by default)
  80892. * @param easingFunction defines the easing function to use (linear by default)
  80893. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80894. * @returns the list of animatables created for all nodes
  80895. * @example https://www.babylonjs-playground.com/#MH0VLI
  80896. */
  80897. 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[]>;
  80898. /**
  80899. * Creates a new animation, merges it with the existing animations and starts it
  80900. * @param name Name of the animation
  80901. * @param node Node which contains the scene that begins the animations
  80902. * @param targetProperty Specifies which property to animate
  80903. * @param framePerSecond The frames per second of the animation
  80904. * @param totalFrame The total number of frames
  80905. * @param from The frame at the beginning of the animation
  80906. * @param to The frame at the end of the animation
  80907. * @param loopMode Specifies the loop mode of the animation
  80908. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  80909. * @param onAnimationEnd Callback to run once the animation is complete
  80910. * @returns Nullable animation
  80911. */
  80912. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  80913. /**
  80914. * Transition property of an host to the target Value
  80915. * @param property The property to transition
  80916. * @param targetValue The target Value of the property
  80917. * @param host The object where the property to animate belongs
  80918. * @param scene Scene used to run the animation
  80919. * @param frameRate Framerate (in frame/s) to use
  80920. * @param transition The transition type we want to use
  80921. * @param duration The duration of the animation, in milliseconds
  80922. * @param onAnimationEnd Callback trigger at the end of the animation
  80923. * @returns Nullable animation
  80924. */
  80925. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  80926. /**
  80927. * Return the array of runtime animations currently using this animation
  80928. */
  80929. readonly runtimeAnimations: RuntimeAnimation[];
  80930. /**
  80931. * Specifies if any of the runtime animations are currently running
  80932. */
  80933. readonly hasRunningRuntimeAnimations: boolean;
  80934. /**
  80935. * Initializes the animation
  80936. * @param name Name of the animation
  80937. * @param targetProperty Property to animate
  80938. * @param framePerSecond The frames per second of the animation
  80939. * @param dataType The data type of the animation
  80940. * @param loopMode The loop mode of the animation
  80941. * @param enableBlending Specifies if blending should be enabled
  80942. */
  80943. constructor(
  80944. /**Name of the animation */
  80945. name: string,
  80946. /**Property to animate */
  80947. targetProperty: string,
  80948. /**The frames per second of the animation */
  80949. framePerSecond: number,
  80950. /**The data type of the animation */
  80951. dataType: number,
  80952. /**The loop mode of the animation */
  80953. loopMode?: number | undefined,
  80954. /**Specifies if blending should be enabled */
  80955. enableBlending?: boolean | undefined);
  80956. /**
  80957. * Converts the animation to a string
  80958. * @param fullDetails support for multiple levels of logging within scene loading
  80959. * @returns String form of the animation
  80960. */
  80961. toString(fullDetails?: boolean): string;
  80962. /**
  80963. * Add an event to this animation
  80964. * @param event Event to add
  80965. */
  80966. addEvent(event: AnimationEvent): void;
  80967. /**
  80968. * Remove all events found at the given frame
  80969. * @param frame The frame to remove events from
  80970. */
  80971. removeEvents(frame: number): void;
  80972. /**
  80973. * Retrieves all the events from the animation
  80974. * @returns Events from the animation
  80975. */
  80976. getEvents(): AnimationEvent[];
  80977. /**
  80978. * Creates an animation range
  80979. * @param name Name of the animation range
  80980. * @param from Starting frame of the animation range
  80981. * @param to Ending frame of the animation
  80982. */
  80983. createRange(name: string, from: number, to: number): void;
  80984. /**
  80985. * Deletes an animation range by name
  80986. * @param name Name of the animation range to delete
  80987. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  80988. */
  80989. deleteRange(name: string, deleteFrames?: boolean): void;
  80990. /**
  80991. * Gets the animation range by name, or null if not defined
  80992. * @param name Name of the animation range
  80993. * @returns Nullable animation range
  80994. */
  80995. getRange(name: string): Nullable<AnimationRange>;
  80996. /**
  80997. * Gets the key frames from the animation
  80998. * @returns The key frames of the animation
  80999. */
  81000. getKeys(): Array<IAnimationKey>;
  81001. /**
  81002. * Gets the highest frame rate of the animation
  81003. * @returns Highest frame rate of the animation
  81004. */
  81005. getHighestFrame(): number;
  81006. /**
  81007. * Gets the easing function of the animation
  81008. * @returns Easing function of the animation
  81009. */
  81010. getEasingFunction(): IEasingFunction;
  81011. /**
  81012. * Sets the easing function of the animation
  81013. * @param easingFunction A custom mathematical formula for animation
  81014. */
  81015. setEasingFunction(easingFunction: EasingFunction): void;
  81016. /**
  81017. * Interpolates a scalar linearly
  81018. * @param startValue Start value of the animation curve
  81019. * @param endValue End value of the animation curve
  81020. * @param gradient Scalar amount to interpolate
  81021. * @returns Interpolated scalar value
  81022. */
  81023. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  81024. /**
  81025. * Interpolates a scalar cubically
  81026. * @param startValue Start value of the animation curve
  81027. * @param outTangent End tangent of the animation
  81028. * @param endValue End value of the animation curve
  81029. * @param inTangent Start tangent of the animation curve
  81030. * @param gradient Scalar amount to interpolate
  81031. * @returns Interpolated scalar value
  81032. */
  81033. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  81034. /**
  81035. * Interpolates a quaternion using a spherical linear interpolation
  81036. * @param startValue Start value of the animation curve
  81037. * @param endValue End value of the animation curve
  81038. * @param gradient Scalar amount to interpolate
  81039. * @returns Interpolated quaternion value
  81040. */
  81041. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  81042. /**
  81043. * Interpolates a quaternion cubically
  81044. * @param startValue Start value of the animation curve
  81045. * @param outTangent End tangent of the animation curve
  81046. * @param endValue End value of the animation curve
  81047. * @param inTangent Start tangent of the animation curve
  81048. * @param gradient Scalar amount to interpolate
  81049. * @returns Interpolated quaternion value
  81050. */
  81051. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  81052. /**
  81053. * Interpolates a Vector3 linearl
  81054. * @param startValue Start value of the animation curve
  81055. * @param endValue End value of the animation curve
  81056. * @param gradient Scalar amount to interpolate
  81057. * @returns Interpolated scalar value
  81058. */
  81059. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  81060. /**
  81061. * Interpolates a Vector3 cubically
  81062. * @param startValue Start value of the animation curve
  81063. * @param outTangent End tangent of the animation
  81064. * @param endValue End value of the animation curve
  81065. * @param inTangent Start tangent of the animation curve
  81066. * @param gradient Scalar amount to interpolate
  81067. * @returns InterpolatedVector3 value
  81068. */
  81069. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  81070. /**
  81071. * Interpolates a Vector2 linearly
  81072. * @param startValue Start value of the animation curve
  81073. * @param endValue End value of the animation curve
  81074. * @param gradient Scalar amount to interpolate
  81075. * @returns Interpolated Vector2 value
  81076. */
  81077. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  81078. /**
  81079. * Interpolates a Vector2 cubically
  81080. * @param startValue Start value of the animation curve
  81081. * @param outTangent End tangent of the animation
  81082. * @param endValue End value of the animation curve
  81083. * @param inTangent Start tangent of the animation curve
  81084. * @param gradient Scalar amount to interpolate
  81085. * @returns Interpolated Vector2 value
  81086. */
  81087. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  81088. /**
  81089. * Interpolates a size linearly
  81090. * @param startValue Start value of the animation curve
  81091. * @param endValue End value of the animation curve
  81092. * @param gradient Scalar amount to interpolate
  81093. * @returns Interpolated Size value
  81094. */
  81095. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  81096. /**
  81097. * Interpolates a Color3 linearly
  81098. * @param startValue Start value of the animation curve
  81099. * @param endValue End value of the animation curve
  81100. * @param gradient Scalar amount to interpolate
  81101. * @returns Interpolated Color3 value
  81102. */
  81103. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  81104. /**
  81105. * @hidden Internal use only
  81106. */
  81107. _getKeyValue(value: any): any;
  81108. /**
  81109. * @hidden Internal use only
  81110. */
  81111. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  81112. /**
  81113. * Defines the function to use to interpolate matrices
  81114. * @param startValue defines the start matrix
  81115. * @param endValue defines the end matrix
  81116. * @param gradient defines the gradient between both matrices
  81117. * @param result defines an optional target matrix where to store the interpolation
  81118. * @returns the interpolated matrix
  81119. */
  81120. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  81121. /**
  81122. * Makes a copy of the animation
  81123. * @returns Cloned animation
  81124. */
  81125. clone(): Animation;
  81126. /**
  81127. * Sets the key frames of the animation
  81128. * @param values The animation key frames to set
  81129. */
  81130. setKeys(values: Array<IAnimationKey>): void;
  81131. /**
  81132. * Serializes the animation to an object
  81133. * @returns Serialized object
  81134. */
  81135. serialize(): any;
  81136. /**
  81137. * Float animation type
  81138. */
  81139. private static _ANIMATIONTYPE_FLOAT;
  81140. /**
  81141. * Vector3 animation type
  81142. */
  81143. private static _ANIMATIONTYPE_VECTOR3;
  81144. /**
  81145. * Quaternion animation type
  81146. */
  81147. private static _ANIMATIONTYPE_QUATERNION;
  81148. /**
  81149. * Matrix animation type
  81150. */
  81151. private static _ANIMATIONTYPE_MATRIX;
  81152. /**
  81153. * Color3 animation type
  81154. */
  81155. private static _ANIMATIONTYPE_COLOR3;
  81156. /**
  81157. * Vector2 animation type
  81158. */
  81159. private static _ANIMATIONTYPE_VECTOR2;
  81160. /**
  81161. * Size animation type
  81162. */
  81163. private static _ANIMATIONTYPE_SIZE;
  81164. /**
  81165. * Relative Loop Mode
  81166. */
  81167. private static _ANIMATIONLOOPMODE_RELATIVE;
  81168. /**
  81169. * Cycle Loop Mode
  81170. */
  81171. private static _ANIMATIONLOOPMODE_CYCLE;
  81172. /**
  81173. * Constant Loop Mode
  81174. */
  81175. private static _ANIMATIONLOOPMODE_CONSTANT;
  81176. /**
  81177. * Get the float animation type
  81178. */
  81179. static readonly ANIMATIONTYPE_FLOAT: number;
  81180. /**
  81181. * Get the Vector3 animation type
  81182. */
  81183. static readonly ANIMATIONTYPE_VECTOR3: number;
  81184. /**
  81185. * Get the Vector2 animation type
  81186. */
  81187. static readonly ANIMATIONTYPE_VECTOR2: number;
  81188. /**
  81189. * Get the Size animation type
  81190. */
  81191. static readonly ANIMATIONTYPE_SIZE: number;
  81192. /**
  81193. * Get the Quaternion animation type
  81194. */
  81195. static readonly ANIMATIONTYPE_QUATERNION: number;
  81196. /**
  81197. * Get the Matrix animation type
  81198. */
  81199. static readonly ANIMATIONTYPE_MATRIX: number;
  81200. /**
  81201. * Get the Color3 animation type
  81202. */
  81203. static readonly ANIMATIONTYPE_COLOR3: number;
  81204. /**
  81205. * Get the Relative Loop Mode
  81206. */
  81207. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  81208. /**
  81209. * Get the Cycle Loop Mode
  81210. */
  81211. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  81212. /**
  81213. * Get the Constant Loop Mode
  81214. */
  81215. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  81216. /** @hidden */
  81217. static _UniversalLerp(left: any, right: any, amount: number): any;
  81218. /**
  81219. * Parses an animation object and creates an animation
  81220. * @param parsedAnimation Parsed animation object
  81221. * @returns Animation object
  81222. */
  81223. static Parse(parsedAnimation: any): Animation;
  81224. /**
  81225. * Appends the serialized animations from the source animations
  81226. * @param source Source containing the animations
  81227. * @param destination Target to store the animations
  81228. */
  81229. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  81230. }
  81231. }
  81232. declare module BABYLON {
  81233. /**
  81234. * Base class of all the textures in babylon.
  81235. * It groups all the common properties the materials, post process, lights... might need
  81236. * in order to make a correct use of the texture.
  81237. */
  81238. export class BaseTexture implements IAnimatable {
  81239. /**
  81240. * Default anisotropic filtering level for the application.
  81241. * It is set to 4 as a good tradeoff between perf and quality.
  81242. */
  81243. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  81244. /**
  81245. * Gets or sets the unique id of the texture
  81246. */
  81247. uniqueId: number;
  81248. /**
  81249. * Define the name of the texture.
  81250. */
  81251. name: string;
  81252. /**
  81253. * Gets or sets an object used to store user defined information.
  81254. */
  81255. metadata: any;
  81256. /**
  81257. * For internal use only. Please do not use.
  81258. */
  81259. reservedDataStore: any;
  81260. private _hasAlpha;
  81261. /**
  81262. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  81263. */
  81264. hasAlpha: boolean;
  81265. /**
  81266. * Defines if the alpha value should be determined via the rgb values.
  81267. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  81268. */
  81269. getAlphaFromRGB: boolean;
  81270. /**
  81271. * Intensity or strength of the texture.
  81272. * It is commonly used by materials to fine tune the intensity of the texture
  81273. */
  81274. level: number;
  81275. /**
  81276. * Define the UV chanel to use starting from 0 and defaulting to 0.
  81277. * This is part of the texture as textures usually maps to one uv set.
  81278. */
  81279. coordinatesIndex: number;
  81280. private _coordinatesMode;
  81281. /**
  81282. * How a texture is mapped.
  81283. *
  81284. * | Value | Type | Description |
  81285. * | ----- | ----------------------------------- | ----------- |
  81286. * | 0 | EXPLICIT_MODE | |
  81287. * | 1 | SPHERICAL_MODE | |
  81288. * | 2 | PLANAR_MODE | |
  81289. * | 3 | CUBIC_MODE | |
  81290. * | 4 | PROJECTION_MODE | |
  81291. * | 5 | SKYBOX_MODE | |
  81292. * | 6 | INVCUBIC_MODE | |
  81293. * | 7 | EQUIRECTANGULAR_MODE | |
  81294. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  81295. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  81296. */
  81297. coordinatesMode: number;
  81298. /**
  81299. * | Value | Type | Description |
  81300. * | ----- | ------------------ | ----------- |
  81301. * | 0 | CLAMP_ADDRESSMODE | |
  81302. * | 1 | WRAP_ADDRESSMODE | |
  81303. * | 2 | MIRROR_ADDRESSMODE | |
  81304. */
  81305. wrapU: number;
  81306. /**
  81307. * | Value | Type | Description |
  81308. * | ----- | ------------------ | ----------- |
  81309. * | 0 | CLAMP_ADDRESSMODE | |
  81310. * | 1 | WRAP_ADDRESSMODE | |
  81311. * | 2 | MIRROR_ADDRESSMODE | |
  81312. */
  81313. wrapV: number;
  81314. /**
  81315. * | Value | Type | Description |
  81316. * | ----- | ------------------ | ----------- |
  81317. * | 0 | CLAMP_ADDRESSMODE | |
  81318. * | 1 | WRAP_ADDRESSMODE | |
  81319. * | 2 | MIRROR_ADDRESSMODE | |
  81320. */
  81321. wrapR: number;
  81322. /**
  81323. * With compliant hardware and browser (supporting anisotropic filtering)
  81324. * this defines the level of anisotropic filtering in the texture.
  81325. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  81326. */
  81327. anisotropicFilteringLevel: number;
  81328. /**
  81329. * Define if the texture is a cube texture or if false a 2d texture.
  81330. */
  81331. isCube: boolean;
  81332. /**
  81333. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  81334. */
  81335. is3D: boolean;
  81336. /**
  81337. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  81338. * HDR texture are usually stored in linear space.
  81339. * This only impacts the PBR and Background materials
  81340. */
  81341. gammaSpace: boolean;
  81342. /**
  81343. * Gets whether or not the texture contains RGBD data.
  81344. */
  81345. readonly isRGBD: boolean;
  81346. /**
  81347. * Is Z inverted in the texture (useful in a cube texture).
  81348. */
  81349. invertZ: boolean;
  81350. /**
  81351. * Are mip maps generated for this texture or not.
  81352. */
  81353. readonly noMipmap: boolean;
  81354. /**
  81355. * @hidden
  81356. */
  81357. lodLevelInAlpha: boolean;
  81358. /**
  81359. * With prefiltered texture, defined the offset used during the prefiltering steps.
  81360. */
  81361. lodGenerationOffset: number;
  81362. /**
  81363. * With prefiltered texture, defined the scale used during the prefiltering steps.
  81364. */
  81365. lodGenerationScale: number;
  81366. /**
  81367. * Define if the texture is a render target.
  81368. */
  81369. isRenderTarget: boolean;
  81370. /**
  81371. * Define the unique id of the texture in the scene.
  81372. */
  81373. readonly uid: string;
  81374. /**
  81375. * Return a string representation of the texture.
  81376. * @returns the texture as a string
  81377. */
  81378. toString(): string;
  81379. /**
  81380. * Get the class name of the texture.
  81381. * @returns "BaseTexture"
  81382. */
  81383. getClassName(): string;
  81384. /**
  81385. * Define the list of animation attached to the texture.
  81386. */
  81387. animations: Animation[];
  81388. /**
  81389. * An event triggered when the texture is disposed.
  81390. */
  81391. onDisposeObservable: Observable<BaseTexture>;
  81392. private _onDisposeObserver;
  81393. /**
  81394. * Callback triggered when the texture has been disposed.
  81395. * Kept for back compatibility, you can use the onDisposeObservable instead.
  81396. */
  81397. onDispose: () => void;
  81398. /**
  81399. * Define the current state of the loading sequence when in delayed load mode.
  81400. */
  81401. delayLoadState: number;
  81402. private _scene;
  81403. /** @hidden */
  81404. _texture: Nullable<InternalTexture>;
  81405. private _uid;
  81406. /**
  81407. * Define if the texture is preventinga material to render or not.
  81408. * If not and the texture is not ready, the engine will use a default black texture instead.
  81409. */
  81410. readonly isBlocking: boolean;
  81411. /**
  81412. * Instantiates a new BaseTexture.
  81413. * Base class of all the textures in babylon.
  81414. * It groups all the common properties the materials, post process, lights... might need
  81415. * in order to make a correct use of the texture.
  81416. * @param scene Define the scene the texture blongs to
  81417. */
  81418. constructor(scene: Nullable<Scene>);
  81419. /**
  81420. * Get the scene the texture belongs to.
  81421. * @returns the scene or null if undefined
  81422. */
  81423. getScene(): Nullable<Scene>;
  81424. /**
  81425. * Get the texture transform matrix used to offset tile the texture for istance.
  81426. * @returns the transformation matrix
  81427. */
  81428. getTextureMatrix(): Matrix;
  81429. /**
  81430. * Get the texture reflection matrix used to rotate/transform the reflection.
  81431. * @returns the reflection matrix
  81432. */
  81433. getReflectionTextureMatrix(): Matrix;
  81434. /**
  81435. * Get the underlying lower level texture from Babylon.
  81436. * @returns the insternal texture
  81437. */
  81438. getInternalTexture(): Nullable<InternalTexture>;
  81439. /**
  81440. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  81441. * @returns true if ready or not blocking
  81442. */
  81443. isReadyOrNotBlocking(): boolean;
  81444. /**
  81445. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  81446. * @returns true if fully ready
  81447. */
  81448. isReady(): boolean;
  81449. private _cachedSize;
  81450. /**
  81451. * Get the size of the texture.
  81452. * @returns the texture size.
  81453. */
  81454. getSize(): ISize;
  81455. /**
  81456. * Get the base size of the texture.
  81457. * It can be different from the size if the texture has been resized for POT for instance
  81458. * @returns the base size
  81459. */
  81460. getBaseSize(): ISize;
  81461. /**
  81462. * Update the sampling mode of the texture.
  81463. * Default is Trilinear mode.
  81464. *
  81465. * | Value | Type | Description |
  81466. * | ----- | ------------------ | ----------- |
  81467. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  81468. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  81469. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  81470. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  81471. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  81472. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  81473. * | 7 | NEAREST_LINEAR | |
  81474. * | 8 | NEAREST_NEAREST | |
  81475. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  81476. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  81477. * | 11 | LINEAR_LINEAR | |
  81478. * | 12 | LINEAR_NEAREST | |
  81479. *
  81480. * > _mag_: magnification filter (close to the viewer)
  81481. * > _min_: minification filter (far from the viewer)
  81482. * > _mip_: filter used between mip map levels
  81483. *@param samplingMode Define the new sampling mode of the texture
  81484. */
  81485. updateSamplingMode(samplingMode: number): void;
  81486. /**
  81487. * Scales the texture if is `canRescale()`
  81488. * @param ratio the resize factor we want to use to rescale
  81489. */
  81490. scale(ratio: number): void;
  81491. /**
  81492. * Get if the texture can rescale.
  81493. */
  81494. readonly canRescale: boolean;
  81495. /** @hidden */
  81496. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  81497. /** @hidden */
  81498. _rebuild(): void;
  81499. /**
  81500. * Triggers the load sequence in delayed load mode.
  81501. */
  81502. delayLoad(): void;
  81503. /**
  81504. * Clones the texture.
  81505. * @returns the cloned texture
  81506. */
  81507. clone(): Nullable<BaseTexture>;
  81508. /**
  81509. * Get the texture underlying type (INT, FLOAT...)
  81510. */
  81511. readonly textureType: number;
  81512. /**
  81513. * Get the texture underlying format (RGB, RGBA...)
  81514. */
  81515. readonly textureFormat: number;
  81516. /**
  81517. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  81518. * This will returns an RGBA array buffer containing either in values (0-255) or
  81519. * float values (0-1) depending of the underlying buffer type.
  81520. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  81521. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  81522. * @param buffer defines a user defined buffer to fill with data (can be null)
  81523. * @returns The Array buffer containing the pixels data.
  81524. */
  81525. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  81526. /**
  81527. * Release and destroy the underlying lower level texture aka internalTexture.
  81528. */
  81529. releaseInternalTexture(): void;
  81530. /**
  81531. * Get the polynomial representation of the texture data.
  81532. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  81533. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  81534. */
  81535. sphericalPolynomial: Nullable<SphericalPolynomial>;
  81536. /** @hidden */
  81537. readonly _lodTextureHigh: Nullable<BaseTexture>;
  81538. /** @hidden */
  81539. readonly _lodTextureMid: Nullable<BaseTexture>;
  81540. /** @hidden */
  81541. readonly _lodTextureLow: Nullable<BaseTexture>;
  81542. /**
  81543. * Dispose the texture and release its associated resources.
  81544. */
  81545. dispose(): void;
  81546. /**
  81547. * Serialize the texture into a JSON representation that can be parsed later on.
  81548. * @returns the JSON representation of the texture
  81549. */
  81550. serialize(): any;
  81551. /**
  81552. * Helper function to be called back once a list of texture contains only ready textures.
  81553. * @param textures Define the list of textures to wait for
  81554. * @param callback Define the callback triggered once the entire list will be ready
  81555. */
  81556. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  81557. }
  81558. }
  81559. declare module BABYLON {
  81560. /**
  81561. * Uniform buffer objects.
  81562. *
  81563. * Handles blocks of uniform on the GPU.
  81564. *
  81565. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81566. *
  81567. * For more information, please refer to :
  81568. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81569. */
  81570. export class UniformBuffer {
  81571. private _engine;
  81572. private _buffer;
  81573. private _data;
  81574. private _bufferData;
  81575. private _dynamic?;
  81576. private _uniformLocations;
  81577. private _uniformSizes;
  81578. private _uniformLocationPointer;
  81579. private _needSync;
  81580. private _noUBO;
  81581. private _currentEffect;
  81582. private static _MAX_UNIFORM_SIZE;
  81583. private static _tempBuffer;
  81584. /**
  81585. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  81586. * This is dynamic to allow compat with webgl 1 and 2.
  81587. * You will need to pass the name of the uniform as well as the value.
  81588. */
  81589. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  81590. /**
  81591. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  81592. * This is dynamic to allow compat with webgl 1 and 2.
  81593. * You will need to pass the name of the uniform as well as the value.
  81594. */
  81595. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  81596. /**
  81597. * Lambda to Update a single float in a uniform buffer.
  81598. * This is dynamic to allow compat with webgl 1 and 2.
  81599. * You will need to pass the name of the uniform as well as the value.
  81600. */
  81601. updateFloat: (name: string, x: number) => void;
  81602. /**
  81603. * Lambda to Update a vec2 of float in a uniform buffer.
  81604. * This is dynamic to allow compat with webgl 1 and 2.
  81605. * You will need to pass the name of the uniform as well as the value.
  81606. */
  81607. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  81608. /**
  81609. * Lambda to Update a vec3 of float in a uniform buffer.
  81610. * This is dynamic to allow compat with webgl 1 and 2.
  81611. * You will need to pass the name of the uniform as well as the value.
  81612. */
  81613. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  81614. /**
  81615. * Lambda to Update a vec4 of float in a uniform buffer.
  81616. * This is dynamic to allow compat with webgl 1 and 2.
  81617. * You will need to pass the name of the uniform as well as the value.
  81618. */
  81619. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  81620. /**
  81621. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  81622. * This is dynamic to allow compat with webgl 1 and 2.
  81623. * You will need to pass the name of the uniform as well as the value.
  81624. */
  81625. updateMatrix: (name: string, mat: Matrix) => void;
  81626. /**
  81627. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  81628. * This is dynamic to allow compat with webgl 1 and 2.
  81629. * You will need to pass the name of the uniform as well as the value.
  81630. */
  81631. updateVector3: (name: string, vector: Vector3) => void;
  81632. /**
  81633. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  81634. * This is dynamic to allow compat with webgl 1 and 2.
  81635. * You will need to pass the name of the uniform as well as the value.
  81636. */
  81637. updateVector4: (name: string, vector: Vector4) => void;
  81638. /**
  81639. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  81640. * This is dynamic to allow compat with webgl 1 and 2.
  81641. * You will need to pass the name of the uniform as well as the value.
  81642. */
  81643. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  81644. /**
  81645. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  81646. * This is dynamic to allow compat with webgl 1 and 2.
  81647. * You will need to pass the name of the uniform as well as the value.
  81648. */
  81649. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  81650. /**
  81651. * Instantiates a new Uniform buffer objects.
  81652. *
  81653. * Handles blocks of uniform on the GPU.
  81654. *
  81655. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81656. *
  81657. * For more information, please refer to :
  81658. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81659. * @param engine Define the engine the buffer is associated with
  81660. * @param data Define the data contained in the buffer
  81661. * @param dynamic Define if the buffer is updatable
  81662. */
  81663. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  81664. /**
  81665. * Indicates if the buffer is using the WebGL2 UBO implementation,
  81666. * or just falling back on setUniformXXX calls.
  81667. */
  81668. readonly useUbo: boolean;
  81669. /**
  81670. * Indicates if the WebGL underlying uniform buffer is in sync
  81671. * with the javascript cache data.
  81672. */
  81673. readonly isSync: boolean;
  81674. /**
  81675. * Indicates if the WebGL underlying uniform buffer is dynamic.
  81676. * Also, a dynamic UniformBuffer will disable cache verification and always
  81677. * update the underlying WebGL uniform buffer to the GPU.
  81678. * @returns if Dynamic, otherwise false
  81679. */
  81680. isDynamic(): boolean;
  81681. /**
  81682. * The data cache on JS side.
  81683. * @returns the underlying data as a float array
  81684. */
  81685. getData(): Float32Array;
  81686. /**
  81687. * The underlying WebGL Uniform buffer.
  81688. * @returns the webgl buffer
  81689. */
  81690. getBuffer(): Nullable<WebGLBuffer>;
  81691. /**
  81692. * std140 layout specifies how to align data within an UBO structure.
  81693. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  81694. * for specs.
  81695. */
  81696. private _fillAlignment;
  81697. /**
  81698. * Adds an uniform in the buffer.
  81699. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  81700. * for the layout to be correct !
  81701. * @param name Name of the uniform, as used in the uniform block in the shader.
  81702. * @param size Data size, or data directly.
  81703. */
  81704. addUniform(name: string, size: number | number[]): void;
  81705. /**
  81706. * Adds a Matrix 4x4 to the uniform buffer.
  81707. * @param name Name of the uniform, as used in the uniform block in the shader.
  81708. * @param mat A 4x4 matrix.
  81709. */
  81710. addMatrix(name: string, mat: Matrix): void;
  81711. /**
  81712. * Adds a vec2 to the uniform buffer.
  81713. * @param name Name of the uniform, as used in the uniform block in the shader.
  81714. * @param x Define the x component value of the vec2
  81715. * @param y Define the y component value of the vec2
  81716. */
  81717. addFloat2(name: string, x: number, y: number): void;
  81718. /**
  81719. * Adds a vec3 to the uniform buffer.
  81720. * @param name Name of the uniform, as used in the uniform block in the shader.
  81721. * @param x Define the x component value of the vec3
  81722. * @param y Define the y component value of the vec3
  81723. * @param z Define the z component value of the vec3
  81724. */
  81725. addFloat3(name: string, x: number, y: number, z: number): void;
  81726. /**
  81727. * Adds a vec3 to the uniform buffer.
  81728. * @param name Name of the uniform, as used in the uniform block in the shader.
  81729. * @param color Define the vec3 from a Color
  81730. */
  81731. addColor3(name: string, color: Color3): void;
  81732. /**
  81733. * Adds a vec4 to the uniform buffer.
  81734. * @param name Name of the uniform, as used in the uniform block in the shader.
  81735. * @param color Define the rgb components from a Color
  81736. * @param alpha Define the a component of the vec4
  81737. */
  81738. addColor4(name: string, color: Color3, alpha: number): void;
  81739. /**
  81740. * Adds a vec3 to the uniform buffer.
  81741. * @param name Name of the uniform, as used in the uniform block in the shader.
  81742. * @param vector Define the vec3 components from a Vector
  81743. */
  81744. addVector3(name: string, vector: Vector3): void;
  81745. /**
  81746. * Adds a Matrix 3x3 to the uniform buffer.
  81747. * @param name Name of the uniform, as used in the uniform block in the shader.
  81748. */
  81749. addMatrix3x3(name: string): void;
  81750. /**
  81751. * Adds a Matrix 2x2 to the uniform buffer.
  81752. * @param name Name of the uniform, as used in the uniform block in the shader.
  81753. */
  81754. addMatrix2x2(name: string): void;
  81755. /**
  81756. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  81757. */
  81758. create(): void;
  81759. /** @hidden */
  81760. _rebuild(): void;
  81761. /**
  81762. * Updates the WebGL Uniform Buffer on the GPU.
  81763. * If the `dynamic` flag is set to true, no cache comparison is done.
  81764. * Otherwise, the buffer will be updated only if the cache differs.
  81765. */
  81766. update(): void;
  81767. /**
  81768. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  81769. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81770. * @param data Define the flattened data
  81771. * @param size Define the size of the data.
  81772. */
  81773. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  81774. private _updateMatrix3x3ForUniform;
  81775. private _updateMatrix3x3ForEffect;
  81776. private _updateMatrix2x2ForEffect;
  81777. private _updateMatrix2x2ForUniform;
  81778. private _updateFloatForEffect;
  81779. private _updateFloatForUniform;
  81780. private _updateFloat2ForEffect;
  81781. private _updateFloat2ForUniform;
  81782. private _updateFloat3ForEffect;
  81783. private _updateFloat3ForUniform;
  81784. private _updateFloat4ForEffect;
  81785. private _updateFloat4ForUniform;
  81786. private _updateMatrixForEffect;
  81787. private _updateMatrixForUniform;
  81788. private _updateVector3ForEffect;
  81789. private _updateVector3ForUniform;
  81790. private _updateVector4ForEffect;
  81791. private _updateVector4ForUniform;
  81792. private _updateColor3ForEffect;
  81793. private _updateColor3ForUniform;
  81794. private _updateColor4ForEffect;
  81795. private _updateColor4ForUniform;
  81796. /**
  81797. * Sets a sampler uniform on the effect.
  81798. * @param name Define the name of the sampler.
  81799. * @param texture Define the texture to set in the sampler
  81800. */
  81801. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  81802. /**
  81803. * Directly updates the value of the uniform in the cache AND on the GPU.
  81804. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81805. * @param data Define the flattened data
  81806. */
  81807. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  81808. /**
  81809. * Binds this uniform buffer to an effect.
  81810. * @param effect Define the effect to bind the buffer to
  81811. * @param name Name of the uniform block in the shader.
  81812. */
  81813. bindToEffect(effect: Effect, name: string): void;
  81814. /**
  81815. * Disposes the uniform buffer.
  81816. */
  81817. dispose(): void;
  81818. }
  81819. }
  81820. declare module BABYLON {
  81821. /**
  81822. * This represents the required contract to create a new type of texture loader.
  81823. */
  81824. export interface IInternalTextureLoader {
  81825. /**
  81826. * Defines wether the loader supports cascade loading the different faces.
  81827. */
  81828. supportCascades: boolean;
  81829. /**
  81830. * This returns if the loader support the current file information.
  81831. * @param extension defines the file extension of the file being loaded
  81832. * @param textureFormatInUse defines the current compressed format in use iun the engine
  81833. * @param fallback defines the fallback internal texture if any
  81834. * @param isBase64 defines whether the texture is encoded as a base64
  81835. * @param isBuffer defines whether the texture data are stored as a buffer
  81836. * @returns true if the loader can load the specified file
  81837. */
  81838. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  81839. /**
  81840. * Transform the url before loading if required.
  81841. * @param rootUrl the url of the texture
  81842. * @param textureFormatInUse defines the current compressed format in use iun the engine
  81843. * @returns the transformed texture
  81844. */
  81845. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  81846. /**
  81847. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  81848. * @param rootUrl the url of the texture
  81849. * @param textureFormatInUse defines the current compressed format in use iun the engine
  81850. * @returns the fallback texture
  81851. */
  81852. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  81853. /**
  81854. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  81855. * @param data contains the texture data
  81856. * @param texture defines the BabylonJS internal texture
  81857. * @param createPolynomials will be true if polynomials have been requested
  81858. * @param onLoad defines the callback to trigger once the texture is ready
  81859. * @param onError defines the callback to trigger in case of error
  81860. */
  81861. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  81862. /**
  81863. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  81864. * @param data contains the texture data
  81865. * @param texture defines the BabylonJS internal texture
  81866. * @param callback defines the method to call once ready to upload
  81867. */
  81868. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  81869. }
  81870. }
  81871. declare module BABYLON {
  81872. /**
  81873. * Creation options of the multi render target texture.
  81874. */
  81875. export interface IMultiRenderTargetOptions {
  81876. /**
  81877. * Define if the texture needs to create mip maps after render.
  81878. */
  81879. generateMipMaps?: boolean;
  81880. /**
  81881. * Define the types of all the draw buffers we want to create
  81882. */
  81883. types?: number[];
  81884. /**
  81885. * Define the sampling modes of all the draw buffers we want to create
  81886. */
  81887. samplingModes?: number[];
  81888. /**
  81889. * Define if a depth buffer is required
  81890. */
  81891. generateDepthBuffer?: boolean;
  81892. /**
  81893. * Define if a stencil buffer is required
  81894. */
  81895. generateStencilBuffer?: boolean;
  81896. /**
  81897. * Define if a depth texture is required instead of a depth buffer
  81898. */
  81899. generateDepthTexture?: boolean;
  81900. /**
  81901. * Define the number of desired draw buffers
  81902. */
  81903. textureCount?: number;
  81904. /**
  81905. * Define if aspect ratio should be adapted to the texture or stay the scene one
  81906. */
  81907. doNotChangeAspectRatio?: boolean;
  81908. /**
  81909. * Define the default type of the buffers we are creating
  81910. */
  81911. defaultType?: number;
  81912. }
  81913. /**
  81914. * A multi render target, like a render target provides the ability to render to a texture.
  81915. * Unlike the render target, it can render to several draw buffers in one draw.
  81916. * This is specially interesting in deferred rendering or for any effects requiring more than
  81917. * just one color from a single pass.
  81918. */
  81919. export class MultiRenderTarget extends RenderTargetTexture {
  81920. private _internalTextures;
  81921. private _textures;
  81922. private _multiRenderTargetOptions;
  81923. /**
  81924. * Get if draw buffers are currently supported by the used hardware and browser.
  81925. */
  81926. readonly isSupported: boolean;
  81927. /**
  81928. * Get the list of textures generated by the multi render target.
  81929. */
  81930. readonly textures: Texture[];
  81931. /**
  81932. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  81933. */
  81934. readonly depthTexture: Texture;
  81935. /**
  81936. * Set the wrapping mode on U of all the textures we are rendering to.
  81937. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  81938. */
  81939. wrapU: number;
  81940. /**
  81941. * Set the wrapping mode on V of all the textures we are rendering to.
  81942. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  81943. */
  81944. wrapV: number;
  81945. /**
  81946. * Instantiate a new multi render target texture.
  81947. * A multi render target, like a render target provides the ability to render to a texture.
  81948. * Unlike the render target, it can render to several draw buffers in one draw.
  81949. * This is specially interesting in deferred rendering or for any effects requiring more than
  81950. * just one color from a single pass.
  81951. * @param name Define the name of the texture
  81952. * @param size Define the size of the buffers to render to
  81953. * @param count Define the number of target we are rendering into
  81954. * @param scene Define the scene the texture belongs to
  81955. * @param options Define the options used to create the multi render target
  81956. */
  81957. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  81958. /** @hidden */
  81959. _rebuild(): void;
  81960. private _createInternalTextures;
  81961. private _createTextures;
  81962. /**
  81963. * Define the number of samples used if MSAA is enabled.
  81964. */
  81965. samples: number;
  81966. /**
  81967. * Resize all the textures in the multi render target.
  81968. * Be carrefull as it will recreate all the data in the new texture.
  81969. * @param size Define the new size
  81970. */
  81971. resize(size: any): void;
  81972. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  81973. /**
  81974. * Dispose the render targets and their associated resources
  81975. */
  81976. dispose(): void;
  81977. /**
  81978. * Release all the underlying texture used as draw buffers.
  81979. */
  81980. releaseInternalTextures(): void;
  81981. }
  81982. }
  81983. declare module BABYLON {
  81984. /**
  81985. * Class used to work with sound analyzer using fast fourier transform (FFT)
  81986. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  81987. */
  81988. export class Analyser {
  81989. /**
  81990. * Gets or sets the smoothing
  81991. * @ignorenaming
  81992. */
  81993. SMOOTHING: number;
  81994. /**
  81995. * Gets or sets the FFT table size
  81996. * @ignorenaming
  81997. */
  81998. FFT_SIZE: number;
  81999. /**
  82000. * Gets or sets the bar graph amplitude
  82001. * @ignorenaming
  82002. */
  82003. BARGRAPHAMPLITUDE: number;
  82004. /**
  82005. * Gets or sets the position of the debug canvas
  82006. * @ignorenaming
  82007. */
  82008. DEBUGCANVASPOS: {
  82009. x: number;
  82010. y: number;
  82011. };
  82012. /**
  82013. * Gets or sets the debug canvas size
  82014. * @ignorenaming
  82015. */
  82016. DEBUGCANVASSIZE: {
  82017. width: number;
  82018. height: number;
  82019. };
  82020. private _byteFreqs;
  82021. private _byteTime;
  82022. private _floatFreqs;
  82023. private _webAudioAnalyser;
  82024. private _debugCanvas;
  82025. private _debugCanvasContext;
  82026. private _scene;
  82027. private _registerFunc;
  82028. private _audioEngine;
  82029. /**
  82030. * Creates a new analyser
  82031. * @param scene defines hosting scene
  82032. */
  82033. constructor(scene: Scene);
  82034. /**
  82035. * Get the number of data values you will have to play with for the visualization
  82036. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  82037. * @returns a number
  82038. */
  82039. getFrequencyBinCount(): number;
  82040. /**
  82041. * Gets the current frequency data as a byte array
  82042. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  82043. * @returns a Uint8Array
  82044. */
  82045. getByteFrequencyData(): Uint8Array;
  82046. /**
  82047. * Gets the current waveform as a byte array
  82048. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  82049. * @returns a Uint8Array
  82050. */
  82051. getByteTimeDomainData(): Uint8Array;
  82052. /**
  82053. * Gets the current frequency data as a float array
  82054. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  82055. * @returns a Float32Array
  82056. */
  82057. getFloatFrequencyData(): Float32Array;
  82058. /**
  82059. * Renders the debug canvas
  82060. */
  82061. drawDebugCanvas(): void;
  82062. /**
  82063. * Stops rendering the debug canvas and removes it
  82064. */
  82065. stopDebugCanvas(): void;
  82066. /**
  82067. * Connects two audio nodes
  82068. * @param inputAudioNode defines first node to connect
  82069. * @param outputAudioNode defines second node to connect
  82070. */
  82071. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  82072. /**
  82073. * Releases all associated resources
  82074. */
  82075. dispose(): void;
  82076. }
  82077. }
  82078. declare module BABYLON {
  82079. /**
  82080. * This represents an audio engine and it is responsible
  82081. * to play, synchronize and analyse sounds throughout the application.
  82082. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82083. */
  82084. export interface IAudioEngine extends IDisposable {
  82085. /**
  82086. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  82087. */
  82088. readonly canUseWebAudio: boolean;
  82089. /**
  82090. * Gets the current AudioContext if available.
  82091. */
  82092. readonly audioContext: Nullable<AudioContext>;
  82093. /**
  82094. * The master gain node defines the global audio volume of your audio engine.
  82095. */
  82096. readonly masterGain: GainNode;
  82097. /**
  82098. * Gets whether or not mp3 are supported by your browser.
  82099. */
  82100. readonly isMP3supported: boolean;
  82101. /**
  82102. * Gets whether or not ogg are supported by your browser.
  82103. */
  82104. readonly isOGGsupported: boolean;
  82105. /**
  82106. * Defines if Babylon should emit a warning if WebAudio is not supported.
  82107. * @ignoreNaming
  82108. */
  82109. WarnedWebAudioUnsupported: boolean;
  82110. /**
  82111. * Defines if the audio engine relies on a custom unlocked button.
  82112. * In this case, the embedded button will not be displayed.
  82113. */
  82114. useCustomUnlockedButton: boolean;
  82115. /**
  82116. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  82117. */
  82118. readonly unlocked: boolean;
  82119. /**
  82120. * Event raised when audio has been unlocked on the browser.
  82121. */
  82122. onAudioUnlockedObservable: Observable<AudioEngine>;
  82123. /**
  82124. * Event raised when audio has been locked on the browser.
  82125. */
  82126. onAudioLockedObservable: Observable<AudioEngine>;
  82127. /**
  82128. * Flags the audio engine in Locked state.
  82129. * This happens due to new browser policies preventing audio to autoplay.
  82130. */
  82131. lock(): void;
  82132. /**
  82133. * Unlocks the audio engine once a user action has been done on the dom.
  82134. * This is helpful to resume play once browser policies have been satisfied.
  82135. */
  82136. unlock(): void;
  82137. }
  82138. /**
  82139. * This represents the default audio engine used in babylon.
  82140. * It is responsible to play, synchronize and analyse sounds throughout the application.
  82141. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82142. */
  82143. export class AudioEngine implements IAudioEngine {
  82144. private _audioContext;
  82145. private _audioContextInitialized;
  82146. private _muteButton;
  82147. private _hostElement;
  82148. /**
  82149. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  82150. */
  82151. canUseWebAudio: boolean;
  82152. /**
  82153. * The master gain node defines the global audio volume of your audio engine.
  82154. */
  82155. masterGain: GainNode;
  82156. /**
  82157. * Defines if Babylon should emit a warning if WebAudio is not supported.
  82158. * @ignoreNaming
  82159. */
  82160. WarnedWebAudioUnsupported: boolean;
  82161. /**
  82162. * Gets whether or not mp3 are supported by your browser.
  82163. */
  82164. isMP3supported: boolean;
  82165. /**
  82166. * Gets whether or not ogg are supported by your browser.
  82167. */
  82168. isOGGsupported: boolean;
  82169. /**
  82170. * Gets whether audio has been unlocked on the device.
  82171. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  82172. * a user interaction has happened.
  82173. */
  82174. unlocked: boolean;
  82175. /**
  82176. * Defines if the audio engine relies on a custom unlocked button.
  82177. * In this case, the embedded button will not be displayed.
  82178. */
  82179. useCustomUnlockedButton: boolean;
  82180. /**
  82181. * Event raised when audio has been unlocked on the browser.
  82182. */
  82183. onAudioUnlockedObservable: Observable<AudioEngine>;
  82184. /**
  82185. * Event raised when audio has been locked on the browser.
  82186. */
  82187. onAudioLockedObservable: Observable<AudioEngine>;
  82188. /**
  82189. * Gets the current AudioContext if available.
  82190. */
  82191. readonly audioContext: Nullable<AudioContext>;
  82192. private _connectedAnalyser;
  82193. /**
  82194. * Instantiates a new audio engine.
  82195. *
  82196. * There should be only one per page as some browsers restrict the number
  82197. * of audio contexts you can create.
  82198. * @param hostElement defines the host element where to display the mute icon if necessary
  82199. */
  82200. constructor(hostElement?: Nullable<HTMLElement>);
  82201. /**
  82202. * Flags the audio engine in Locked state.
  82203. * This happens due to new browser policies preventing audio to autoplay.
  82204. */
  82205. lock(): void;
  82206. /**
  82207. * Unlocks the audio engine once a user action has been done on the dom.
  82208. * This is helpful to resume play once browser policies have been satisfied.
  82209. */
  82210. unlock(): void;
  82211. private _resumeAudioContext;
  82212. private _initializeAudioContext;
  82213. private _tryToRun;
  82214. private _triggerRunningState;
  82215. private _triggerSuspendedState;
  82216. private _displayMuteButton;
  82217. private _moveButtonToTopLeft;
  82218. private _onResize;
  82219. private _hideMuteButton;
  82220. /**
  82221. * Destroy and release the resources associated with the audio ccontext.
  82222. */
  82223. dispose(): void;
  82224. /**
  82225. * Gets the global volume sets on the master gain.
  82226. * @returns the global volume if set or -1 otherwise
  82227. */
  82228. getGlobalVolume(): number;
  82229. /**
  82230. * Sets the global volume of your experience (sets on the master gain).
  82231. * @param newVolume Defines the new global volume of the application
  82232. */
  82233. setGlobalVolume(newVolume: number): void;
  82234. /**
  82235. * Connect the audio engine to an audio analyser allowing some amazing
  82236. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  82237. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  82238. * @param analyser The analyser to connect to the engine
  82239. */
  82240. connectToAnalyser(analyser: Analyser): void;
  82241. }
  82242. }
  82243. declare module BABYLON {
  82244. /**
  82245. * Interface used to present a loading screen while loading a scene
  82246. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  82247. */
  82248. export interface ILoadingScreen {
  82249. /**
  82250. * Function called to display the loading screen
  82251. */
  82252. displayLoadingUI: () => void;
  82253. /**
  82254. * Function called to hide the loading screen
  82255. */
  82256. hideLoadingUI: () => void;
  82257. /**
  82258. * Gets or sets the color to use for the background
  82259. */
  82260. loadingUIBackgroundColor: string;
  82261. /**
  82262. * Gets or sets the text to display while loading
  82263. */
  82264. loadingUIText: string;
  82265. }
  82266. /**
  82267. * Class used for the default loading screen
  82268. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  82269. */
  82270. export class DefaultLoadingScreen implements ILoadingScreen {
  82271. private _renderingCanvas;
  82272. private _loadingText;
  82273. private _loadingDivBackgroundColor;
  82274. private _loadingDiv;
  82275. private _loadingTextDiv;
  82276. /**
  82277. * Creates a new default loading screen
  82278. * @param _renderingCanvas defines the canvas used to render the scene
  82279. * @param _loadingText defines the default text to display
  82280. * @param _loadingDivBackgroundColor defines the default background color
  82281. */
  82282. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  82283. /**
  82284. * Function called to display the loading screen
  82285. */
  82286. displayLoadingUI(): void;
  82287. /**
  82288. * Function called to hide the loading screen
  82289. */
  82290. hideLoadingUI(): void;
  82291. /**
  82292. * Gets or sets the text to display while loading
  82293. */
  82294. loadingUIText: string;
  82295. /**
  82296. * Gets or sets the color to use for the background
  82297. */
  82298. loadingUIBackgroundColor: string;
  82299. private _resizeLoadingUI;
  82300. }
  82301. }
  82302. declare module BABYLON {
  82303. /**
  82304. * Settings for finer control over video usage
  82305. */
  82306. export interface VideoTextureSettings {
  82307. /**
  82308. * Applies `autoplay` to video, if specified
  82309. */
  82310. autoPlay?: boolean;
  82311. /**
  82312. * Applies `loop` to video, if specified
  82313. */
  82314. loop?: boolean;
  82315. /**
  82316. * Automatically updates internal texture from video at every frame in the render loop
  82317. */
  82318. autoUpdateTexture: boolean;
  82319. /**
  82320. * Image src displayed during the video loading or until the user interacts with the video.
  82321. */
  82322. poster?: string;
  82323. }
  82324. /**
  82325. * If you want to display a video in your scene, this is the special texture for that.
  82326. * This special texture works similar to other textures, with the exception of a few parameters.
  82327. * @see https://doc.babylonjs.com/how_to/video_texture
  82328. */
  82329. export class VideoTexture extends Texture {
  82330. /**
  82331. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  82332. */
  82333. readonly autoUpdateTexture: boolean;
  82334. /**
  82335. * The video instance used by the texture internally
  82336. */
  82337. readonly video: HTMLVideoElement;
  82338. private _onUserActionRequestedObservable;
  82339. /**
  82340. * Event triggerd when a dom action is required by the user to play the video.
  82341. * This happens due to recent changes in browser policies preventing video to auto start.
  82342. */
  82343. readonly onUserActionRequestedObservable: Observable<Texture>;
  82344. private _generateMipMaps;
  82345. private _engine;
  82346. private _stillImageCaptured;
  82347. private _displayingPosterTexture;
  82348. private _settings;
  82349. private _createInternalTextureOnEvent;
  82350. /**
  82351. * Creates a video texture.
  82352. * If you want to display a video in your scene, this is the special texture for that.
  82353. * This special texture works similar to other textures, with the exception of a few parameters.
  82354. * @see https://doc.babylonjs.com/how_to/video_texture
  82355. * @param name optional name, will detect from video source, if not defined
  82356. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  82357. * @param scene is obviously the current scene.
  82358. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  82359. * @param invertY is false by default but can be used to invert video on Y axis
  82360. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  82361. * @param settings allows finer control over video usage
  82362. */
  82363. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  82364. private _getName;
  82365. private _getVideo;
  82366. private _createInternalTexture;
  82367. private reset;
  82368. /**
  82369. * @hidden Internal method to initiate `update`.
  82370. */
  82371. _rebuild(): void;
  82372. /**
  82373. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  82374. */
  82375. update(): void;
  82376. /**
  82377. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  82378. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  82379. */
  82380. updateTexture(isVisible: boolean): void;
  82381. protected _updateInternalTexture: () => void;
  82382. /**
  82383. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  82384. * @param url New url.
  82385. */
  82386. updateURL(url: string): void;
  82387. /**
  82388. * Dispose the texture and release its associated resources.
  82389. */
  82390. dispose(): void;
  82391. /**
  82392. * Creates a video texture straight from your WebCam video feed.
  82393. * @param scene Define the scene the texture should be created in
  82394. * @param onReady Define a callback to triggered once the texture will be ready
  82395. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  82396. */
  82397. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  82398. minWidth: number;
  82399. maxWidth: number;
  82400. minHeight: number;
  82401. maxHeight: number;
  82402. deviceId: string;
  82403. }): void;
  82404. }
  82405. }
  82406. declare module BABYLON {
  82407. /**
  82408. * Interface for attribute information associated with buffer instanciation
  82409. */
  82410. export class InstancingAttributeInfo {
  82411. /**
  82412. * Index/offset of the attribute in the vertex shader
  82413. */
  82414. index: number;
  82415. /**
  82416. * size of the attribute, 1, 2, 3 or 4
  82417. */
  82418. attributeSize: number;
  82419. /**
  82420. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  82421. * default is FLOAT
  82422. */
  82423. attribyteType: number;
  82424. /**
  82425. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  82426. */
  82427. normalized: boolean;
  82428. /**
  82429. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  82430. */
  82431. offset: number;
  82432. /**
  82433. * Name of the GLSL attribute, for debugging purpose only
  82434. */
  82435. attributeName: string;
  82436. }
  82437. /**
  82438. * Define options used to create a depth texture
  82439. */
  82440. export class DepthTextureCreationOptions {
  82441. /** Specifies whether or not a stencil should be allocated in the texture */
  82442. generateStencil?: boolean;
  82443. /** Specifies whether or not bilinear filtering is enable on the texture */
  82444. bilinearFiltering?: boolean;
  82445. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  82446. comparisonFunction?: number;
  82447. /** Specifies if the created texture is a cube texture */
  82448. isCube?: boolean;
  82449. }
  82450. /**
  82451. * Class used to describe the capabilities of the engine relatively to the current browser
  82452. */
  82453. export class EngineCapabilities {
  82454. /** Maximum textures units per fragment shader */
  82455. maxTexturesImageUnits: number;
  82456. /** Maximum texture units per vertex shader */
  82457. maxVertexTextureImageUnits: number;
  82458. /** Maximum textures units in the entire pipeline */
  82459. maxCombinedTexturesImageUnits: number;
  82460. /** Maximum texture size */
  82461. maxTextureSize: number;
  82462. /** Maximum cube texture size */
  82463. maxCubemapTextureSize: number;
  82464. /** Maximum render texture size */
  82465. maxRenderTextureSize: number;
  82466. /** Maximum number of vertex attributes */
  82467. maxVertexAttribs: number;
  82468. /** Maximum number of varyings */
  82469. maxVaryingVectors: number;
  82470. /** Maximum number of uniforms per vertex shader */
  82471. maxVertexUniformVectors: number;
  82472. /** Maximum number of uniforms per fragment shader */
  82473. maxFragmentUniformVectors: number;
  82474. /** Defines if standard derivates (dx/dy) are supported */
  82475. standardDerivatives: boolean;
  82476. /** Defines if s3tc texture compression is supported */
  82477. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  82478. /** Defines if pvrtc texture compression is supported */
  82479. pvrtc: any;
  82480. /** Defines if etc1 texture compression is supported */
  82481. etc1: any;
  82482. /** Defines if etc2 texture compression is supported */
  82483. etc2: any;
  82484. /** Defines if astc texture compression is supported */
  82485. astc: any;
  82486. /** Defines if float textures are supported */
  82487. textureFloat: boolean;
  82488. /** Defines if vertex array objects are supported */
  82489. vertexArrayObject: boolean;
  82490. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  82491. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  82492. /** Gets the maximum level of anisotropy supported */
  82493. maxAnisotropy: number;
  82494. /** Defines if instancing is supported */
  82495. instancedArrays: boolean;
  82496. /** Defines if 32 bits indices are supported */
  82497. uintIndices: boolean;
  82498. /** Defines if high precision shaders are supported */
  82499. highPrecisionShaderSupported: boolean;
  82500. /** Defines if depth reading in the fragment shader is supported */
  82501. fragmentDepthSupported: boolean;
  82502. /** Defines if float texture linear filtering is supported*/
  82503. textureFloatLinearFiltering: boolean;
  82504. /** Defines if rendering to float textures is supported */
  82505. textureFloatRender: boolean;
  82506. /** Defines if half float textures are supported*/
  82507. textureHalfFloat: boolean;
  82508. /** Defines if half float texture linear filtering is supported*/
  82509. textureHalfFloatLinearFiltering: boolean;
  82510. /** Defines if rendering to half float textures is supported */
  82511. textureHalfFloatRender: boolean;
  82512. /** Defines if textureLOD shader command is supported */
  82513. textureLOD: boolean;
  82514. /** Defines if draw buffers extension is supported */
  82515. drawBuffersExtension: boolean;
  82516. /** Defines if depth textures are supported */
  82517. depthTextureExtension: boolean;
  82518. /** Defines if float color buffer are supported */
  82519. colorBufferFloat: boolean;
  82520. /** Gets disjoint timer query extension (null if not supported) */
  82521. timerQuery: EXT_disjoint_timer_query;
  82522. /** Defines if timestamp can be used with timer query */
  82523. canUseTimestampForTimerQuery: boolean;
  82524. /** Function used to let the system compiles shaders in background */
  82525. parallelShaderCompile: {
  82526. MAX_SHADER_COMPILER_THREADS_KHR: number;
  82527. maxShaderCompilerThreadsKHR: (thread: number) => void;
  82528. COMPLETION_STATUS_KHR: number;
  82529. };
  82530. }
  82531. /** Interface defining initialization parameters for Engine class */
  82532. export interface EngineOptions extends WebGLContextAttributes {
  82533. /**
  82534. * Defines if the engine should no exceed a specified device ratio
  82535. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  82536. */
  82537. limitDeviceRatio?: number;
  82538. /**
  82539. * Defines if webvr should be enabled automatically
  82540. * @see http://doc.babylonjs.com/how_to/webvr_camera
  82541. */
  82542. autoEnableWebVR?: boolean;
  82543. /**
  82544. * Defines if webgl2 should be turned off even if supported
  82545. * @see http://doc.babylonjs.com/features/webgl2
  82546. */
  82547. disableWebGL2Support?: boolean;
  82548. /**
  82549. * Defines if webaudio should be initialized as well
  82550. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82551. */
  82552. audioEngine?: boolean;
  82553. /**
  82554. * Defines if animations should run using a deterministic lock step
  82555. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  82556. */
  82557. deterministicLockstep?: boolean;
  82558. /** Defines the maximum steps to use with deterministic lock step mode */
  82559. lockstepMaxSteps?: number;
  82560. /**
  82561. * Defines that engine should ignore context lost events
  82562. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  82563. */
  82564. doNotHandleContextLost?: boolean;
  82565. /**
  82566. * Defines that engine should ignore modifying touch action attribute and style
  82567. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  82568. */
  82569. doNotHandleTouchAction?: boolean;
  82570. }
  82571. /**
  82572. * Defines the interface used by display changed events
  82573. */
  82574. export interface IDisplayChangedEventArgs {
  82575. /** Gets the vrDisplay object (if any) */
  82576. vrDisplay: Nullable<any>;
  82577. /** Gets a boolean indicating if webVR is supported */
  82578. vrSupported: boolean;
  82579. }
  82580. /**
  82581. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  82582. */
  82583. export class Engine {
  82584. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  82585. static ExceptionList: ({
  82586. key: string;
  82587. capture: string;
  82588. captureConstraint: number;
  82589. targets: string[];
  82590. } | {
  82591. key: string;
  82592. capture: null;
  82593. captureConstraint: null;
  82594. targets: string[];
  82595. })[];
  82596. /** Gets the list of created engines */
  82597. static readonly Instances: Engine[];
  82598. /**
  82599. * Gets the latest created engine
  82600. */
  82601. static readonly LastCreatedEngine: Nullable<Engine>;
  82602. /**
  82603. * Gets the latest created scene
  82604. */
  82605. static readonly LastCreatedScene: Nullable<Scene>;
  82606. /**
  82607. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  82608. * @param flag defines which part of the materials must be marked as dirty
  82609. * @param predicate defines a predicate used to filter which materials should be affected
  82610. */
  82611. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  82612. /**
  82613. * Hidden
  82614. */
  82615. static _TextureLoaders: IInternalTextureLoader[];
  82616. /** Defines that alpha blending is disabled */
  82617. static readonly ALPHA_DISABLE: number;
  82618. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  82619. static readonly ALPHA_ADD: number;
  82620. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  82621. static readonly ALPHA_COMBINE: number;
  82622. /** Defines that alpha blending to DEST - SRC * DEST */
  82623. static readonly ALPHA_SUBTRACT: number;
  82624. /** Defines that alpha blending to SRC * DEST */
  82625. static readonly ALPHA_MULTIPLY: number;
  82626. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  82627. static readonly ALPHA_MAXIMIZED: number;
  82628. /** Defines that alpha blending to SRC + DEST */
  82629. static readonly ALPHA_ONEONE: number;
  82630. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  82631. static readonly ALPHA_PREMULTIPLIED: number;
  82632. /**
  82633. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  82634. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  82635. */
  82636. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  82637. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  82638. static readonly ALPHA_INTERPOLATE: number;
  82639. /**
  82640. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  82641. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  82642. */
  82643. static readonly ALPHA_SCREENMODE: number;
  82644. /** Defines that the ressource is not delayed*/
  82645. static readonly DELAYLOADSTATE_NONE: number;
  82646. /** Defines that the ressource was successfully delay loaded */
  82647. static readonly DELAYLOADSTATE_LOADED: number;
  82648. /** Defines that the ressource is currently delay loading */
  82649. static readonly DELAYLOADSTATE_LOADING: number;
  82650. /** Defines that the ressource is delayed and has not started loading */
  82651. static readonly DELAYLOADSTATE_NOTLOADED: number;
  82652. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  82653. static readonly NEVER: number;
  82654. /** 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 */
  82655. static readonly ALWAYS: number;
  82656. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  82657. static readonly LESS: number;
  82658. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  82659. static readonly EQUAL: number;
  82660. /** 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 */
  82661. static readonly LEQUAL: number;
  82662. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  82663. static readonly GREATER: number;
  82664. /** 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 */
  82665. static readonly GEQUAL: number;
  82666. /** 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 */
  82667. static readonly NOTEQUAL: number;
  82668. /** Passed to stencilOperation to specify that stencil value must be kept */
  82669. static readonly KEEP: number;
  82670. /** Passed to stencilOperation to specify that stencil value must be replaced */
  82671. static readonly REPLACE: number;
  82672. /** Passed to stencilOperation to specify that stencil value must be incremented */
  82673. static readonly INCR: number;
  82674. /** Passed to stencilOperation to specify that stencil value must be decremented */
  82675. static readonly DECR: number;
  82676. /** Passed to stencilOperation to specify that stencil value must be inverted */
  82677. static readonly INVERT: number;
  82678. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  82679. static readonly INCR_WRAP: number;
  82680. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  82681. static readonly DECR_WRAP: number;
  82682. /** Texture is not repeating outside of 0..1 UVs */
  82683. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  82684. /** Texture is repeating outside of 0..1 UVs */
  82685. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  82686. /** Texture is repeating and mirrored */
  82687. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  82688. /** ALPHA */
  82689. static readonly TEXTUREFORMAT_ALPHA: number;
  82690. /** LUMINANCE */
  82691. static readonly TEXTUREFORMAT_LUMINANCE: number;
  82692. /** LUMINANCE_ALPHA */
  82693. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  82694. /** RGB */
  82695. static readonly TEXTUREFORMAT_RGB: number;
  82696. /** RGBA */
  82697. static readonly TEXTUREFORMAT_RGBA: number;
  82698. /** RED */
  82699. static readonly TEXTUREFORMAT_RED: number;
  82700. /** RED (2nd reference) */
  82701. static readonly TEXTUREFORMAT_R: number;
  82702. /** RG */
  82703. static readonly TEXTUREFORMAT_RG: number;
  82704. /** RED_INTEGER */
  82705. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  82706. /** RED_INTEGER (2nd reference) */
  82707. static readonly TEXTUREFORMAT_R_INTEGER: number;
  82708. /** RG_INTEGER */
  82709. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  82710. /** RGB_INTEGER */
  82711. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  82712. /** RGBA_INTEGER */
  82713. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  82714. /** UNSIGNED_BYTE */
  82715. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  82716. /** UNSIGNED_BYTE (2nd reference) */
  82717. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  82718. /** FLOAT */
  82719. static readonly TEXTURETYPE_FLOAT: number;
  82720. /** HALF_FLOAT */
  82721. static readonly TEXTURETYPE_HALF_FLOAT: number;
  82722. /** BYTE */
  82723. static readonly TEXTURETYPE_BYTE: number;
  82724. /** SHORT */
  82725. static readonly TEXTURETYPE_SHORT: number;
  82726. /** UNSIGNED_SHORT */
  82727. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  82728. /** INT */
  82729. static readonly TEXTURETYPE_INT: number;
  82730. /** UNSIGNED_INT */
  82731. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  82732. /** UNSIGNED_SHORT_4_4_4_4 */
  82733. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  82734. /** UNSIGNED_SHORT_5_5_5_1 */
  82735. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  82736. /** UNSIGNED_SHORT_5_6_5 */
  82737. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  82738. /** UNSIGNED_INT_2_10_10_10_REV */
  82739. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  82740. /** UNSIGNED_INT_24_8 */
  82741. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  82742. /** UNSIGNED_INT_10F_11F_11F_REV */
  82743. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  82744. /** UNSIGNED_INT_5_9_9_9_REV */
  82745. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  82746. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  82747. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  82748. /** nearest is mag = nearest and min = nearest and mip = linear */
  82749. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  82750. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82751. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  82752. /** Trilinear is mag = linear and min = linear and mip = linear */
  82753. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  82754. /** nearest is mag = nearest and min = nearest and mip = linear */
  82755. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  82756. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82757. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  82758. /** Trilinear is mag = linear and min = linear and mip = linear */
  82759. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  82760. /** mag = nearest and min = nearest and mip = nearest */
  82761. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  82762. /** mag = nearest and min = linear and mip = nearest */
  82763. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  82764. /** mag = nearest and min = linear and mip = linear */
  82765. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  82766. /** mag = nearest and min = linear and mip = none */
  82767. static readonly TEXTURE_NEAREST_LINEAR: number;
  82768. /** mag = nearest and min = nearest and mip = none */
  82769. static readonly TEXTURE_NEAREST_NEAREST: number;
  82770. /** mag = linear and min = nearest and mip = nearest */
  82771. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  82772. /** mag = linear and min = nearest and mip = linear */
  82773. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  82774. /** mag = linear and min = linear and mip = none */
  82775. static readonly TEXTURE_LINEAR_LINEAR: number;
  82776. /** mag = linear and min = nearest and mip = none */
  82777. static readonly TEXTURE_LINEAR_NEAREST: number;
  82778. /** Explicit coordinates mode */
  82779. static readonly TEXTURE_EXPLICIT_MODE: number;
  82780. /** Spherical coordinates mode */
  82781. static readonly TEXTURE_SPHERICAL_MODE: number;
  82782. /** Planar coordinates mode */
  82783. static readonly TEXTURE_PLANAR_MODE: number;
  82784. /** Cubic coordinates mode */
  82785. static readonly TEXTURE_CUBIC_MODE: number;
  82786. /** Projection coordinates mode */
  82787. static readonly TEXTURE_PROJECTION_MODE: number;
  82788. /** Skybox coordinates mode */
  82789. static readonly TEXTURE_SKYBOX_MODE: number;
  82790. /** Inverse Cubic coordinates mode */
  82791. static readonly TEXTURE_INVCUBIC_MODE: number;
  82792. /** Equirectangular coordinates mode */
  82793. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  82794. /** Equirectangular Fixed coordinates mode */
  82795. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  82796. /** Equirectangular Fixed Mirrored coordinates mode */
  82797. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82798. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  82799. static readonly SCALEMODE_FLOOR: number;
  82800. /** Defines that texture rescaling will look for the nearest power of 2 size */
  82801. static readonly SCALEMODE_NEAREST: number;
  82802. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  82803. static readonly SCALEMODE_CEILING: number;
  82804. /**
  82805. * Returns the current version of the framework
  82806. */
  82807. static readonly Version: string;
  82808. /**
  82809. * Returns a string describing the current engine
  82810. */
  82811. readonly description: string;
  82812. /**
  82813. * Gets or sets the epsilon value used by collision engine
  82814. */
  82815. static CollisionsEpsilon: number;
  82816. /**
  82817. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  82818. */
  82819. static ShadersRepository: string;
  82820. /**
  82821. * Method called to create the default loading screen.
  82822. * This can be overriden in your own app.
  82823. * @param canvas The rendering canvas element
  82824. * @returns The loading screen
  82825. */
  82826. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  82827. /**
  82828. * Method called to create the default rescale post process on each engine.
  82829. */
  82830. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  82831. /**
  82832. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  82833. */
  82834. forcePOTTextures: boolean;
  82835. /**
  82836. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  82837. */
  82838. isFullscreen: boolean;
  82839. /**
  82840. * Gets a boolean indicating if the pointer is currently locked
  82841. */
  82842. isPointerLock: boolean;
  82843. /**
  82844. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  82845. */
  82846. cullBackFaces: boolean;
  82847. /**
  82848. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  82849. */
  82850. renderEvenInBackground: boolean;
  82851. /**
  82852. * Gets or sets a boolean indicating that cache can be kept between frames
  82853. */
  82854. preventCacheWipeBetweenFrames: boolean;
  82855. /**
  82856. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  82857. **/
  82858. enableOfflineSupport: boolean;
  82859. /**
  82860. * 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)
  82861. **/
  82862. disableManifestCheck: boolean;
  82863. /**
  82864. * Gets the list of created scenes
  82865. */
  82866. scenes: Scene[];
  82867. /**
  82868. * Event raised when a new scene is created
  82869. */
  82870. onNewSceneAddedObservable: Observable<Scene>;
  82871. /**
  82872. * Gets the list of created postprocesses
  82873. */
  82874. postProcesses: PostProcess[];
  82875. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  82876. validateShaderPrograms: boolean;
  82877. /**
  82878. * Observable event triggered each time the rendering canvas is resized
  82879. */
  82880. onResizeObservable: Observable<Engine>;
  82881. /**
  82882. * Observable event triggered each time the canvas loses focus
  82883. */
  82884. onCanvasBlurObservable: Observable<Engine>;
  82885. /**
  82886. * Observable event triggered each time the canvas gains focus
  82887. */
  82888. onCanvasFocusObservable: Observable<Engine>;
  82889. /**
  82890. * Observable event triggered each time the canvas receives pointerout event
  82891. */
  82892. onCanvasPointerOutObservable: Observable<PointerEvent>;
  82893. /**
  82894. * Observable event triggered before each texture is initialized
  82895. */
  82896. onBeforeTextureInitObservable: Observable<Texture>;
  82897. private _vrDisplay;
  82898. private _vrSupported;
  82899. private _oldSize;
  82900. private _oldHardwareScaleFactor;
  82901. private _vrExclusivePointerMode;
  82902. private _webVRInitPromise;
  82903. /**
  82904. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  82905. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  82906. */
  82907. readonly isInVRExclusivePointerMode: boolean;
  82908. /**
  82909. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  82910. */
  82911. disableUniformBuffers: boolean;
  82912. /** @hidden */
  82913. _uniformBuffers: UniformBuffer[];
  82914. /**
  82915. * Gets a boolean indicating that the engine supports uniform buffers
  82916. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  82917. */
  82918. readonly supportsUniformBuffers: boolean;
  82919. /**
  82920. * Observable raised when the engine begins a new frame
  82921. */
  82922. onBeginFrameObservable: Observable<Engine>;
  82923. /**
  82924. * If set, will be used to request the next animation frame for the render loop
  82925. */
  82926. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  82927. /**
  82928. * Observable raised when the engine ends the current frame
  82929. */
  82930. onEndFrameObservable: Observable<Engine>;
  82931. /**
  82932. * Observable raised when the engine is about to compile a shader
  82933. */
  82934. onBeforeShaderCompilationObservable: Observable<Engine>;
  82935. /**
  82936. * Observable raised when the engine has jsut compiled a shader
  82937. */
  82938. onAfterShaderCompilationObservable: Observable<Engine>;
  82939. /** @hidden */
  82940. _gl: WebGLRenderingContext;
  82941. private _renderingCanvas;
  82942. private _windowIsBackground;
  82943. private _webGLVersion;
  82944. /**
  82945. * Gets a boolean indicating that only power of 2 textures are supported
  82946. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  82947. */
  82948. readonly needPOTTextures: boolean;
  82949. /** @hidden */
  82950. _badOS: boolean;
  82951. /** @hidden */
  82952. _badDesktopOS: boolean;
  82953. /**
  82954. * Gets or sets a value indicating if we want to disable texture binding optimization.
  82955. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  82956. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  82957. */
  82958. disableTextureBindingOptimization: boolean;
  82959. /**
  82960. * Gets the audio engine
  82961. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82962. * @ignorenaming
  82963. */
  82964. static audioEngine: IAudioEngine;
  82965. /**
  82966. * Default AudioEngine factory responsible of creating the Audio Engine.
  82967. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  82968. */
  82969. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  82970. /**
  82971. * Default offline support factory responsible of creating a tool used to store data locally.
  82972. * By default, this will create a Database object if the workload has been embedded.
  82973. */
  82974. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  82975. private _onFocus;
  82976. private _onBlur;
  82977. private _onCanvasPointerOut;
  82978. private _onCanvasBlur;
  82979. private _onCanvasFocus;
  82980. private _onFullscreenChange;
  82981. private _onPointerLockChange;
  82982. private _onVRDisplayPointerRestricted;
  82983. private _onVRDisplayPointerUnrestricted;
  82984. private _onVrDisplayConnect;
  82985. private _onVrDisplayDisconnect;
  82986. private _onVrDisplayPresentChange;
  82987. /**
  82988. * Observable signaled when VR display mode changes
  82989. */
  82990. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  82991. /**
  82992. * Observable signaled when VR request present is complete
  82993. */
  82994. onVRRequestPresentComplete: Observable<boolean>;
  82995. /**
  82996. * Observable signaled when VR request present starts
  82997. */
  82998. onVRRequestPresentStart: Observable<Engine>;
  82999. private _hardwareScalingLevel;
  83000. /** @hidden */
  83001. protected _caps: EngineCapabilities;
  83002. private _pointerLockRequested;
  83003. private _isStencilEnable;
  83004. private _colorWrite;
  83005. private _loadingScreen;
  83006. /** @hidden */
  83007. _drawCalls: PerfCounter;
  83008. /** @hidden */
  83009. _textureCollisions: PerfCounter;
  83010. private _glVersion;
  83011. private _glRenderer;
  83012. private _glVendor;
  83013. private _videoTextureSupported;
  83014. private _renderingQueueLaunched;
  83015. private _activeRenderLoops;
  83016. private _deterministicLockstep;
  83017. private _lockstepMaxSteps;
  83018. /**
  83019. * Observable signaled when a context lost event is raised
  83020. */
  83021. onContextLostObservable: Observable<Engine>;
  83022. /**
  83023. * Observable signaled when a context restored event is raised
  83024. */
  83025. onContextRestoredObservable: Observable<Engine>;
  83026. private _onContextLost;
  83027. private _onContextRestored;
  83028. private _contextWasLost;
  83029. private _doNotHandleContextLost;
  83030. /**
  83031. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  83032. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  83033. */
  83034. doNotHandleContextLost: boolean;
  83035. private _performanceMonitor;
  83036. private _fps;
  83037. private _deltaTime;
  83038. /**
  83039. * Turn this value on if you want to pause FPS computation when in background
  83040. */
  83041. disablePerformanceMonitorInBackground: boolean;
  83042. /**
  83043. * Gets the performance monitor attached to this engine
  83044. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  83045. */
  83046. readonly performanceMonitor: PerformanceMonitor;
  83047. /** @hidden */
  83048. protected _depthCullingState: _DepthCullingState;
  83049. /** @hidden */
  83050. protected _stencilState: _StencilState;
  83051. /** @hidden */
  83052. protected _alphaState: _AlphaState;
  83053. /** @hidden */
  83054. protected _alphaMode: number;
  83055. protected _internalTexturesCache: InternalTexture[];
  83056. /** @hidden */
  83057. protected _activeChannel: number;
  83058. private _currentTextureChannel;
  83059. /** @hidden */
  83060. protected _boundTexturesCache: {
  83061. [key: string]: Nullable<InternalTexture>;
  83062. };
  83063. /** @hidden */
  83064. protected _currentEffect: Nullable<Effect>;
  83065. /** @hidden */
  83066. protected _currentProgram: Nullable<WebGLProgram>;
  83067. private _compiledEffects;
  83068. private _vertexAttribArraysEnabled;
  83069. /** @hidden */
  83070. protected _cachedViewport: Nullable<Viewport>;
  83071. private _cachedVertexArrayObject;
  83072. /** @hidden */
  83073. protected _cachedVertexBuffers: any;
  83074. /** @hidden */
  83075. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  83076. /** @hidden */
  83077. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  83078. /** @hidden */
  83079. protected _currentRenderTarget: Nullable<InternalTexture>;
  83080. private _uintIndicesCurrentlySet;
  83081. private _currentBoundBuffer;
  83082. /** @hidden */
  83083. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  83084. private _currentBufferPointers;
  83085. private _currentInstanceLocations;
  83086. private _currentInstanceBuffers;
  83087. private _textureUnits;
  83088. private _firstBoundInternalTextureTracker;
  83089. private _lastBoundInternalTextureTracker;
  83090. private _workingCanvas;
  83091. private _workingContext;
  83092. private _rescalePostProcess;
  83093. private _dummyFramebuffer;
  83094. private _externalData;
  83095. private _bindedRenderFunction;
  83096. private _vaoRecordInProgress;
  83097. private _mustWipeVertexAttributes;
  83098. private _emptyTexture;
  83099. private _emptyCubeTexture;
  83100. private _emptyTexture3D;
  83101. /** @hidden */
  83102. _frameHandler: number;
  83103. private _nextFreeTextureSlots;
  83104. private _maxSimultaneousTextures;
  83105. private _activeRequests;
  83106. private _texturesSupported;
  83107. private _textureFormatInUse;
  83108. /**
  83109. * Gets the list of texture formats supported
  83110. */
  83111. readonly texturesSupported: Array<string>;
  83112. /**
  83113. * Gets the list of texture formats in use
  83114. */
  83115. readonly textureFormatInUse: Nullable<string>;
  83116. /**
  83117. * Gets the current viewport
  83118. */
  83119. readonly currentViewport: Nullable<Viewport>;
  83120. /**
  83121. * Gets the default empty texture
  83122. */
  83123. readonly emptyTexture: InternalTexture;
  83124. /**
  83125. * Gets the default empty 3D texture
  83126. */
  83127. readonly emptyTexture3D: InternalTexture;
  83128. /**
  83129. * Gets the default empty cube texture
  83130. */
  83131. readonly emptyCubeTexture: InternalTexture;
  83132. /**
  83133. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  83134. */
  83135. readonly premultipliedAlpha: boolean;
  83136. /**
  83137. * Creates a new engine
  83138. * @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
  83139. * @param antialias defines enable antialiasing (default: false)
  83140. * @param options defines further options to be sent to the getContext() function
  83141. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  83142. */
  83143. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  83144. private _disableTouchAction;
  83145. private _rebuildInternalTextures;
  83146. private _rebuildEffects;
  83147. /**
  83148. * Gets a boolean indicating if all created effects are ready
  83149. * @returns true if all effects are ready
  83150. */
  83151. areAllEffectsReady(): boolean;
  83152. private _rebuildBuffers;
  83153. private _initGLContext;
  83154. /**
  83155. * Gets version of the current webGL context
  83156. */
  83157. readonly webGLVersion: number;
  83158. /**
  83159. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  83160. */
  83161. readonly isStencilEnable: boolean;
  83162. private _prepareWorkingCanvas;
  83163. /**
  83164. * Reset the texture cache to empty state
  83165. */
  83166. resetTextureCache(): void;
  83167. /**
  83168. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  83169. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83170. * @returns true if engine is in deterministic lock step mode
  83171. */
  83172. isDeterministicLockStep(): boolean;
  83173. /**
  83174. * Gets the max steps when engine is running in deterministic lock step
  83175. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83176. * @returns the max steps
  83177. */
  83178. getLockstepMaxSteps(): number;
  83179. /**
  83180. * Gets an object containing information about the current webGL context
  83181. * @returns an object containing the vender, the renderer and the version of the current webGL context
  83182. */
  83183. getGlInfo(): {
  83184. vendor: string;
  83185. renderer: string;
  83186. version: string;
  83187. };
  83188. /**
  83189. * Gets current aspect ratio
  83190. * @param camera defines the camera to use to get the aspect ratio
  83191. * @param useScreen defines if screen size must be used (or the current render target if any)
  83192. * @returns a number defining the aspect ratio
  83193. */
  83194. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  83195. /**
  83196. * Gets current screen aspect ratio
  83197. * @returns a number defining the aspect ratio
  83198. */
  83199. getScreenAspectRatio(): number;
  83200. /**
  83201. * Gets the current render width
  83202. * @param useScreen defines if screen size must be used (or the current render target if any)
  83203. * @returns a number defining the current render width
  83204. */
  83205. getRenderWidth(useScreen?: boolean): number;
  83206. /**
  83207. * Gets the current render height
  83208. * @param useScreen defines if screen size must be used (or the current render target if any)
  83209. * @returns a number defining the current render height
  83210. */
  83211. getRenderHeight(useScreen?: boolean): number;
  83212. /**
  83213. * Gets the HTML canvas attached with the current webGL context
  83214. * @returns a HTML canvas
  83215. */
  83216. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  83217. /**
  83218. * Gets the client rect of the HTML canvas attached with the current webGL context
  83219. * @returns a client rectanglee
  83220. */
  83221. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  83222. /**
  83223. * Defines the hardware scaling level.
  83224. * By default the hardware scaling level is computed from the window device ratio.
  83225. * 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.
  83226. * @param level defines the level to use
  83227. */
  83228. setHardwareScalingLevel(level: number): void;
  83229. /**
  83230. * Gets the current hardware scaling level.
  83231. * By default the hardware scaling level is computed from the window device ratio.
  83232. * 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.
  83233. * @returns a number indicating the current hardware scaling level
  83234. */
  83235. getHardwareScalingLevel(): number;
  83236. /**
  83237. * Gets the list of loaded textures
  83238. * @returns an array containing all loaded textures
  83239. */
  83240. getLoadedTexturesCache(): InternalTexture[];
  83241. /**
  83242. * Gets the object containing all engine capabilities
  83243. * @returns the EngineCapabilities object
  83244. */
  83245. getCaps(): EngineCapabilities;
  83246. /**
  83247. * Gets the current depth function
  83248. * @returns a number defining the depth function
  83249. */
  83250. getDepthFunction(): Nullable<number>;
  83251. /**
  83252. * Sets the current depth function
  83253. * @param depthFunc defines the function to use
  83254. */
  83255. setDepthFunction(depthFunc: number): void;
  83256. /**
  83257. * Sets the current depth function to GREATER
  83258. */
  83259. setDepthFunctionToGreater(): void;
  83260. /**
  83261. * Sets the current depth function to GEQUAL
  83262. */
  83263. setDepthFunctionToGreaterOrEqual(): void;
  83264. /**
  83265. * Sets the current depth function to LESS
  83266. */
  83267. setDepthFunctionToLess(): void;
  83268. /**
  83269. * Sets the current depth function to LEQUAL
  83270. */
  83271. setDepthFunctionToLessOrEqual(): void;
  83272. /**
  83273. * Gets a boolean indicating if stencil buffer is enabled
  83274. * @returns the current stencil buffer state
  83275. */
  83276. getStencilBuffer(): boolean;
  83277. /**
  83278. * Enable or disable the stencil buffer
  83279. * @param enable defines if the stencil buffer must be enabled or disabled
  83280. */
  83281. setStencilBuffer(enable: boolean): void;
  83282. /**
  83283. * Gets the current stencil mask
  83284. * @returns a number defining the new stencil mask to use
  83285. */
  83286. getStencilMask(): number;
  83287. /**
  83288. * Sets the current stencil mask
  83289. * @param mask defines the new stencil mask to use
  83290. */
  83291. setStencilMask(mask: number): void;
  83292. /**
  83293. * Gets the current stencil function
  83294. * @returns a number defining the stencil function to use
  83295. */
  83296. getStencilFunction(): number;
  83297. /**
  83298. * Gets the current stencil reference value
  83299. * @returns a number defining the stencil reference value to use
  83300. */
  83301. getStencilFunctionReference(): number;
  83302. /**
  83303. * Gets the current stencil mask
  83304. * @returns a number defining the stencil mask to use
  83305. */
  83306. getStencilFunctionMask(): number;
  83307. /**
  83308. * Sets the current stencil function
  83309. * @param stencilFunc defines the new stencil function to use
  83310. */
  83311. setStencilFunction(stencilFunc: number): void;
  83312. /**
  83313. * Sets the current stencil reference
  83314. * @param reference defines the new stencil reference to use
  83315. */
  83316. setStencilFunctionReference(reference: number): void;
  83317. /**
  83318. * Sets the current stencil mask
  83319. * @param mask defines the new stencil mask to use
  83320. */
  83321. setStencilFunctionMask(mask: number): void;
  83322. /**
  83323. * Gets the current stencil operation when stencil fails
  83324. * @returns a number defining stencil operation to use when stencil fails
  83325. */
  83326. getStencilOperationFail(): number;
  83327. /**
  83328. * Gets the current stencil operation when depth fails
  83329. * @returns a number defining stencil operation to use when depth fails
  83330. */
  83331. getStencilOperationDepthFail(): number;
  83332. /**
  83333. * Gets the current stencil operation when stencil passes
  83334. * @returns a number defining stencil operation to use when stencil passes
  83335. */
  83336. getStencilOperationPass(): number;
  83337. /**
  83338. * Sets the stencil operation to use when stencil fails
  83339. * @param operation defines the stencil operation to use when stencil fails
  83340. */
  83341. setStencilOperationFail(operation: number): void;
  83342. /**
  83343. * Sets the stencil operation to use when depth fails
  83344. * @param operation defines the stencil operation to use when depth fails
  83345. */
  83346. setStencilOperationDepthFail(operation: number): void;
  83347. /**
  83348. * Sets the stencil operation to use when stencil passes
  83349. * @param operation defines the stencil operation to use when stencil passes
  83350. */
  83351. setStencilOperationPass(operation: number): void;
  83352. /**
  83353. * Sets a boolean indicating if the dithering state is enabled or disabled
  83354. * @param value defines the dithering state
  83355. */
  83356. setDitheringState(value: boolean): void;
  83357. /**
  83358. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  83359. * @param value defines the rasterizer state
  83360. */
  83361. setRasterizerState(value: boolean): void;
  83362. /**
  83363. * stop executing a render loop function and remove it from the execution array
  83364. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  83365. */
  83366. stopRenderLoop(renderFunction?: () => void): void;
  83367. /** @hidden */
  83368. _renderLoop(): void;
  83369. /**
  83370. * Register and execute a render loop. The engine can have more than one render function
  83371. * @param renderFunction defines the function to continuously execute
  83372. */
  83373. runRenderLoop(renderFunction: () => void): void;
  83374. /**
  83375. * Toggle full screen mode
  83376. * @param requestPointerLock defines if a pointer lock should be requested from the user
  83377. */
  83378. switchFullscreen(requestPointerLock: boolean): void;
  83379. /**
  83380. * Clear the current render buffer or the current render target (if any is set up)
  83381. * @param color defines the color to use
  83382. * @param backBuffer defines if the back buffer must be cleared
  83383. * @param depth defines if the depth buffer must be cleared
  83384. * @param stencil defines if the stencil buffer must be cleared
  83385. */
  83386. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  83387. /**
  83388. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  83389. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  83390. * @param y defines the y-coordinate of the corner of the clear rectangle
  83391. * @param width defines the width of the clear rectangle
  83392. * @param height defines the height of the clear rectangle
  83393. * @param clearColor defines the clear color
  83394. */
  83395. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  83396. /**
  83397. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  83398. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  83399. * @param y defines the y-coordinate of the corner of the clear rectangle
  83400. * @param width defines the width of the clear rectangle
  83401. * @param height defines the height of the clear rectangle
  83402. */
  83403. enableScissor(x: number, y: number, width: number, height: number): void;
  83404. /**
  83405. * Disable previously set scissor test rectangle
  83406. */
  83407. disableScissor(): void;
  83408. private _viewportCached;
  83409. /** @hidden */
  83410. _viewport(x: number, y: number, width: number, height: number): void;
  83411. /**
  83412. * Set the WebGL's viewport
  83413. * @param viewport defines the viewport element to be used
  83414. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  83415. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  83416. */
  83417. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  83418. /**
  83419. * Directly set the WebGL Viewport
  83420. * @param x defines the x coordinate of the viewport (in screen space)
  83421. * @param y defines the y coordinate of the viewport (in screen space)
  83422. * @param width defines the width of the viewport (in screen space)
  83423. * @param height defines the height of the viewport (in screen space)
  83424. * @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
  83425. */
  83426. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  83427. /**
  83428. * Begin a new frame
  83429. */
  83430. beginFrame(): void;
  83431. /**
  83432. * Enf the current frame
  83433. */
  83434. endFrame(): void;
  83435. /**
  83436. * Resize the view according to the canvas' size
  83437. */
  83438. resize(): void;
  83439. /**
  83440. * Force a specific size of the canvas
  83441. * @param width defines the new canvas' width
  83442. * @param height defines the new canvas' height
  83443. */
  83444. setSize(width: number, height: number): void;
  83445. /**
  83446. * Gets a boolean indicating if a webVR device was detected
  83447. * @returns true if a webVR device was detected
  83448. */
  83449. isVRDevicePresent(): boolean;
  83450. /**
  83451. * Gets the current webVR device
  83452. * @returns the current webVR device (or null)
  83453. */
  83454. getVRDevice(): any;
  83455. /**
  83456. * Initializes a webVR display and starts listening to display change events
  83457. * The onVRDisplayChangedObservable will be notified upon these changes
  83458. * @returns The onVRDisplayChangedObservable
  83459. */
  83460. initWebVR(): Observable<IDisplayChangedEventArgs>;
  83461. /**
  83462. * Initializes a webVR display and starts listening to display change events
  83463. * The onVRDisplayChangedObservable will be notified upon these changes
  83464. * @returns A promise containing a VRDisplay and if vr is supported
  83465. */
  83466. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  83467. /**
  83468. * Call this function to switch to webVR mode
  83469. * Will do nothing if webVR is not supported or if there is no webVR device
  83470. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83471. */
  83472. enableVR(): void;
  83473. /**
  83474. * Call this function to leave webVR mode
  83475. * Will do nothing if webVR is not supported or if there is no webVR device
  83476. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83477. */
  83478. disableVR(): void;
  83479. private _onVRFullScreenTriggered;
  83480. private _getVRDisplaysAsync;
  83481. /**
  83482. * Binds the frame buffer to the specified texture.
  83483. * @param texture The texture to render to or null for the default canvas
  83484. * @param faceIndex The face of the texture to render to in case of cube texture
  83485. * @param requiredWidth The width of the target to render to
  83486. * @param requiredHeight The height of the target to render to
  83487. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  83488. * @param depthStencilTexture The depth stencil texture to use to render
  83489. * @param lodLevel defines le lod level to bind to the frame buffer
  83490. */
  83491. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  83492. private bindUnboundFramebuffer;
  83493. /**
  83494. * Unbind the current render target texture from the webGL context
  83495. * @param texture defines the render target texture to unbind
  83496. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  83497. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  83498. */
  83499. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  83500. /**
  83501. * Unbind a list of render target textures from the webGL context
  83502. * This is used only when drawBuffer extension or webGL2 are active
  83503. * @param textures defines the render target textures to unbind
  83504. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  83505. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  83506. */
  83507. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  83508. /**
  83509. * Force the mipmap generation for the given render target texture
  83510. * @param texture defines the render target texture to use
  83511. */
  83512. generateMipMapsForCubemap(texture: InternalTexture): void;
  83513. /**
  83514. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  83515. */
  83516. flushFramebuffer(): void;
  83517. /**
  83518. * Unbind the current render target and bind the default framebuffer
  83519. */
  83520. restoreDefaultFramebuffer(): void;
  83521. /**
  83522. * Create an uniform buffer
  83523. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83524. * @param elements defines the content of the uniform buffer
  83525. * @returns the webGL uniform buffer
  83526. */
  83527. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  83528. /**
  83529. * Create a dynamic uniform buffer
  83530. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83531. * @param elements defines the content of the uniform buffer
  83532. * @returns the webGL uniform buffer
  83533. */
  83534. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  83535. /**
  83536. * Update an existing uniform buffer
  83537. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83538. * @param uniformBuffer defines the target uniform buffer
  83539. * @param elements defines the content to update
  83540. * @param offset defines the offset in the uniform buffer where update should start
  83541. * @param count defines the size of the data to update
  83542. */
  83543. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  83544. private _resetVertexBufferBinding;
  83545. /**
  83546. * Creates a vertex buffer
  83547. * @param data the data for the vertex buffer
  83548. * @returns the new WebGL static buffer
  83549. */
  83550. createVertexBuffer(data: DataArray): WebGLBuffer;
  83551. /**
  83552. * Creates a dynamic vertex buffer
  83553. * @param data the data for the dynamic vertex buffer
  83554. * @returns the new WebGL dynamic buffer
  83555. */
  83556. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  83557. /**
  83558. * Update a dynamic index buffer
  83559. * @param indexBuffer defines the target index buffer
  83560. * @param indices defines the data to update
  83561. * @param offset defines the offset in the target index buffer where update should start
  83562. */
  83563. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  83564. /**
  83565. * Updates a dynamic vertex buffer.
  83566. * @param vertexBuffer the vertex buffer to update
  83567. * @param data the data used to update the vertex buffer
  83568. * @param byteOffset the byte offset of the data
  83569. * @param byteLength the byte length of the data
  83570. */
  83571. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  83572. private _resetIndexBufferBinding;
  83573. /**
  83574. * Creates a new index buffer
  83575. * @param indices defines the content of the index buffer
  83576. * @param updatable defines if the index buffer must be updatable
  83577. * @returns a new webGL buffer
  83578. */
  83579. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  83580. /**
  83581. * Bind a webGL buffer to the webGL context
  83582. * @param buffer defines the buffer to bind
  83583. */
  83584. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  83585. /**
  83586. * Bind an uniform buffer to the current webGL context
  83587. * @param buffer defines the buffer to bind
  83588. */
  83589. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  83590. /**
  83591. * Bind a buffer to the current webGL context at a given location
  83592. * @param buffer defines the buffer to bind
  83593. * @param location defines the index where to bind the buffer
  83594. */
  83595. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  83596. /**
  83597. * Bind a specific block at a given index in a specific shader program
  83598. * @param shaderProgram defines the shader program
  83599. * @param blockName defines the block name
  83600. * @param index defines the index where to bind the block
  83601. */
  83602. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  83603. private bindIndexBuffer;
  83604. private bindBuffer;
  83605. /**
  83606. * update the bound buffer with the given data
  83607. * @param data defines the data to update
  83608. */
  83609. updateArrayBuffer(data: Float32Array): void;
  83610. private _vertexAttribPointer;
  83611. private _bindIndexBufferWithCache;
  83612. private _bindVertexBuffersAttributes;
  83613. /**
  83614. * Records a vertex array object
  83615. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  83616. * @param vertexBuffers defines the list of vertex buffers to store
  83617. * @param indexBuffer defines the index buffer to store
  83618. * @param effect defines the effect to store
  83619. * @returns the new vertex array object
  83620. */
  83621. recordVertexArrayObject(vertexBuffers: {
  83622. [key: string]: VertexBuffer;
  83623. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  83624. /**
  83625. * Bind a specific vertex array object
  83626. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  83627. * @param vertexArrayObject defines the vertex array object to bind
  83628. * @param indexBuffer defines the index buffer to bind
  83629. */
  83630. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  83631. /**
  83632. * Bind webGl buffers directly to the webGL context
  83633. * @param vertexBuffer defines the vertex buffer to bind
  83634. * @param indexBuffer defines the index buffer to bind
  83635. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  83636. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  83637. * @param effect defines the effect associated with the vertex buffer
  83638. */
  83639. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  83640. private _unbindVertexArrayObject;
  83641. /**
  83642. * Bind a list of vertex buffers to the webGL context
  83643. * @param vertexBuffers defines the list of vertex buffers to bind
  83644. * @param indexBuffer defines the index buffer to bind
  83645. * @param effect defines the effect associated with the vertex buffers
  83646. */
  83647. bindBuffers(vertexBuffers: {
  83648. [key: string]: Nullable<VertexBuffer>;
  83649. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  83650. /**
  83651. * Unbind all instance attributes
  83652. */
  83653. unbindInstanceAttributes(): void;
  83654. /**
  83655. * Release and free the memory of a vertex array object
  83656. * @param vao defines the vertex array object to delete
  83657. */
  83658. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  83659. /** @hidden */
  83660. _releaseBuffer(buffer: WebGLBuffer): boolean;
  83661. /**
  83662. * Creates a webGL buffer to use with instanciation
  83663. * @param capacity defines the size of the buffer
  83664. * @returns the webGL buffer
  83665. */
  83666. createInstancesBuffer(capacity: number): WebGLBuffer;
  83667. /**
  83668. * Delete a webGL buffer used with instanciation
  83669. * @param buffer defines the webGL buffer to delete
  83670. */
  83671. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  83672. /**
  83673. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  83674. * @param instancesBuffer defines the webGL buffer to update and bind
  83675. * @param data defines the data to store in the buffer
  83676. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  83677. */
  83678. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  83679. /**
  83680. * Apply all cached states (depth, culling, stencil and alpha)
  83681. */
  83682. applyStates(): void;
  83683. /**
  83684. * Send a draw order
  83685. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  83686. * @param indexStart defines the starting index
  83687. * @param indexCount defines the number of index to draw
  83688. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83689. */
  83690. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  83691. /**
  83692. * Draw a list of points
  83693. * @param verticesStart defines the index of first vertex to draw
  83694. * @param verticesCount defines the count of vertices to draw
  83695. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83696. */
  83697. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  83698. /**
  83699. * Draw a list of unindexed primitives
  83700. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  83701. * @param verticesStart defines the index of first vertex to draw
  83702. * @param verticesCount defines the count of vertices to draw
  83703. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83704. */
  83705. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  83706. /**
  83707. * Draw a list of indexed primitives
  83708. * @param fillMode defines the primitive to use
  83709. * @param indexStart defines the starting index
  83710. * @param indexCount defines the number of index to draw
  83711. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83712. */
  83713. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  83714. /**
  83715. * Draw a list of unindexed primitives
  83716. * @param fillMode defines the primitive to use
  83717. * @param verticesStart defines the index of first vertex to draw
  83718. * @param verticesCount defines the count of vertices to draw
  83719. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83720. */
  83721. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  83722. private _drawMode;
  83723. /** @hidden */
  83724. _releaseEffect(effect: Effect): void;
  83725. /** @hidden */
  83726. _deleteProgram(program: WebGLProgram): void;
  83727. /**
  83728. * Create a new effect (used to store vertex/fragment shaders)
  83729. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  83730. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  83731. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  83732. * @param samplers defines an array of string used to represent textures
  83733. * @param defines defines the string containing the defines to use to compile the shaders
  83734. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  83735. * @param onCompiled defines a function to call when the effect creation is successful
  83736. * @param onError defines a function to call when the effect creation has failed
  83737. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  83738. * @returns the new Effect
  83739. */
  83740. 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;
  83741. private _compileShader;
  83742. private _compileRawShader;
  83743. /**
  83744. * Directly creates a webGL program
  83745. * @param vertexCode defines the vertex shader code to use
  83746. * @param fragmentCode defines the fragment shader code to use
  83747. * @param context defines the webGL context to use (if not set, the current one will be used)
  83748. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  83749. * @returns the new webGL program
  83750. */
  83751. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  83752. /**
  83753. * Creates a webGL program
  83754. * @param vertexCode defines the vertex shader code to use
  83755. * @param fragmentCode defines the fragment shader code to use
  83756. * @param defines defines the string containing the defines to use to compile the shaders
  83757. * @param context defines the webGL context to use (if not set, the current one will be used)
  83758. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  83759. * @returns the new webGL program
  83760. */
  83761. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  83762. private _createShaderProgram;
  83763. private _finalizeProgram;
  83764. /** @hidden */
  83765. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  83766. /** @hidden */
  83767. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  83768. /**
  83769. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  83770. * @param shaderProgram defines the webGL program to use
  83771. * @param uniformsNames defines the list of uniform names
  83772. * @returns an array of webGL uniform locations
  83773. */
  83774. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  83775. /**
  83776. * Gets the lsit of active attributes for a given webGL program
  83777. * @param shaderProgram defines the webGL program to use
  83778. * @param attributesNames defines the list of attribute names to get
  83779. * @returns an array of indices indicating the offset of each attribute
  83780. */
  83781. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  83782. /**
  83783. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  83784. * @param effect defines the effect to activate
  83785. */
  83786. enableEffect(effect: Nullable<Effect>): void;
  83787. /**
  83788. * Set the value of an uniform to an array of int32
  83789. * @param uniform defines the webGL uniform location where to store the value
  83790. * @param array defines the array of int32 to store
  83791. */
  83792. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83793. /**
  83794. * Set the value of an uniform to an array of int32 (stored as vec2)
  83795. * @param uniform defines the webGL uniform location where to store the value
  83796. * @param array defines the array of int32 to store
  83797. */
  83798. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83799. /**
  83800. * Set the value of an uniform to an array of int32 (stored as vec3)
  83801. * @param uniform defines the webGL uniform location where to store the value
  83802. * @param array defines the array of int32 to store
  83803. */
  83804. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83805. /**
  83806. * Set the value of an uniform to an array of int32 (stored as vec4)
  83807. * @param uniform defines the webGL uniform location where to store the value
  83808. * @param array defines the array of int32 to store
  83809. */
  83810. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83811. /**
  83812. * Set the value of an uniform to an array of float32
  83813. * @param uniform defines the webGL uniform location where to store the value
  83814. * @param array defines the array of float32 to store
  83815. */
  83816. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83817. /**
  83818. * Set the value of an uniform to an array of float32 (stored as vec2)
  83819. * @param uniform defines the webGL uniform location where to store the value
  83820. * @param array defines the array of float32 to store
  83821. */
  83822. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83823. /**
  83824. * Set the value of an uniform to an array of float32 (stored as vec3)
  83825. * @param uniform defines the webGL uniform location where to store the value
  83826. * @param array defines the array of float32 to store
  83827. */
  83828. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83829. /**
  83830. * Set the value of an uniform to an array of float32 (stored as vec4)
  83831. * @param uniform defines the webGL uniform location where to store the value
  83832. * @param array defines the array of float32 to store
  83833. */
  83834. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83835. /**
  83836. * Set the value of an uniform to an array of number
  83837. * @param uniform defines the webGL uniform location where to store the value
  83838. * @param array defines the array of number to store
  83839. */
  83840. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83841. /**
  83842. * Set the value of an uniform to an array of number (stored as vec2)
  83843. * @param uniform defines the webGL uniform location where to store the value
  83844. * @param array defines the array of number to store
  83845. */
  83846. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83847. /**
  83848. * Set the value of an uniform to an array of number (stored as vec3)
  83849. * @param uniform defines the webGL uniform location where to store the value
  83850. * @param array defines the array of number to store
  83851. */
  83852. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83853. /**
  83854. * Set the value of an uniform to an array of number (stored as vec4)
  83855. * @param uniform defines the webGL uniform location where to store the value
  83856. * @param array defines the array of number to store
  83857. */
  83858. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83859. /**
  83860. * Set the value of an uniform to an array of float32 (stored as matrices)
  83861. * @param uniform defines the webGL uniform location where to store the value
  83862. * @param matrices defines the array of float32 to store
  83863. */
  83864. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  83865. /**
  83866. * Set the value of an uniform to a matrix
  83867. * @param uniform defines the webGL uniform location where to store the value
  83868. * @param matrix defines the matrix to store
  83869. */
  83870. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  83871. /**
  83872. * Set the value of an uniform to a matrix (3x3)
  83873. * @param uniform defines the webGL uniform location where to store the value
  83874. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  83875. */
  83876. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  83877. /**
  83878. * Set the value of an uniform to a matrix (2x2)
  83879. * @param uniform defines the webGL uniform location where to store the value
  83880. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  83881. */
  83882. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  83883. /**
  83884. * Set the value of an uniform to a number (int)
  83885. * @param uniform defines the webGL uniform location where to store the value
  83886. * @param value defines the int number to store
  83887. */
  83888. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  83889. /**
  83890. * Set the value of an uniform to a number (float)
  83891. * @param uniform defines the webGL uniform location where to store the value
  83892. * @param value defines the float number to store
  83893. */
  83894. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  83895. /**
  83896. * Set the value of an uniform to a vec2
  83897. * @param uniform defines the webGL uniform location where to store the value
  83898. * @param x defines the 1st component of the value
  83899. * @param y defines the 2nd component of the value
  83900. */
  83901. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  83902. /**
  83903. * Set the value of an uniform to a vec3
  83904. * @param uniform defines the webGL uniform location where to store the value
  83905. * @param x defines the 1st component of the value
  83906. * @param y defines the 2nd component of the value
  83907. * @param z defines the 3rd component of the value
  83908. */
  83909. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  83910. /**
  83911. * Set the value of an uniform to a boolean
  83912. * @param uniform defines the webGL uniform location where to store the value
  83913. * @param bool defines the boolean to store
  83914. */
  83915. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  83916. /**
  83917. * Set the value of an uniform to a vec4
  83918. * @param uniform defines the webGL uniform location where to store the value
  83919. * @param x defines the 1st component of the value
  83920. * @param y defines the 2nd component of the value
  83921. * @param z defines the 3rd component of the value
  83922. * @param w defines the 4th component of the value
  83923. */
  83924. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  83925. /**
  83926. * Set the value of an uniform to a Color3
  83927. * @param uniform defines the webGL uniform location where to store the value
  83928. * @param color3 defines the color to store
  83929. */
  83930. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  83931. /**
  83932. * Set the value of an uniform to a Color3 and an alpha value
  83933. * @param uniform defines the webGL uniform location where to store the value
  83934. * @param color3 defines the color to store
  83935. * @param alpha defines the alpha component to store
  83936. */
  83937. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  83938. /**
  83939. * Sets a Color4 on a uniform variable
  83940. * @param uniform defines the uniform location
  83941. * @param color4 defines the value to be set
  83942. */
  83943. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  83944. /**
  83945. * Set various states to the webGL context
  83946. * @param culling defines backface culling state
  83947. * @param zOffset defines the value to apply to zOffset (0 by default)
  83948. * @param force defines if states must be applied even if cache is up to date
  83949. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  83950. */
  83951. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  83952. /**
  83953. * Set the z offset to apply to current rendering
  83954. * @param value defines the offset to apply
  83955. */
  83956. setZOffset(value: number): void;
  83957. /**
  83958. * Gets the current value of the zOffset
  83959. * @returns the current zOffset state
  83960. */
  83961. getZOffset(): number;
  83962. /**
  83963. * Enable or disable depth buffering
  83964. * @param enable defines the state to set
  83965. */
  83966. setDepthBuffer(enable: boolean): void;
  83967. /**
  83968. * Gets a boolean indicating if depth writing is enabled
  83969. * @returns the current depth writing state
  83970. */
  83971. getDepthWrite(): boolean;
  83972. /**
  83973. * Enable or disable depth writing
  83974. * @param enable defines the state to set
  83975. */
  83976. setDepthWrite(enable: boolean): void;
  83977. /**
  83978. * Enable or disable color writing
  83979. * @param enable defines the state to set
  83980. */
  83981. setColorWrite(enable: boolean): void;
  83982. /**
  83983. * Gets a boolean indicating if color writing is enabled
  83984. * @returns the current color writing state
  83985. */
  83986. getColorWrite(): boolean;
  83987. /**
  83988. * Sets alpha constants used by some alpha blending modes
  83989. * @param r defines the red component
  83990. * @param g defines the green component
  83991. * @param b defines the blue component
  83992. * @param a defines the alpha component
  83993. */
  83994. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  83995. /**
  83996. * Sets the current alpha mode
  83997. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  83998. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  83999. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  84000. */
  84001. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  84002. /**
  84003. * Gets the current alpha mode
  84004. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  84005. * @returns the current alpha mode
  84006. */
  84007. getAlphaMode(): number;
  84008. /**
  84009. * Clears the list of texture accessible through engine.
  84010. * This can help preventing texture load conflict due to name collision.
  84011. */
  84012. clearInternalTexturesCache(): void;
  84013. /**
  84014. * Force the entire cache to be cleared
  84015. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  84016. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  84017. */
  84018. wipeCaches(bruteForce?: boolean): void;
  84019. /**
  84020. * Set the compressed texture format to use, based on the formats you have, and the formats
  84021. * supported by the hardware / browser.
  84022. *
  84023. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  84024. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  84025. * to API arguments needed to compressed textures. This puts the burden on the container
  84026. * generator to house the arcane code for determining these for current & future formats.
  84027. *
  84028. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  84029. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  84030. *
  84031. * Note: The result of this call is not taken into account when a texture is base64.
  84032. *
  84033. * @param formatsAvailable defines the list of those format families you have created
  84034. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  84035. *
  84036. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  84037. * @returns The extension selected.
  84038. */
  84039. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  84040. private _getSamplingParameters;
  84041. private _partialLoadImg;
  84042. private _cascadeLoadImgs;
  84043. /** @hidden */
  84044. _createTexture(): WebGLTexture;
  84045. /**
  84046. * Usually called from Texture.ts.
  84047. * Passed information to create a WebGLTexture
  84048. * @param urlArg defines a value which contains one of the following:
  84049. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  84050. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  84051. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  84052. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  84053. * @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)
  84054. * @param scene needed for loading to the correct scene
  84055. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  84056. * @param onLoad optional callback to be called upon successful completion
  84057. * @param onError optional callback to be called upon failure
  84058. * @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
  84059. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  84060. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  84061. * @param forcedExtension defines the extension to use to pick the right loader
  84062. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  84063. * @returns a InternalTexture for assignment back into BABYLON.Texture
  84064. */
  84065. 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;
  84066. private _rescaleTexture;
  84067. /**
  84068. * Update a raw texture
  84069. * @param texture defines the texture to update
  84070. * @param data defines the data to store in the texture
  84071. * @param format defines the format of the data
  84072. * @param invertY defines if data must be stored with Y axis inverted
  84073. * @param compression defines the compression used (null by default)
  84074. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84075. */
  84076. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  84077. /**
  84078. * Creates a raw texture
  84079. * @param data defines the data to store in the texture
  84080. * @param width defines the width of the texture
  84081. * @param height defines the height of the texture
  84082. * @param format defines the format of the data
  84083. * @param generateMipMaps defines if the engine should generate the mip levels
  84084. * @param invertY defines if data must be stored with Y axis inverted
  84085. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84086. * @param compression defines the compression used (null by default)
  84087. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84088. * @returns the raw texture inside an InternalTexture
  84089. */
  84090. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  84091. private _unpackFlipYCached;
  84092. /**
  84093. * In case you are sharing the context with other applications, it might
  84094. * be interested to not cache the unpack flip y state to ensure a consistent
  84095. * value would be set.
  84096. */
  84097. enableUnpackFlipYCached: boolean;
  84098. /** @hidden */
  84099. _unpackFlipY(value: boolean): void;
  84100. /** @hidden */
  84101. _getUnpackAlignement(): number;
  84102. /**
  84103. * Creates a dynamic texture
  84104. * @param width defines the width of the texture
  84105. * @param height defines the height of the texture
  84106. * @param generateMipMaps defines if the engine should generate the mip levels
  84107. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84108. * @returns the dynamic texture inside an InternalTexture
  84109. */
  84110. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84111. /**
  84112. * Update the sampling mode of a given texture
  84113. * @param samplingMode defines the required sampling mode
  84114. * @param texture defines the texture to update
  84115. */
  84116. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  84117. /**
  84118. * Update the content of a dynamic texture
  84119. * @param texture defines the texture to update
  84120. * @param canvas defines the canvas containing the source
  84121. * @param invertY defines if data must be stored with Y axis inverted
  84122. * @param premulAlpha defines if alpha is stored as premultiplied
  84123. * @param format defines the format of the data
  84124. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84125. */
  84126. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84127. /**
  84128. * Update a video texture
  84129. * @param texture defines the texture to update
  84130. * @param video defines the video element to use
  84131. * @param invertY defines if data must be stored with Y axis inverted
  84132. */
  84133. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  84134. /**
  84135. * Updates a depth texture Comparison Mode and Function.
  84136. * If the comparison Function is equal to 0, the mode will be set to none.
  84137. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  84138. * @param texture The texture to set the comparison function for
  84139. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  84140. */
  84141. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  84142. private _setupDepthStencilTexture;
  84143. /**
  84144. * Creates a depth stencil texture.
  84145. * This is only available in WebGL 2 or with the depth texture extension available.
  84146. * @param size The size of face edge in the texture.
  84147. * @param options The options defining the texture.
  84148. * @returns The texture
  84149. */
  84150. createDepthStencilTexture(size: number | {
  84151. width: number;
  84152. height: number;
  84153. }, options: DepthTextureCreationOptions): InternalTexture;
  84154. /**
  84155. * Creates a depth stencil texture.
  84156. * This is only available in WebGL 2 or with the depth texture extension available.
  84157. * @param size The size of face edge in the texture.
  84158. * @param options The options defining the texture.
  84159. * @returns The texture
  84160. */
  84161. private _createDepthStencilTexture;
  84162. /**
  84163. * Creates a depth stencil cube texture.
  84164. * This is only available in WebGL 2.
  84165. * @param size The size of face edge in the cube texture.
  84166. * @param options The options defining the cube texture.
  84167. * @returns The cube texture
  84168. */
  84169. private _createDepthStencilCubeTexture;
  84170. /**
  84171. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  84172. * @param renderTarget The render target to set the frame buffer for
  84173. */
  84174. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  84175. /**
  84176. * Creates a new render target texture
  84177. * @param size defines the size of the texture
  84178. * @param options defines the options used to create the texture
  84179. * @returns a new render target texture stored in an InternalTexture
  84180. */
  84181. createRenderTargetTexture(size: number | {
  84182. width: number;
  84183. height: number;
  84184. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  84185. /**
  84186. * Create a multi render target texture
  84187. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  84188. * @param size defines the size of the texture
  84189. * @param options defines the creation options
  84190. * @returns the cube texture as an InternalTexture
  84191. */
  84192. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  84193. private _setupFramebufferDepthAttachments;
  84194. /**
  84195. * Updates the sample count of a render target texture
  84196. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  84197. * @param texture defines the texture to update
  84198. * @param samples defines the sample count to set
  84199. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  84200. */
  84201. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  84202. /**
  84203. * Update the sample count for a given multiple render target texture
  84204. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  84205. * @param textures defines the textures to update
  84206. * @param samples defines the sample count to set
  84207. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  84208. */
  84209. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  84210. /** @hidden */
  84211. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84212. /** @hidden */
  84213. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84214. /** @hidden */
  84215. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84216. /** @hidden */
  84217. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  84218. /**
  84219. * Creates a new render target cube texture
  84220. * @param size defines the size of the texture
  84221. * @param options defines the options used to create the texture
  84222. * @returns a new render target cube texture stored in an InternalTexture
  84223. */
  84224. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84225. /**
  84226. * Creates a cube texture
  84227. * @param rootUrl defines the url where the files to load is located
  84228. * @param scene defines the current scene
  84229. * @param files defines the list of files to load (1 per face)
  84230. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84231. * @param onLoad defines an optional callback raised when the texture is loaded
  84232. * @param onError defines an optional callback raised if there is an issue to load the texture
  84233. * @param format defines the format of the data
  84234. * @param forcedExtension defines the extension to use to pick the right loader
  84235. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  84236. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84237. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84238. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  84239. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  84240. * @returns the cube texture as an InternalTexture
  84241. */
  84242. 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;
  84243. /**
  84244. * @hidden
  84245. */
  84246. _setCubeMapTextureParams(loadMipmap: boolean): void;
  84247. /**
  84248. * Update a raw cube texture
  84249. * @param texture defines the texture to udpdate
  84250. * @param data defines the data to store
  84251. * @param format defines the data format
  84252. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84253. * @param invertY defines if data must be stored with Y axis inverted
  84254. * @param compression defines the compression used (null by default)
  84255. * @param level defines which level of the texture to update
  84256. */
  84257. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  84258. /**
  84259. * Creates a new raw cube texture
  84260. * @param data defines the array of data to use to create each face
  84261. * @param size defines the size of the textures
  84262. * @param format defines the format of the data
  84263. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84264. * @param generateMipMaps defines if the engine should generate the mip levels
  84265. * @param invertY defines if data must be stored with Y axis inverted
  84266. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84267. * @param compression defines the compression used (null by default)
  84268. * @returns the cube texture as an InternalTexture
  84269. */
  84270. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  84271. /**
  84272. * Creates a new raw cube texture from a specified url
  84273. * @param url defines the url where the data is located
  84274. * @param scene defines the current scene
  84275. * @param size defines the size of the textures
  84276. * @param format defines the format of the data
  84277. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84278. * @param noMipmap defines if the engine should avoid generating the mip levels
  84279. * @param callback defines a callback used to extract texture data from loaded data
  84280. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84281. * @param onLoad defines a callback called when texture is loaded
  84282. * @param onError defines a callback called if there is an error
  84283. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84284. * @param invertY defines if data must be stored with Y axis inverted
  84285. * @returns the cube texture as an InternalTexture
  84286. */
  84287. 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;
  84288. /**
  84289. * Update a raw 3D texture
  84290. * @param texture defines the texture to update
  84291. * @param data defines the data to store
  84292. * @param format defines the data format
  84293. * @param invertY defines if data must be stored with Y axis inverted
  84294. * @param compression defines the used compression (can be null)
  84295. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84296. */
  84297. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  84298. /**
  84299. * Creates a new raw 3D texture
  84300. * @param data defines the data used to create the texture
  84301. * @param width defines the width of the texture
  84302. * @param height defines the height of the texture
  84303. * @param depth defines the depth of the texture
  84304. * @param format defines the format of the texture
  84305. * @param generateMipMaps defines if the engine must generate mip levels
  84306. * @param invertY defines if data must be stored with Y axis inverted
  84307. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84308. * @param compression defines the compressed used (can be null)
  84309. * @param textureType defines the compressed used (can be null)
  84310. * @returns a new raw 3D texture (stored in an InternalTexture)
  84311. */
  84312. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  84313. private _prepareWebGLTextureContinuation;
  84314. private _prepareWebGLTexture;
  84315. private _convertRGBtoRGBATextureData;
  84316. /** @hidden */
  84317. _releaseFramebufferObjects(texture: InternalTexture): void;
  84318. /** @hidden */
  84319. _releaseTexture(texture: InternalTexture): void;
  84320. private setProgram;
  84321. private _boundUniforms;
  84322. /**
  84323. * Binds an effect to the webGL context
  84324. * @param effect defines the effect to bind
  84325. */
  84326. bindSamplers(effect: Effect): void;
  84327. private _moveBoundTextureOnTop;
  84328. private _getCorrectTextureChannel;
  84329. private _linkTrackers;
  84330. private _removeDesignatedSlot;
  84331. private _activateCurrentTexture;
  84332. /** @hidden */
  84333. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  84334. /** @hidden */
  84335. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  84336. /**
  84337. * Sets a texture to the webGL context from a postprocess
  84338. * @param channel defines the channel to use
  84339. * @param postProcess defines the source postprocess
  84340. */
  84341. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  84342. /**
  84343. * Binds the output of the passed in post process to the texture channel specified
  84344. * @param channel The channel the texture should be bound to
  84345. * @param postProcess The post process which's output should be bound
  84346. */
  84347. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  84348. /**
  84349. * Unbind all textures from the webGL context
  84350. */
  84351. unbindAllTextures(): void;
  84352. /**
  84353. * Sets a texture to the according uniform.
  84354. * @param channel The texture channel
  84355. * @param uniform The uniform to set
  84356. * @param texture The texture to apply
  84357. */
  84358. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  84359. /**
  84360. * Sets a depth stencil texture from a render target to the according uniform.
  84361. * @param channel The texture channel
  84362. * @param uniform The uniform to set
  84363. * @param texture The render target texture containing the depth stencil texture to apply
  84364. */
  84365. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  84366. private _bindSamplerUniformToChannel;
  84367. private _getTextureWrapMode;
  84368. private _setTexture;
  84369. /**
  84370. * Sets an array of texture to the webGL context
  84371. * @param channel defines the channel where the texture array must be set
  84372. * @param uniform defines the associated uniform location
  84373. * @param textures defines the array of textures to bind
  84374. */
  84375. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  84376. /** @hidden */
  84377. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  84378. private _setTextureParameterFloat;
  84379. private _setTextureParameterInteger;
  84380. /**
  84381. * Reads pixels from the current frame buffer. Please note that this function can be slow
  84382. * @param x defines the x coordinate of the rectangle where pixels must be read
  84383. * @param y defines the y coordinate of the rectangle where pixels must be read
  84384. * @param width defines the width of the rectangle where pixels must be read
  84385. * @param height defines the height of the rectangle where pixels must be read
  84386. * @returns a Uint8Array containing RGBA colors
  84387. */
  84388. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  84389. /**
  84390. * Add an externaly attached data from its key.
  84391. * This method call will fail and return false, if such key already exists.
  84392. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  84393. * @param key the unique key that identifies the data
  84394. * @param data the data object to associate to the key for this Engine instance
  84395. * @return true if no such key were already present and the data was added successfully, false otherwise
  84396. */
  84397. addExternalData<T>(key: string, data: T): boolean;
  84398. /**
  84399. * Get an externaly attached data from its key
  84400. * @param key the unique key that identifies the data
  84401. * @return the associated data, if present (can be null), or undefined if not present
  84402. */
  84403. getExternalData<T>(key: string): T;
  84404. /**
  84405. * Get an externaly attached data from its key, create it using a factory if it's not already present
  84406. * @param key the unique key that identifies the data
  84407. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  84408. * @return the associated data, can be null if the factory returned null.
  84409. */
  84410. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  84411. /**
  84412. * Remove an externaly attached data from the Engine instance
  84413. * @param key the unique key that identifies the data
  84414. * @return true if the data was successfully removed, false if it doesn't exist
  84415. */
  84416. removeExternalData(key: string): boolean;
  84417. /**
  84418. * Unbind all vertex attributes from the webGL context
  84419. */
  84420. unbindAllAttributes(): void;
  84421. /**
  84422. * 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
  84423. */
  84424. releaseEffects(): void;
  84425. /**
  84426. * Dispose and release all associated resources
  84427. */
  84428. dispose(): void;
  84429. /**
  84430. * Display the loading screen
  84431. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84432. */
  84433. displayLoadingUI(): void;
  84434. /**
  84435. * Hide the loading screen
  84436. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84437. */
  84438. hideLoadingUI(): void;
  84439. /**
  84440. * Gets the current loading screen object
  84441. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84442. */
  84443. /**
  84444. * Sets the current loading screen object
  84445. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84446. */
  84447. loadingScreen: ILoadingScreen;
  84448. /**
  84449. * Sets the current loading screen text
  84450. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84451. */
  84452. loadingUIText: string;
  84453. /**
  84454. * Sets the current loading screen background color
  84455. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84456. */
  84457. loadingUIBackgroundColor: string;
  84458. /**
  84459. * Attach a new callback raised when context lost event is fired
  84460. * @param callback defines the callback to call
  84461. */
  84462. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  84463. /**
  84464. * Attach a new callback raised when context restored event is fired
  84465. * @param callback defines the callback to call
  84466. */
  84467. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  84468. /**
  84469. * Gets the source code of the vertex shader associated with a specific webGL program
  84470. * @param program defines the program to use
  84471. * @returns a string containing the source code of the vertex shader associated with the program
  84472. */
  84473. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  84474. /**
  84475. * Gets the source code of the fragment shader associated with a specific webGL program
  84476. * @param program defines the program to use
  84477. * @returns a string containing the source code of the fragment shader associated with the program
  84478. */
  84479. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  84480. /**
  84481. * Get the current error code of the webGL context
  84482. * @returns the error code
  84483. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  84484. */
  84485. getError(): number;
  84486. /**
  84487. * Gets the current framerate
  84488. * @returns a number representing the framerate
  84489. */
  84490. getFps(): number;
  84491. /**
  84492. * Gets the time spent between current and previous frame
  84493. * @returns a number representing the delta time in ms
  84494. */
  84495. getDeltaTime(): number;
  84496. private _measureFps;
  84497. /** @hidden */
  84498. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  84499. private _canRenderToFloatFramebuffer;
  84500. private _canRenderToHalfFloatFramebuffer;
  84501. private _canRenderToFramebuffer;
  84502. /** @hidden */
  84503. _getWebGLTextureType(type: number): number;
  84504. private _getInternalFormat;
  84505. /** @hidden */
  84506. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  84507. /** @hidden */
  84508. _getRGBAMultiSampleBufferFormat(type: number): number;
  84509. /** @hidden */
  84510. _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;
  84511. /** @hidden */
  84512. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  84513. private _partialLoadFile;
  84514. private _cascadeLoadFiles;
  84515. /**
  84516. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  84517. * @returns true if the engine can be created
  84518. * @ignorenaming
  84519. */
  84520. static isSupported(): boolean;
  84521. }
  84522. }
  84523. declare module BABYLON {
  84524. /**
  84525. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  84526. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  84527. */
  84528. export class EffectFallbacks {
  84529. private _defines;
  84530. private _currentRank;
  84531. private _maxRank;
  84532. private _mesh;
  84533. /**
  84534. * Removes the fallback from the bound mesh.
  84535. */
  84536. unBindMesh(): void;
  84537. /**
  84538. * Adds a fallback on the specified property.
  84539. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  84540. * @param define The name of the define in the shader
  84541. */
  84542. addFallback(rank: number, define: string): void;
  84543. /**
  84544. * Sets the mesh to use CPU skinning when needing to fallback.
  84545. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  84546. * @param mesh The mesh to use the fallbacks.
  84547. */
  84548. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  84549. /**
  84550. * Checks to see if more fallbacks are still availible.
  84551. */
  84552. readonly isMoreFallbacks: boolean;
  84553. /**
  84554. * Removes the defines that shoould be removed when falling back.
  84555. * @param currentDefines defines the current define statements for the shader.
  84556. * @param effect defines the current effect we try to compile
  84557. * @returns The resulting defines with defines of the current rank removed.
  84558. */
  84559. reduce(currentDefines: string, effect: Effect): string;
  84560. }
  84561. /**
  84562. * Options to be used when creating an effect.
  84563. */
  84564. export class EffectCreationOptions {
  84565. /**
  84566. * Atrributes that will be used in the shader.
  84567. */
  84568. attributes: string[];
  84569. /**
  84570. * Uniform varible names that will be set in the shader.
  84571. */
  84572. uniformsNames: string[];
  84573. /**
  84574. * Uniform buffer varible names that will be set in the shader.
  84575. */
  84576. uniformBuffersNames: string[];
  84577. /**
  84578. * Sampler texture variable names that will be set in the shader.
  84579. */
  84580. samplers: string[];
  84581. /**
  84582. * Define statements that will be set in the shader.
  84583. */
  84584. defines: any;
  84585. /**
  84586. * Possible fallbacks for this effect to improve performance when needed.
  84587. */
  84588. fallbacks: Nullable<EffectFallbacks>;
  84589. /**
  84590. * Callback that will be called when the shader is compiled.
  84591. */
  84592. onCompiled: Nullable<(effect: Effect) => void>;
  84593. /**
  84594. * Callback that will be called if an error occurs during shader compilation.
  84595. */
  84596. onError: Nullable<(effect: Effect, errors: string) => void>;
  84597. /**
  84598. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  84599. */
  84600. indexParameters: any;
  84601. /**
  84602. * Max number of lights that can be used in the shader.
  84603. */
  84604. maxSimultaneousLights: number;
  84605. /**
  84606. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  84607. */
  84608. transformFeedbackVaryings: Nullable<string[]>;
  84609. }
  84610. /**
  84611. * Effect containing vertex and fragment shader that can be executed on an object.
  84612. */
  84613. export class Effect {
  84614. /**
  84615. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  84616. */
  84617. static ShadersRepository: string;
  84618. /**
  84619. * Name of the effect.
  84620. */
  84621. name: any;
  84622. /**
  84623. * String container all the define statements that should be set on the shader.
  84624. */
  84625. defines: string;
  84626. /**
  84627. * Callback that will be called when the shader is compiled.
  84628. */
  84629. onCompiled: Nullable<(effect: Effect) => void>;
  84630. /**
  84631. * Callback that will be called if an error occurs during shader compilation.
  84632. */
  84633. onError: Nullable<(effect: Effect, errors: string) => void>;
  84634. /**
  84635. * Callback that will be called when effect is bound.
  84636. */
  84637. onBind: Nullable<(effect: Effect) => void>;
  84638. /**
  84639. * Unique ID of the effect.
  84640. */
  84641. uniqueId: number;
  84642. /**
  84643. * Observable that will be called when the shader is compiled.
  84644. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  84645. */
  84646. onCompileObservable: Observable<Effect>;
  84647. /**
  84648. * Observable that will be called if an error occurs during shader compilation.
  84649. */
  84650. onErrorObservable: Observable<Effect>;
  84651. /** @hidden */
  84652. _onBindObservable: Nullable<Observable<Effect>>;
  84653. /**
  84654. * Observable that will be called when effect is bound.
  84655. */
  84656. readonly onBindObservable: Observable<Effect>;
  84657. /** @hidden */
  84658. _bonesComputationForcedToCPU: boolean;
  84659. private static _uniqueIdSeed;
  84660. private _engine;
  84661. private _uniformBuffersNames;
  84662. private _uniformsNames;
  84663. private _samplers;
  84664. private _isReady;
  84665. private _compilationError;
  84666. private _attributesNames;
  84667. private _attributes;
  84668. private _uniforms;
  84669. /**
  84670. * Key for the effect.
  84671. * @hidden
  84672. */
  84673. _key: string;
  84674. private _indexParameters;
  84675. private _fallbacks;
  84676. private _vertexSourceCode;
  84677. private _fragmentSourceCode;
  84678. private _vertexSourceCodeOverride;
  84679. private _fragmentSourceCodeOverride;
  84680. private _transformFeedbackVaryings;
  84681. /**
  84682. * Compiled shader to webGL program.
  84683. * @hidden
  84684. */
  84685. _program: WebGLProgram;
  84686. private _valueCache;
  84687. private static _baseCache;
  84688. /**
  84689. * Instantiates an effect.
  84690. * An effect can be used to create/manage/execute vertex and fragment shaders.
  84691. * @param baseName Name of the effect.
  84692. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  84693. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  84694. * @param samplers List of sampler variables that will be passed to the shader.
  84695. * @param engine Engine to be used to render the effect
  84696. * @param defines Define statements to be added to the shader.
  84697. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  84698. * @param onCompiled Callback that will be called when the shader is compiled.
  84699. * @param onError Callback that will be called if an error occurs during shader compilation.
  84700. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  84701. */
  84702. 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);
  84703. /**
  84704. * Unique key for this effect
  84705. */
  84706. readonly key: string;
  84707. /**
  84708. * If the effect has been compiled and prepared.
  84709. * @returns if the effect is compiled and prepared.
  84710. */
  84711. isReady(): boolean;
  84712. /**
  84713. * The engine the effect was initialized with.
  84714. * @returns the engine.
  84715. */
  84716. getEngine(): Engine;
  84717. /**
  84718. * The compiled webGL program for the effect
  84719. * @returns the webGL program.
  84720. */
  84721. getProgram(): WebGLProgram;
  84722. /**
  84723. * The set of names of attribute variables for the shader.
  84724. * @returns An array of attribute names.
  84725. */
  84726. getAttributesNames(): string[];
  84727. /**
  84728. * Returns the attribute at the given index.
  84729. * @param index The index of the attribute.
  84730. * @returns The location of the attribute.
  84731. */
  84732. getAttributeLocation(index: number): number;
  84733. /**
  84734. * Returns the attribute based on the name of the variable.
  84735. * @param name of the attribute to look up.
  84736. * @returns the attribute location.
  84737. */
  84738. getAttributeLocationByName(name: string): number;
  84739. /**
  84740. * The number of attributes.
  84741. * @returns the numnber of attributes.
  84742. */
  84743. getAttributesCount(): number;
  84744. /**
  84745. * Gets the index of a uniform variable.
  84746. * @param uniformName of the uniform to look up.
  84747. * @returns the index.
  84748. */
  84749. getUniformIndex(uniformName: string): number;
  84750. /**
  84751. * Returns the attribute based on the name of the variable.
  84752. * @param uniformName of the uniform to look up.
  84753. * @returns the location of the uniform.
  84754. */
  84755. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  84756. /**
  84757. * Returns an array of sampler variable names
  84758. * @returns The array of sampler variable neames.
  84759. */
  84760. getSamplers(): string[];
  84761. /**
  84762. * The error from the last compilation.
  84763. * @returns the error string.
  84764. */
  84765. getCompilationError(): string;
  84766. /**
  84767. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  84768. * @param func The callback to be used.
  84769. */
  84770. executeWhenCompiled(func: (effect: Effect) => void): void;
  84771. private _checkIsReady;
  84772. /** @hidden */
  84773. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  84774. /** @hidden */
  84775. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  84776. /** @hidden */
  84777. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  84778. private _processShaderConversion;
  84779. private _processIncludes;
  84780. private _processPrecision;
  84781. /**
  84782. * Recompiles the webGL program
  84783. * @param vertexSourceCode The source code for the vertex shader.
  84784. * @param fragmentSourceCode The source code for the fragment shader.
  84785. * @param onCompiled Callback called when completed.
  84786. * @param onError Callback called on error.
  84787. * @hidden
  84788. */
  84789. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  84790. /**
  84791. * Gets the uniform locations of the the specified variable names
  84792. * @param names THe names of the variables to lookup.
  84793. * @returns Array of locations in the same order as variable names.
  84794. */
  84795. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  84796. /**
  84797. * Prepares the effect
  84798. * @hidden
  84799. */
  84800. _prepareEffect(): void;
  84801. /**
  84802. * Checks if the effect is supported. (Must be called after compilation)
  84803. */
  84804. readonly isSupported: boolean;
  84805. /**
  84806. * Binds a texture to the engine to be used as output of the shader.
  84807. * @param channel Name of the output variable.
  84808. * @param texture Texture to bind.
  84809. * @hidden
  84810. */
  84811. _bindTexture(channel: string, texture: InternalTexture): void;
  84812. /**
  84813. * Sets a texture on the engine to be used in the shader.
  84814. * @param channel Name of the sampler variable.
  84815. * @param texture Texture to set.
  84816. */
  84817. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  84818. /**
  84819. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  84820. * @param channel Name of the sampler variable.
  84821. * @param texture Texture to set.
  84822. */
  84823. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  84824. /**
  84825. * Sets an array of textures on the engine to be used in the shader.
  84826. * @param channel Name of the variable.
  84827. * @param textures Textures to set.
  84828. */
  84829. setTextureArray(channel: string, textures: BaseTexture[]): void;
  84830. /**
  84831. * 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)
  84832. * @param channel Name of the sampler variable.
  84833. * @param postProcess Post process to get the input texture from.
  84834. */
  84835. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  84836. /**
  84837. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  84838. * 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)
  84839. * @param channel Name of the sampler variable.
  84840. * @param postProcess Post process to get the output texture from.
  84841. */
  84842. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  84843. /** @hidden */
  84844. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  84845. /** @hidden */
  84846. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  84847. /** @hidden */
  84848. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  84849. /** @hidden */
  84850. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  84851. /**
  84852. * Binds a buffer to a uniform.
  84853. * @param buffer Buffer to bind.
  84854. * @param name Name of the uniform variable to bind to.
  84855. */
  84856. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  84857. /**
  84858. * Binds block to a uniform.
  84859. * @param blockName Name of the block to bind.
  84860. * @param index Index to bind.
  84861. */
  84862. bindUniformBlock(blockName: string, index: number): void;
  84863. /**
  84864. * Sets an interger value on a uniform variable.
  84865. * @param uniformName Name of the variable.
  84866. * @param value Value to be set.
  84867. * @returns this effect.
  84868. */
  84869. setInt(uniformName: string, value: number): Effect;
  84870. /**
  84871. * Sets an int array on a uniform variable.
  84872. * @param uniformName Name of the variable.
  84873. * @param array array to be set.
  84874. * @returns this effect.
  84875. */
  84876. setIntArray(uniformName: string, array: Int32Array): Effect;
  84877. /**
  84878. * 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)
  84879. * @param uniformName Name of the variable.
  84880. * @param array array to be set.
  84881. * @returns this effect.
  84882. */
  84883. setIntArray2(uniformName: string, array: Int32Array): Effect;
  84884. /**
  84885. * 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)
  84886. * @param uniformName Name of the variable.
  84887. * @param array array to be set.
  84888. * @returns this effect.
  84889. */
  84890. setIntArray3(uniformName: string, array: Int32Array): Effect;
  84891. /**
  84892. * 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)
  84893. * @param uniformName Name of the variable.
  84894. * @param array array to be set.
  84895. * @returns this effect.
  84896. */
  84897. setIntArray4(uniformName: string, array: Int32Array): Effect;
  84898. /**
  84899. * Sets an float array on a uniform variable.
  84900. * @param uniformName Name of the variable.
  84901. * @param array array to be set.
  84902. * @returns this effect.
  84903. */
  84904. setFloatArray(uniformName: string, array: Float32Array): Effect;
  84905. /**
  84906. * 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)
  84907. * @param uniformName Name of the variable.
  84908. * @param array array to be set.
  84909. * @returns this effect.
  84910. */
  84911. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  84912. /**
  84913. * 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)
  84914. * @param uniformName Name of the variable.
  84915. * @param array array to be set.
  84916. * @returns this effect.
  84917. */
  84918. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  84919. /**
  84920. * 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)
  84921. * @param uniformName Name of the variable.
  84922. * @param array array to be set.
  84923. * @returns this effect.
  84924. */
  84925. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  84926. /**
  84927. * Sets an array on a uniform variable.
  84928. * @param uniformName Name of the variable.
  84929. * @param array array to be set.
  84930. * @returns this effect.
  84931. */
  84932. setArray(uniformName: string, array: number[]): Effect;
  84933. /**
  84934. * 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)
  84935. * @param uniformName Name of the variable.
  84936. * @param array array to be set.
  84937. * @returns this effect.
  84938. */
  84939. setArray2(uniformName: string, array: number[]): Effect;
  84940. /**
  84941. * 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)
  84942. * @param uniformName Name of the variable.
  84943. * @param array array to be set.
  84944. * @returns this effect.
  84945. */
  84946. setArray3(uniformName: string, array: number[]): Effect;
  84947. /**
  84948. * 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)
  84949. * @param uniformName Name of the variable.
  84950. * @param array array to be set.
  84951. * @returns this effect.
  84952. */
  84953. setArray4(uniformName: string, array: number[]): Effect;
  84954. /**
  84955. * Sets matrices on a uniform variable.
  84956. * @param uniformName Name of the variable.
  84957. * @param matrices matrices to be set.
  84958. * @returns this effect.
  84959. */
  84960. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  84961. /**
  84962. * Sets matrix on a uniform variable.
  84963. * @param uniformName Name of the variable.
  84964. * @param matrix matrix to be set.
  84965. * @returns this effect.
  84966. */
  84967. setMatrix(uniformName: string, matrix: Matrix): Effect;
  84968. /**
  84969. * 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)
  84970. * @param uniformName Name of the variable.
  84971. * @param matrix matrix to be set.
  84972. * @returns this effect.
  84973. */
  84974. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  84975. /**
  84976. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  84977. * @param uniformName Name of the variable.
  84978. * @param matrix matrix to be set.
  84979. * @returns this effect.
  84980. */
  84981. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  84982. /**
  84983. * Sets a float on a uniform variable.
  84984. * @param uniformName Name of the variable.
  84985. * @param value value to be set.
  84986. * @returns this effect.
  84987. */
  84988. setFloat(uniformName: string, value: number): Effect;
  84989. /**
  84990. * Sets a boolean on a uniform variable.
  84991. * @param uniformName Name of the variable.
  84992. * @param bool value to be set.
  84993. * @returns this effect.
  84994. */
  84995. setBool(uniformName: string, bool: boolean): Effect;
  84996. /**
  84997. * Sets a Vector2 on a uniform variable.
  84998. * @param uniformName Name of the variable.
  84999. * @param vector2 vector2 to be set.
  85000. * @returns this effect.
  85001. */
  85002. setVector2(uniformName: string, vector2: Vector2): Effect;
  85003. /**
  85004. * Sets a float2 on a uniform variable.
  85005. * @param uniformName Name of the variable.
  85006. * @param x First float in float2.
  85007. * @param y Second float in float2.
  85008. * @returns this effect.
  85009. */
  85010. setFloat2(uniformName: string, x: number, y: number): Effect;
  85011. /**
  85012. * Sets a Vector3 on a uniform variable.
  85013. * @param uniformName Name of the variable.
  85014. * @param vector3 Value to be set.
  85015. * @returns this effect.
  85016. */
  85017. setVector3(uniformName: string, vector3: Vector3): Effect;
  85018. /**
  85019. * Sets a float3 on a uniform variable.
  85020. * @param uniformName Name of the variable.
  85021. * @param x First float in float3.
  85022. * @param y Second float in float3.
  85023. * @param z Third float in float3.
  85024. * @returns this effect.
  85025. */
  85026. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  85027. /**
  85028. * Sets a Vector4 on a uniform variable.
  85029. * @param uniformName Name of the variable.
  85030. * @param vector4 Value to be set.
  85031. * @returns this effect.
  85032. */
  85033. setVector4(uniformName: string, vector4: Vector4): Effect;
  85034. /**
  85035. * Sets a float4 on a uniform variable.
  85036. * @param uniformName Name of the variable.
  85037. * @param x First float in float4.
  85038. * @param y Second float in float4.
  85039. * @param z Third float in float4.
  85040. * @param w Fourth float in float4.
  85041. * @returns this effect.
  85042. */
  85043. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  85044. /**
  85045. * Sets a Color3 on a uniform variable.
  85046. * @param uniformName Name of the variable.
  85047. * @param color3 Value to be set.
  85048. * @returns this effect.
  85049. */
  85050. setColor3(uniformName: string, color3: Color3): Effect;
  85051. /**
  85052. * Sets a Color4 on a uniform variable.
  85053. * @param uniformName Name of the variable.
  85054. * @param color3 Value to be set.
  85055. * @param alpha Alpha value to be set.
  85056. * @returns this effect.
  85057. */
  85058. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  85059. /**
  85060. * Sets a Color4 on a uniform variable
  85061. * @param uniformName defines the name of the variable
  85062. * @param color4 defines the value to be set
  85063. * @returns this effect.
  85064. */
  85065. setDirectColor4(uniformName: string, color4: Color4): Effect;
  85066. /**
  85067. * This function will add a new shader to the shader store
  85068. * @param name the name of the shader
  85069. * @param pixelShader optional pixel shader content
  85070. * @param vertexShader optional vertex shader content
  85071. */
  85072. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  85073. /**
  85074. * Store of each shader (The can be looked up using effect.key)
  85075. */
  85076. static ShadersStore: {
  85077. [key: string]: string;
  85078. };
  85079. /**
  85080. * Store of each included file for a shader (The can be looked up using effect.key)
  85081. */
  85082. static IncludesShadersStore: {
  85083. [key: string]: string;
  85084. };
  85085. /**
  85086. * Resets the cache of effects.
  85087. */
  85088. static ResetCache(): void;
  85089. }
  85090. }
  85091. declare module BABYLON {
  85092. /**
  85093. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  85094. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  85095. * 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;
  85096. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  85097. */
  85098. export class ColorCurves {
  85099. private _dirty;
  85100. private _tempColor;
  85101. private _globalCurve;
  85102. private _highlightsCurve;
  85103. private _midtonesCurve;
  85104. private _shadowsCurve;
  85105. private _positiveCurve;
  85106. private _negativeCurve;
  85107. private _globalHue;
  85108. private _globalDensity;
  85109. private _globalSaturation;
  85110. private _globalExposure;
  85111. /**
  85112. * Gets the global Hue value.
  85113. * 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).
  85114. */
  85115. /**
  85116. * Sets the global Hue value.
  85117. * 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).
  85118. */
  85119. globalHue: number;
  85120. /**
  85121. * Gets the global Density value.
  85122. * 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.
  85123. * Values less than zero provide a filter of opposite hue.
  85124. */
  85125. /**
  85126. * Sets the global Density value.
  85127. * 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.
  85128. * Values less than zero provide a filter of opposite hue.
  85129. */
  85130. globalDensity: number;
  85131. /**
  85132. * Gets the global Saturation value.
  85133. * 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.
  85134. */
  85135. /**
  85136. * Sets the global Saturation value.
  85137. * 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.
  85138. */
  85139. globalSaturation: number;
  85140. /**
  85141. * Gets the global Exposure value.
  85142. * 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.
  85143. */
  85144. /**
  85145. * Sets the global Exposure value.
  85146. * 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.
  85147. */
  85148. globalExposure: number;
  85149. private _highlightsHue;
  85150. private _highlightsDensity;
  85151. private _highlightsSaturation;
  85152. private _highlightsExposure;
  85153. /**
  85154. * Gets the highlights Hue value.
  85155. * 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).
  85156. */
  85157. /**
  85158. * Sets the highlights Hue value.
  85159. * 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).
  85160. */
  85161. highlightsHue: number;
  85162. /**
  85163. * Gets the highlights Density value.
  85164. * 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.
  85165. * Values less than zero provide a filter of opposite hue.
  85166. */
  85167. /**
  85168. * Sets the highlights Density value.
  85169. * 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.
  85170. * Values less than zero provide a filter of opposite hue.
  85171. */
  85172. highlightsDensity: number;
  85173. /**
  85174. * Gets the highlights Saturation value.
  85175. * 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.
  85176. */
  85177. /**
  85178. * Sets the highlights Saturation value.
  85179. * 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.
  85180. */
  85181. highlightsSaturation: number;
  85182. /**
  85183. * Gets the highlights Exposure value.
  85184. * 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.
  85185. */
  85186. /**
  85187. * Sets the highlights Exposure value.
  85188. * 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.
  85189. */
  85190. highlightsExposure: number;
  85191. private _midtonesHue;
  85192. private _midtonesDensity;
  85193. private _midtonesSaturation;
  85194. private _midtonesExposure;
  85195. /**
  85196. * Gets the midtones Hue value.
  85197. * 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).
  85198. */
  85199. /**
  85200. * Sets the midtones Hue value.
  85201. * 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).
  85202. */
  85203. midtonesHue: number;
  85204. /**
  85205. * Gets the midtones Density value.
  85206. * 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.
  85207. * Values less than zero provide a filter of opposite hue.
  85208. */
  85209. /**
  85210. * Sets the midtones Density value.
  85211. * 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.
  85212. * Values less than zero provide a filter of opposite hue.
  85213. */
  85214. midtonesDensity: number;
  85215. /**
  85216. * Gets the midtones Saturation value.
  85217. * 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.
  85218. */
  85219. /**
  85220. * Sets the midtones Saturation value.
  85221. * 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.
  85222. */
  85223. midtonesSaturation: number;
  85224. /**
  85225. * Gets the midtones Exposure value.
  85226. * 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.
  85227. */
  85228. /**
  85229. * Sets the midtones Exposure value.
  85230. * 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.
  85231. */
  85232. midtonesExposure: number;
  85233. private _shadowsHue;
  85234. private _shadowsDensity;
  85235. private _shadowsSaturation;
  85236. private _shadowsExposure;
  85237. /**
  85238. * Gets the shadows Hue value.
  85239. * 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).
  85240. */
  85241. /**
  85242. * Sets the shadows Hue value.
  85243. * 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).
  85244. */
  85245. shadowsHue: number;
  85246. /**
  85247. * Gets the shadows Density value.
  85248. * 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.
  85249. * Values less than zero provide a filter of opposite hue.
  85250. */
  85251. /**
  85252. * Sets the shadows Density value.
  85253. * 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.
  85254. * Values less than zero provide a filter of opposite hue.
  85255. */
  85256. shadowsDensity: number;
  85257. /**
  85258. * Gets the shadows Saturation value.
  85259. * 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.
  85260. */
  85261. /**
  85262. * Sets the shadows Saturation value.
  85263. * 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.
  85264. */
  85265. shadowsSaturation: number;
  85266. /**
  85267. * Gets the shadows Exposure value.
  85268. * 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.
  85269. */
  85270. /**
  85271. * Sets the shadows Exposure value.
  85272. * 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.
  85273. */
  85274. shadowsExposure: number;
  85275. /**
  85276. * Returns the class name
  85277. * @returns The class name
  85278. */
  85279. getClassName(): string;
  85280. /**
  85281. * Binds the color curves to the shader.
  85282. * @param colorCurves The color curve to bind
  85283. * @param effect The effect to bind to
  85284. * @param positiveUniform The positive uniform shader parameter
  85285. * @param neutralUniform The neutral uniform shader parameter
  85286. * @param negativeUniform The negative uniform shader parameter
  85287. */
  85288. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  85289. /**
  85290. * Prepare the list of uniforms associated with the ColorCurves effects.
  85291. * @param uniformsList The list of uniforms used in the effect
  85292. */
  85293. static PrepareUniforms(uniformsList: string[]): void;
  85294. /**
  85295. * Returns color grading data based on a hue, density, saturation and exposure value.
  85296. * @param filterHue The hue of the color filter.
  85297. * @param filterDensity The density of the color filter.
  85298. * @param saturation The saturation.
  85299. * @param exposure The exposure.
  85300. * @param result The result data container.
  85301. */
  85302. private getColorGradingDataToRef;
  85303. /**
  85304. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  85305. * @param value The input slider value in range [-100,100].
  85306. * @returns Adjusted value.
  85307. */
  85308. private static applyColorGradingSliderNonlinear;
  85309. /**
  85310. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  85311. * @param hue The hue (H) input.
  85312. * @param saturation The saturation (S) input.
  85313. * @param brightness The brightness (B) input.
  85314. * @result An RGBA color represented as Vector4.
  85315. */
  85316. private static fromHSBToRef;
  85317. /**
  85318. * Returns a value clamped between min and max
  85319. * @param value The value to clamp
  85320. * @param min The minimum of value
  85321. * @param max The maximum of value
  85322. * @returns The clamped value.
  85323. */
  85324. private static clamp;
  85325. /**
  85326. * Clones the current color curve instance.
  85327. * @return The cloned curves
  85328. */
  85329. clone(): ColorCurves;
  85330. /**
  85331. * Serializes the current color curve instance to a json representation.
  85332. * @return a JSON representation
  85333. */
  85334. serialize(): any;
  85335. /**
  85336. * Parses the color curve from a json representation.
  85337. * @param source the JSON source to parse
  85338. * @return The parsed curves
  85339. */
  85340. static Parse(source: any): ColorCurves;
  85341. }
  85342. }
  85343. declare module BABYLON {
  85344. /**
  85345. * Interface to follow in your material defines to integrate easily the
  85346. * Image proccessing functions.
  85347. * @hidden
  85348. */
  85349. export interface IImageProcessingConfigurationDefines {
  85350. IMAGEPROCESSING: boolean;
  85351. VIGNETTE: boolean;
  85352. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85353. VIGNETTEBLENDMODEOPAQUE: boolean;
  85354. TONEMAPPING: boolean;
  85355. TONEMAPPING_ACES: boolean;
  85356. CONTRAST: boolean;
  85357. EXPOSURE: boolean;
  85358. COLORCURVES: boolean;
  85359. COLORGRADING: boolean;
  85360. COLORGRADING3D: boolean;
  85361. SAMPLER3DGREENDEPTH: boolean;
  85362. SAMPLER3DBGRMAP: boolean;
  85363. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85364. }
  85365. /**
  85366. * @hidden
  85367. */
  85368. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  85369. IMAGEPROCESSING: boolean;
  85370. VIGNETTE: boolean;
  85371. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85372. VIGNETTEBLENDMODEOPAQUE: boolean;
  85373. TONEMAPPING: boolean;
  85374. TONEMAPPING_ACES: boolean;
  85375. CONTRAST: boolean;
  85376. COLORCURVES: boolean;
  85377. COLORGRADING: boolean;
  85378. COLORGRADING3D: boolean;
  85379. SAMPLER3DGREENDEPTH: boolean;
  85380. SAMPLER3DBGRMAP: boolean;
  85381. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85382. EXPOSURE: boolean;
  85383. constructor();
  85384. }
  85385. /**
  85386. * This groups together the common properties used for image processing either in direct forward pass
  85387. * or through post processing effect depending on the use of the image processing pipeline in your scene
  85388. * or not.
  85389. */
  85390. export class ImageProcessingConfiguration {
  85391. /**
  85392. * Default tone mapping applied in BabylonJS.
  85393. */
  85394. static readonly TONEMAPPING_STANDARD: number;
  85395. /**
  85396. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  85397. * to other engines rendering to increase portability.
  85398. */
  85399. static readonly TONEMAPPING_ACES: number;
  85400. /**
  85401. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  85402. */
  85403. colorCurves: Nullable<ColorCurves>;
  85404. private _colorCurvesEnabled;
  85405. /**
  85406. * Gets wether the color curves effect is enabled.
  85407. */
  85408. /**
  85409. * Sets wether the color curves effect is enabled.
  85410. */
  85411. colorCurvesEnabled: boolean;
  85412. private _colorGradingTexture;
  85413. /**
  85414. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85415. */
  85416. /**
  85417. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85418. */
  85419. colorGradingTexture: Nullable<BaseTexture>;
  85420. private _colorGradingEnabled;
  85421. /**
  85422. * Gets wether the color grading effect is enabled.
  85423. */
  85424. /**
  85425. * Sets wether the color grading effect is enabled.
  85426. */
  85427. colorGradingEnabled: boolean;
  85428. private _colorGradingWithGreenDepth;
  85429. /**
  85430. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  85431. */
  85432. /**
  85433. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  85434. */
  85435. colorGradingWithGreenDepth: boolean;
  85436. private _colorGradingBGR;
  85437. /**
  85438. * Gets wether the color grading texture contains BGR values.
  85439. */
  85440. /**
  85441. * Sets wether the color grading texture contains BGR values.
  85442. */
  85443. colorGradingBGR: boolean;
  85444. /** @hidden */
  85445. _exposure: number;
  85446. /**
  85447. * Gets the Exposure used in the effect.
  85448. */
  85449. /**
  85450. * Sets the Exposure used in the effect.
  85451. */
  85452. exposure: number;
  85453. private _toneMappingEnabled;
  85454. /**
  85455. * Gets wether the tone mapping effect is enabled.
  85456. */
  85457. /**
  85458. * Sets wether the tone mapping effect is enabled.
  85459. */
  85460. toneMappingEnabled: boolean;
  85461. private _toneMappingType;
  85462. /**
  85463. * Gets the type of tone mapping effect.
  85464. */
  85465. /**
  85466. * Sets the type of tone mapping effect used in BabylonJS.
  85467. */
  85468. toneMappingType: number;
  85469. protected _contrast: number;
  85470. /**
  85471. * Gets the contrast used in the effect.
  85472. */
  85473. /**
  85474. * Sets the contrast used in the effect.
  85475. */
  85476. contrast: number;
  85477. /**
  85478. * Vignette stretch size.
  85479. */
  85480. vignetteStretch: number;
  85481. /**
  85482. * Vignette centre X Offset.
  85483. */
  85484. vignetteCentreX: number;
  85485. /**
  85486. * Vignette centre Y Offset.
  85487. */
  85488. vignetteCentreY: number;
  85489. /**
  85490. * Vignette weight or intensity of the vignette effect.
  85491. */
  85492. vignetteWeight: number;
  85493. /**
  85494. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  85495. * if vignetteEnabled is set to true.
  85496. */
  85497. vignetteColor: Color4;
  85498. /**
  85499. * Camera field of view used by the Vignette effect.
  85500. */
  85501. vignetteCameraFov: number;
  85502. private _vignetteBlendMode;
  85503. /**
  85504. * Gets the vignette blend mode allowing different kind of effect.
  85505. */
  85506. /**
  85507. * Sets the vignette blend mode allowing different kind of effect.
  85508. */
  85509. vignetteBlendMode: number;
  85510. private _vignetteEnabled;
  85511. /**
  85512. * Gets wether the vignette effect is enabled.
  85513. */
  85514. /**
  85515. * Sets wether the vignette effect is enabled.
  85516. */
  85517. vignetteEnabled: boolean;
  85518. private _applyByPostProcess;
  85519. /**
  85520. * Gets wether the image processing is applied through a post process or not.
  85521. */
  85522. /**
  85523. * Sets wether the image processing is applied through a post process or not.
  85524. */
  85525. applyByPostProcess: boolean;
  85526. private _isEnabled;
  85527. /**
  85528. * Gets wether the image processing is enabled or not.
  85529. */
  85530. /**
  85531. * Sets wether the image processing is enabled or not.
  85532. */
  85533. isEnabled: boolean;
  85534. /**
  85535. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  85536. */
  85537. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  85538. /**
  85539. * Method called each time the image processing information changes requires to recompile the effect.
  85540. */
  85541. protected _updateParameters(): void;
  85542. /**
  85543. * Gets the current class name.
  85544. * @return "ImageProcessingConfiguration"
  85545. */
  85546. getClassName(): string;
  85547. /**
  85548. * Prepare the list of uniforms associated with the Image Processing effects.
  85549. * @param uniforms The list of uniforms used in the effect
  85550. * @param defines the list of defines currently in use
  85551. */
  85552. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  85553. /**
  85554. * Prepare the list of samplers associated with the Image Processing effects.
  85555. * @param samplersList The list of uniforms used in the effect
  85556. * @param defines the list of defines currently in use
  85557. */
  85558. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  85559. /**
  85560. * Prepare the list of defines associated to the shader.
  85561. * @param defines the list of defines to complete
  85562. * @param forPostProcess Define if we are currently in post process mode or not
  85563. */
  85564. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  85565. /**
  85566. * Returns true if all the image processing information are ready.
  85567. * @returns True if ready, otherwise, false
  85568. */
  85569. isReady(): boolean;
  85570. /**
  85571. * Binds the image processing to the shader.
  85572. * @param effect The effect to bind to
  85573. * @param aspectRatio Define the current aspect ratio of the effect
  85574. */
  85575. bind(effect: Effect, aspectRatio?: number): void;
  85576. /**
  85577. * Clones the current image processing instance.
  85578. * @return The cloned image processing
  85579. */
  85580. clone(): ImageProcessingConfiguration;
  85581. /**
  85582. * Serializes the current image processing instance to a json representation.
  85583. * @return a JSON representation
  85584. */
  85585. serialize(): any;
  85586. /**
  85587. * Parses the image processing from a json representation.
  85588. * @param source the JSON source to parse
  85589. * @return The parsed image processing
  85590. */
  85591. static Parse(source: any): ImageProcessingConfiguration;
  85592. private static _VIGNETTEMODE_MULTIPLY;
  85593. private static _VIGNETTEMODE_OPAQUE;
  85594. /**
  85595. * Used to apply the vignette as a mix with the pixel color.
  85596. */
  85597. static readonly VIGNETTEMODE_MULTIPLY: number;
  85598. /**
  85599. * Used to apply the vignette as a replacement of the pixel color.
  85600. */
  85601. static readonly VIGNETTEMODE_OPAQUE: number;
  85602. }
  85603. }
  85604. declare module BABYLON {
  85605. /**
  85606. * This represents all the required information to add a fresnel effect on a material:
  85607. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  85608. */
  85609. export class FresnelParameters {
  85610. private _isEnabled;
  85611. /**
  85612. * Define if the fresnel effect is enable or not.
  85613. */
  85614. isEnabled: boolean;
  85615. /**
  85616. * Define the color used on edges (grazing angle)
  85617. */
  85618. leftColor: Color3;
  85619. /**
  85620. * Define the color used on center
  85621. */
  85622. rightColor: Color3;
  85623. /**
  85624. * Define bias applied to computed fresnel term
  85625. */
  85626. bias: number;
  85627. /**
  85628. * Defined the power exponent applied to fresnel term
  85629. */
  85630. power: number;
  85631. /**
  85632. * Clones the current fresnel and its valuues
  85633. * @returns a clone fresnel configuration
  85634. */
  85635. clone(): FresnelParameters;
  85636. /**
  85637. * Serializes the current fresnel parameters to a JSON representation.
  85638. * @return the JSON serialization
  85639. */
  85640. serialize(): any;
  85641. /**
  85642. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  85643. * @param parsedFresnelParameters Define the JSON representation
  85644. * @returns the parsed parameters
  85645. */
  85646. static Parse(parsedFresnelParameters: any): FresnelParameters;
  85647. }
  85648. }
  85649. declare module BABYLON {
  85650. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  85651. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85652. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85653. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85654. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85655. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85656. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85657. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85658. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85659. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85660. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85661. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85662. /**
  85663. * Decorator used to define property that can be serialized as reference to a camera
  85664. * @param sourceName defines the name of the property to decorate
  85665. */
  85666. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85667. /**
  85668. * Class used to help serialization objects
  85669. */
  85670. export class SerializationHelper {
  85671. /** hidden */
  85672. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  85673. /** hidden */
  85674. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  85675. /** hidden */
  85676. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  85677. /** hidden */
  85678. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  85679. /**
  85680. * Appends the serialized animations from the source animations
  85681. * @param source Source containing the animations
  85682. * @param destination Target to store the animations
  85683. */
  85684. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  85685. /**
  85686. * Static function used to serialized a specific entity
  85687. * @param entity defines the entity to serialize
  85688. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  85689. * @returns a JSON compatible object representing the serialization of the entity
  85690. */
  85691. static Serialize<T>(entity: T, serializationObject?: any): any;
  85692. /**
  85693. * Creates a new entity from a serialization data object
  85694. * @param creationFunction defines a function used to instanciated the new entity
  85695. * @param source defines the source serialization data
  85696. * @param scene defines the hosting scene
  85697. * @param rootUrl defines the root url for resources
  85698. * @returns a new entity
  85699. */
  85700. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  85701. /**
  85702. * Clones an object
  85703. * @param creationFunction defines the function used to instanciate the new object
  85704. * @param source defines the source object
  85705. * @returns the cloned object
  85706. */
  85707. static Clone<T>(creationFunction: () => T, source: T): T;
  85708. /**
  85709. * Instanciates a new object based on a source one (some data will be shared between both object)
  85710. * @param creationFunction defines the function used to instanciate the new object
  85711. * @param source defines the source object
  85712. * @returns the new object
  85713. */
  85714. static Instanciate<T>(creationFunction: () => T, source: T): T;
  85715. }
  85716. }
  85717. declare module BABYLON {
  85718. /**
  85719. * This is the base class of all the camera used in the application.
  85720. * @see http://doc.babylonjs.com/features/cameras
  85721. */
  85722. export class Camera extends Node {
  85723. /** @hidden */
  85724. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  85725. /**
  85726. * This is the default projection mode used by the cameras.
  85727. * It helps recreating a feeling of perspective and better appreciate depth.
  85728. * This is the best way to simulate real life cameras.
  85729. */
  85730. static readonly PERSPECTIVE_CAMERA: number;
  85731. /**
  85732. * This helps creating camera with an orthographic mode.
  85733. * 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.
  85734. */
  85735. static readonly ORTHOGRAPHIC_CAMERA: number;
  85736. /**
  85737. * This is the default FOV mode for perspective cameras.
  85738. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  85739. */
  85740. static readonly FOVMODE_VERTICAL_FIXED: number;
  85741. /**
  85742. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  85743. */
  85744. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  85745. /**
  85746. * This specifies ther is no need for a camera rig.
  85747. * Basically only one eye is rendered corresponding to the camera.
  85748. */
  85749. static readonly RIG_MODE_NONE: number;
  85750. /**
  85751. * Simulates a camera Rig with one blue eye and one red eye.
  85752. * This can be use with 3d blue and red glasses.
  85753. */
  85754. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  85755. /**
  85756. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  85757. */
  85758. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  85759. /**
  85760. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  85761. */
  85762. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  85763. /**
  85764. * Defines that both eyes of the camera will be rendered over under each other.
  85765. */
  85766. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  85767. /**
  85768. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  85769. */
  85770. static readonly RIG_MODE_VR: number;
  85771. /**
  85772. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  85773. */
  85774. static readonly RIG_MODE_WEBVR: number;
  85775. /**
  85776. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  85777. */
  85778. static readonly RIG_MODE_CUSTOM: number;
  85779. /**
  85780. * Defines if by default attaching controls should prevent the default javascript event to continue.
  85781. */
  85782. static ForceAttachControlToAlwaysPreventDefault: boolean;
  85783. /**
  85784. * @hidden
  85785. * Might be removed once multiview will be a thing
  85786. */
  85787. static UseAlternateWebVRRendering: boolean;
  85788. /**
  85789. * Define the input manager associated with the camera.
  85790. */
  85791. inputs: CameraInputsManager<Camera>;
  85792. /**
  85793. * Define the current local position of the camera in the scene
  85794. */
  85795. position: Vector3;
  85796. /**
  85797. * The vector the camera should consider as up.
  85798. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  85799. */
  85800. upVector: Vector3;
  85801. /**
  85802. * Define the current limit on the left side for an orthographic camera
  85803. * In scene unit
  85804. */
  85805. orthoLeft: Nullable<number>;
  85806. /**
  85807. * Define the current limit on the right side for an orthographic camera
  85808. * In scene unit
  85809. */
  85810. orthoRight: Nullable<number>;
  85811. /**
  85812. * Define the current limit on the bottom side for an orthographic camera
  85813. * In scene unit
  85814. */
  85815. orthoBottom: Nullable<number>;
  85816. /**
  85817. * Define the current limit on the top side for an orthographic camera
  85818. * In scene unit
  85819. */
  85820. orthoTop: Nullable<number>;
  85821. /**
  85822. * Field Of View is set in Radians. (default is 0.8)
  85823. */
  85824. fov: number;
  85825. /**
  85826. * Define the minimum distance the camera can see from.
  85827. * This is important to note that the depth buffer are not infinite and the closer it starts
  85828. * the more your scene might encounter depth fighting issue.
  85829. */
  85830. minZ: number;
  85831. /**
  85832. * Define the maximum distance the camera can see to.
  85833. * This is important to note that the depth buffer are not infinite and the further it end
  85834. * the more your scene might encounter depth fighting issue.
  85835. */
  85836. maxZ: number;
  85837. /**
  85838. * Define the default inertia of the camera.
  85839. * This helps giving a smooth feeling to the camera movement.
  85840. */
  85841. inertia: number;
  85842. /**
  85843. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  85844. */
  85845. mode: number;
  85846. /**
  85847. * Define wether the camera is intermediate.
  85848. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  85849. */
  85850. isIntermediate: boolean;
  85851. /**
  85852. * Define the viewport of the camera.
  85853. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  85854. */
  85855. viewport: Viewport;
  85856. /**
  85857. * Restricts the camera to viewing objects with the same layerMask.
  85858. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  85859. */
  85860. layerMask: number;
  85861. /**
  85862. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  85863. */
  85864. fovMode: number;
  85865. /**
  85866. * Rig mode of the camera.
  85867. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  85868. * This is normally controlled byt the camera themselves as internal use.
  85869. */
  85870. cameraRigMode: number;
  85871. /**
  85872. * Defines the distance between both "eyes" in case of a RIG
  85873. */
  85874. interaxialDistance: number;
  85875. /**
  85876. * Defines if stereoscopic rendering is done side by side or over under.
  85877. */
  85878. isStereoscopicSideBySide: boolean;
  85879. /**
  85880. * 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
  85881. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  85882. * else in the scene.
  85883. */
  85884. customRenderTargets: RenderTargetTexture[];
  85885. /**
  85886. * When set, the camera will render to this render target instead of the default canvas
  85887. */
  85888. outputRenderTarget: Nullable<RenderTargetTexture>;
  85889. /**
  85890. * Observable triggered when the camera view matrix has changed.
  85891. */
  85892. onViewMatrixChangedObservable: Observable<Camera>;
  85893. /**
  85894. * Observable triggered when the camera Projection matrix has changed.
  85895. */
  85896. onProjectionMatrixChangedObservable: Observable<Camera>;
  85897. /**
  85898. * Observable triggered when the inputs have been processed.
  85899. */
  85900. onAfterCheckInputsObservable: Observable<Camera>;
  85901. /**
  85902. * Observable triggered when reset has been called and applied to the camera.
  85903. */
  85904. onRestoreStateObservable: Observable<Camera>;
  85905. /** @hidden */
  85906. _cameraRigParams: any;
  85907. /** @hidden */
  85908. _rigCameras: Camera[];
  85909. /** @hidden */
  85910. _rigPostProcess: Nullable<PostProcess>;
  85911. protected _webvrViewMatrix: Matrix;
  85912. /** @hidden */
  85913. _skipRendering: boolean;
  85914. /** @hidden */
  85915. _alternateCamera: Camera;
  85916. /** @hidden */
  85917. _projectionMatrix: Matrix;
  85918. /** @hidden */
  85919. _postProcesses: Nullable<PostProcess>[];
  85920. /** @hidden */
  85921. _activeMeshes: SmartArray<AbstractMesh>;
  85922. protected _globalPosition: Vector3;
  85923. /** hidden */
  85924. _computedViewMatrix: Matrix;
  85925. private _doNotComputeProjectionMatrix;
  85926. private _transformMatrix;
  85927. private _frustumPlanes;
  85928. private _refreshFrustumPlanes;
  85929. private _storedFov;
  85930. private _stateStored;
  85931. /**
  85932. * Instantiates a new camera object.
  85933. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  85934. * @see http://doc.babylonjs.com/features/cameras
  85935. * @param name Defines the name of the camera in the scene
  85936. * @param position Defines the position of the camera
  85937. * @param scene Defines the scene the camera belongs too
  85938. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  85939. */
  85940. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  85941. /**
  85942. * Store current camera state (fov, position, etc..)
  85943. * @returns the camera
  85944. */
  85945. storeState(): Camera;
  85946. /**
  85947. * Restores the camera state values if it has been stored. You must call storeState() first
  85948. */
  85949. protected _restoreStateValues(): boolean;
  85950. /**
  85951. * Restored camera state. You must call storeState() first.
  85952. * @returns true if restored and false otherwise
  85953. */
  85954. restoreState(): boolean;
  85955. /**
  85956. * Gets the class name of the camera.
  85957. * @returns the class name
  85958. */
  85959. getClassName(): string;
  85960. /** @hidden */
  85961. readonly _isCamera: boolean;
  85962. /**
  85963. * Gets a string representation of the camera useful for debug purpose.
  85964. * @param fullDetails Defines that a more verboe level of logging is required
  85965. * @returns the string representation
  85966. */
  85967. toString(fullDetails?: boolean): string;
  85968. /**
  85969. * Gets the current world space position of the camera.
  85970. */
  85971. readonly globalPosition: Vector3;
  85972. /**
  85973. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  85974. * @returns the active meshe list
  85975. */
  85976. getActiveMeshes(): SmartArray<AbstractMesh>;
  85977. /**
  85978. * Check wether a mesh is part of the current active mesh list of the camera
  85979. * @param mesh Defines the mesh to check
  85980. * @returns true if active, false otherwise
  85981. */
  85982. isActiveMesh(mesh: Mesh): boolean;
  85983. /**
  85984. * Is this camera ready to be used/rendered
  85985. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  85986. * @return true if the camera is ready
  85987. */
  85988. isReady(completeCheck?: boolean): boolean;
  85989. /** @hidden */
  85990. _initCache(): void;
  85991. /** @hidden */
  85992. _updateCache(ignoreParentClass?: boolean): void;
  85993. /** @hidden */
  85994. _isSynchronized(): boolean;
  85995. /** @hidden */
  85996. _isSynchronizedViewMatrix(): boolean;
  85997. /** @hidden */
  85998. _isSynchronizedProjectionMatrix(): boolean;
  85999. /**
  86000. * Attach the input controls to a specific dom element to get the input from.
  86001. * @param element Defines the element the controls should be listened from
  86002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86003. */
  86004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86005. /**
  86006. * Detach the current controls from the specified dom element.
  86007. * @param element Defines the element to stop listening the inputs from
  86008. */
  86009. detachControl(element: HTMLElement): void;
  86010. /**
  86011. * Update the camera state according to the different inputs gathered during the frame.
  86012. */
  86013. update(): void;
  86014. /** @hidden */
  86015. _checkInputs(): void;
  86016. /** @hidden */
  86017. readonly rigCameras: Camera[];
  86018. /**
  86019. * Gets the post process used by the rig cameras
  86020. */
  86021. readonly rigPostProcess: Nullable<PostProcess>;
  86022. /**
  86023. * Internal, gets the first post proces.
  86024. * @returns the first post process to be run on this camera.
  86025. */
  86026. _getFirstPostProcess(): Nullable<PostProcess>;
  86027. private _cascadePostProcessesToRigCams;
  86028. /**
  86029. * Attach a post process to the camera.
  86030. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  86031. * @param postProcess The post process to attach to the camera
  86032. * @param insertAt The position of the post process in case several of them are in use in the scene
  86033. * @returns the position the post process has been inserted at
  86034. */
  86035. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  86036. /**
  86037. * Detach a post process to the camera.
  86038. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  86039. * @param postProcess The post process to detach from the camera
  86040. */
  86041. detachPostProcess(postProcess: PostProcess): void;
  86042. /**
  86043. * Gets the current world matrix of the camera
  86044. */
  86045. getWorldMatrix(): Matrix;
  86046. /** @hidden */
  86047. _getViewMatrix(): Matrix;
  86048. /**
  86049. * Gets the current view matrix of the camera.
  86050. * @param force forces the camera to recompute the matrix without looking at the cached state
  86051. * @returns the view matrix
  86052. */
  86053. getViewMatrix(force?: boolean): Matrix;
  86054. /**
  86055. * Freeze the projection matrix.
  86056. * It will prevent the cache check of the camera projection compute and can speed up perf
  86057. * if no parameter of the camera are meant to change
  86058. * @param projection Defines manually a projection if necessary
  86059. */
  86060. freezeProjectionMatrix(projection?: Matrix): void;
  86061. /**
  86062. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  86063. */
  86064. unfreezeProjectionMatrix(): void;
  86065. /**
  86066. * Gets the current projection matrix of the camera.
  86067. * @param force forces the camera to recompute the matrix without looking at the cached state
  86068. * @returns the projection matrix
  86069. */
  86070. getProjectionMatrix(force?: boolean): Matrix;
  86071. /**
  86072. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  86073. * @returns a Matrix
  86074. */
  86075. getTransformationMatrix(): Matrix;
  86076. private _updateFrustumPlanes;
  86077. /**
  86078. * Checks if a cullable object (mesh...) is in the camera frustum
  86079. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  86080. * @param target The object to check
  86081. * @returns true if the object is in frustum otherwise false
  86082. */
  86083. isInFrustum(target: ICullable): boolean;
  86084. /**
  86085. * Checks if a cullable object (mesh...) is in the camera frustum
  86086. * Unlike isInFrustum this cheks the full bounding box
  86087. * @param target The object to check
  86088. * @returns true if the object is in frustum otherwise false
  86089. */
  86090. isCompletelyInFrustum(target: ICullable): boolean;
  86091. /**
  86092. * Gets a ray in the forward direction from the camera.
  86093. * @param length Defines the length of the ray to create
  86094. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  86095. * @param origin Defines the start point of the ray which defaults to the camera position
  86096. * @returns the forward ray
  86097. */
  86098. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  86099. /**
  86100. * Releases resources associated with this node.
  86101. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  86102. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  86103. */
  86104. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  86105. /**
  86106. * Gets the left camera of a rig setup in case of Rigged Camera
  86107. */
  86108. readonly leftCamera: Nullable<FreeCamera>;
  86109. /**
  86110. * Gets the right camera of a rig setup in case of Rigged Camera
  86111. */
  86112. readonly rightCamera: Nullable<FreeCamera>;
  86113. /**
  86114. * Gets the left camera target of a rig setup in case of Rigged Camera
  86115. * @returns the target position
  86116. */
  86117. getLeftTarget(): Nullable<Vector3>;
  86118. /**
  86119. * Gets the right camera target of a rig setup in case of Rigged Camera
  86120. * @returns the target position
  86121. */
  86122. getRightTarget(): Nullable<Vector3>;
  86123. /**
  86124. * @hidden
  86125. */
  86126. setCameraRigMode(mode: number, rigParams: any): void;
  86127. /** @hidden */
  86128. static _setStereoscopicRigMode(camera: Camera): void;
  86129. /** @hidden */
  86130. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  86131. /** @hidden */
  86132. static _setVRRigMode(camera: Camera, rigParams: any): void;
  86133. /** @hidden */
  86134. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  86135. /** @hidden */
  86136. _getVRProjectionMatrix(): Matrix;
  86137. protected _updateCameraRotationMatrix(): void;
  86138. protected _updateWebVRCameraRotationMatrix(): void;
  86139. /**
  86140. * This function MUST be overwritten by the different WebVR cameras available.
  86141. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  86142. * @hidden
  86143. */
  86144. _getWebVRProjectionMatrix(): Matrix;
  86145. /**
  86146. * This function MUST be overwritten by the different WebVR cameras available.
  86147. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  86148. * @hidden
  86149. */
  86150. _getWebVRViewMatrix(): Matrix;
  86151. /** @hidden */
  86152. setCameraRigParameter(name: string, value: any): void;
  86153. /**
  86154. * needs to be overridden by children so sub has required properties to be copied
  86155. * @hidden
  86156. */
  86157. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  86158. /**
  86159. * May need to be overridden by children
  86160. * @hidden
  86161. */
  86162. _updateRigCameras(): void;
  86163. /** @hidden */
  86164. _setupInputs(): void;
  86165. /**
  86166. * Serialiaze the camera setup to a json represention
  86167. * @returns the JSON representation
  86168. */
  86169. serialize(): any;
  86170. /**
  86171. * Clones the current camera.
  86172. * @param name The cloned camera name
  86173. * @returns the cloned camera
  86174. */
  86175. clone(name: string): Camera;
  86176. /**
  86177. * Gets the direction of the camera relative to a given local axis.
  86178. * @param localAxis Defines the reference axis to provide a relative direction.
  86179. * @return the direction
  86180. */
  86181. getDirection(localAxis: Vector3): Vector3;
  86182. /**
  86183. * Gets the direction of the camera relative to a given local axis into a passed vector.
  86184. * @param localAxis Defines the reference axis to provide a relative direction.
  86185. * @param result Defines the vector to store the result in
  86186. */
  86187. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  86188. /**
  86189. * Gets a camera constructor for a given camera type
  86190. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  86191. * @param name The name of the camera the result will be able to instantiate
  86192. * @param scene The scene the result will construct the camera in
  86193. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  86194. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  86195. * @returns a factory method to construc the camera
  86196. */
  86197. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  86198. /**
  86199. * Compute the world matrix of the camera.
  86200. * @returns the camera workd matrix
  86201. */
  86202. computeWorldMatrix(): Matrix;
  86203. /**
  86204. * Parse a JSON and creates the camera from the parsed information
  86205. * @param parsedCamera The JSON to parse
  86206. * @param scene The scene to instantiate the camera in
  86207. * @returns the newly constructed camera
  86208. */
  86209. static Parse(parsedCamera: any, scene: Scene): Camera;
  86210. }
  86211. }
  86212. declare module BABYLON {
  86213. /**
  86214. * Interface for any object that can request an animation frame
  86215. */
  86216. export interface ICustomAnimationFrameRequester {
  86217. /**
  86218. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  86219. */
  86220. renderFunction?: Function;
  86221. /**
  86222. * Called to request the next frame to render to
  86223. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  86224. */
  86225. requestAnimationFrame: Function;
  86226. /**
  86227. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  86228. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  86229. */
  86230. requestID?: number;
  86231. }
  86232. /**
  86233. * Interface containing an array of animations
  86234. */
  86235. export interface IAnimatable {
  86236. /**
  86237. * Array of animations
  86238. */
  86239. animations: Array<Animation>;
  86240. }
  86241. /** Interface used by value gradients (color, factor, ...) */
  86242. export interface IValueGradient {
  86243. /**
  86244. * Gets or sets the gradient value (between 0 and 1)
  86245. */
  86246. gradient: number;
  86247. }
  86248. /** Class used to store color4 gradient */
  86249. export class ColorGradient implements IValueGradient {
  86250. /**
  86251. * Gets or sets the gradient value (between 0 and 1)
  86252. */
  86253. gradient: number;
  86254. /**
  86255. * Gets or sets first associated color
  86256. */
  86257. color1: Color4;
  86258. /**
  86259. * Gets or sets second associated color
  86260. */
  86261. color2?: Color4;
  86262. /**
  86263. * Will get a color picked randomly between color1 and color2.
  86264. * If color2 is undefined then color1 will be used
  86265. * @param result defines the target Color4 to store the result in
  86266. */
  86267. getColorToRef(result: Color4): void;
  86268. }
  86269. /** Class used to store color 3 gradient */
  86270. export class Color3Gradient implements IValueGradient {
  86271. /**
  86272. * Gets or sets the gradient value (between 0 and 1)
  86273. */
  86274. gradient: number;
  86275. /**
  86276. * Gets or sets the associated color
  86277. */
  86278. color: Color3;
  86279. }
  86280. /** Class used to store factor gradient */
  86281. export class FactorGradient implements IValueGradient {
  86282. /**
  86283. * Gets or sets the gradient value (between 0 and 1)
  86284. */
  86285. gradient: number;
  86286. /**
  86287. * Gets or sets first associated factor
  86288. */
  86289. factor1: number;
  86290. /**
  86291. * Gets or sets second associated factor
  86292. */
  86293. factor2?: number;
  86294. /**
  86295. * Will get a number picked randomly between factor1 and factor2.
  86296. * If factor2 is undefined then factor1 will be used
  86297. * @returns the picked number
  86298. */
  86299. getFactor(): number;
  86300. }
  86301. /**
  86302. * @ignore
  86303. * Application error to support additional information when loading a file
  86304. */
  86305. export class LoadFileError extends Error {
  86306. /** defines the optional XHR request */
  86307. request?: XMLHttpRequest | undefined;
  86308. private static _setPrototypeOf;
  86309. /**
  86310. * Creates a new LoadFileError
  86311. * @param message defines the message of the error
  86312. * @param request defines the optional XHR request
  86313. */
  86314. constructor(message: string,
  86315. /** defines the optional XHR request */
  86316. request?: XMLHttpRequest | undefined);
  86317. }
  86318. /**
  86319. * Class used to define a retry strategy when error happens while loading assets
  86320. */
  86321. export class RetryStrategy {
  86322. /**
  86323. * Function used to defines an exponential back off strategy
  86324. * @param maxRetries defines the maximum number of retries (3 by default)
  86325. * @param baseInterval defines the interval between retries
  86326. * @returns the strategy function to use
  86327. */
  86328. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  86329. }
  86330. /**
  86331. * File request interface
  86332. */
  86333. export interface IFileRequest {
  86334. /**
  86335. * Raised when the request is complete (success or error).
  86336. */
  86337. onCompleteObservable: Observable<IFileRequest>;
  86338. /**
  86339. * Aborts the request for a file.
  86340. */
  86341. abort: () => void;
  86342. }
  86343. /**
  86344. * Class containing a set of static utilities functions
  86345. */
  86346. export class Tools {
  86347. /**
  86348. * Gets or sets the base URL to use to load assets
  86349. */
  86350. static BaseUrl: string;
  86351. /**
  86352. * Enable/Disable Custom HTTP Request Headers globally.
  86353. * default = false
  86354. * @see CustomRequestHeaders
  86355. */
  86356. static UseCustomRequestHeaders: boolean;
  86357. /**
  86358. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  86359. * i.e. when loading files, where the server/service expects an Authorization header.
  86360. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  86361. */
  86362. static CustomRequestHeaders: {
  86363. [key: string]: string;
  86364. };
  86365. /**
  86366. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  86367. */
  86368. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  86369. /**
  86370. * Default behaviour for cors in the application.
  86371. * It can be a string if the expected behavior is identical in the entire app.
  86372. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  86373. */
  86374. static CorsBehavior: string | ((url: string | string[]) => string);
  86375. /**
  86376. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  86377. * @ignorenaming
  86378. */
  86379. static UseFallbackTexture: boolean;
  86380. /**
  86381. * Use this object to register external classes like custom textures or material
  86382. * to allow the laoders to instantiate them
  86383. */
  86384. static RegisteredExternalClasses: {
  86385. [key: string]: Object;
  86386. };
  86387. /**
  86388. * Texture content used if a texture cannot loaded
  86389. * @ignorenaming
  86390. */
  86391. static fallbackTexture: string;
  86392. /**
  86393. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  86394. * @param u defines the coordinate on X axis
  86395. * @param v defines the coordinate on Y axis
  86396. * @param width defines the width of the source data
  86397. * @param height defines the height of the source data
  86398. * @param pixels defines the source byte array
  86399. * @param color defines the output color
  86400. */
  86401. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  86402. /**
  86403. * Interpolates between a and b via alpha
  86404. * @param a The lower value (returned when alpha = 0)
  86405. * @param b The upper value (returned when alpha = 1)
  86406. * @param alpha The interpolation-factor
  86407. * @return The mixed value
  86408. */
  86409. static Mix(a: number, b: number, alpha: number): number;
  86410. /**
  86411. * Tries to instantiate a new object from a given class name
  86412. * @param className defines the class name to instantiate
  86413. * @returns the new object or null if the system was not able to do the instantiation
  86414. */
  86415. static Instantiate(className: string): any;
  86416. /**
  86417. * Provides a slice function that will work even on IE
  86418. * @param data defines the array to slice
  86419. * @param start defines the start of the data (optional)
  86420. * @param end defines the end of the data (optional)
  86421. * @returns the new sliced array
  86422. */
  86423. static Slice<T>(data: T, start?: number, end?: number): T;
  86424. /**
  86425. * Polyfill for setImmediate
  86426. * @param action defines the action to execute after the current execution block
  86427. */
  86428. static SetImmediate(action: () => void): void;
  86429. /**
  86430. * Function indicating if a number is an exponent of 2
  86431. * @param value defines the value to test
  86432. * @returns true if the value is an exponent of 2
  86433. */
  86434. static IsExponentOfTwo(value: number): boolean;
  86435. private static _tmpFloatArray;
  86436. /**
  86437. * Returns the nearest 32-bit single precision float representation of a Number
  86438. * @param value A Number. If the parameter is of a different type, it will get converted
  86439. * to a number or to NaN if it cannot be converted
  86440. * @returns number
  86441. */
  86442. static FloatRound(value: number): number;
  86443. /**
  86444. * Find the next highest power of two.
  86445. * @param x Number to start search from.
  86446. * @return Next highest power of two.
  86447. */
  86448. static CeilingPOT(x: number): number;
  86449. /**
  86450. * Find the next lowest power of two.
  86451. * @param x Number to start search from.
  86452. * @return Next lowest power of two.
  86453. */
  86454. static FloorPOT(x: number): number;
  86455. /**
  86456. * Find the nearest power of two.
  86457. * @param x Number to start search from.
  86458. * @return Next nearest power of two.
  86459. */
  86460. static NearestPOT(x: number): number;
  86461. /**
  86462. * Get the closest exponent of two
  86463. * @param value defines the value to approximate
  86464. * @param max defines the maximum value to return
  86465. * @param mode defines how to define the closest value
  86466. * @returns closest exponent of two of the given value
  86467. */
  86468. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  86469. /**
  86470. * Extracts the filename from a path
  86471. * @param path defines the path to use
  86472. * @returns the filename
  86473. */
  86474. static GetFilename(path: string): string;
  86475. /**
  86476. * Extracts the "folder" part of a path (everything before the filename).
  86477. * @param uri The URI to extract the info from
  86478. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  86479. * @returns The "folder" part of the path
  86480. */
  86481. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  86482. /**
  86483. * Extracts text content from a DOM element hierarchy
  86484. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  86485. */
  86486. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  86487. /**
  86488. * Convert an angle in radians to degrees
  86489. * @param angle defines the angle to convert
  86490. * @returns the angle in degrees
  86491. */
  86492. static ToDegrees(angle: number): number;
  86493. /**
  86494. * Convert an angle in degrees to radians
  86495. * @param angle defines the angle to convert
  86496. * @returns the angle in radians
  86497. */
  86498. static ToRadians(angle: number): number;
  86499. /**
  86500. * Encode a buffer to a base64 string
  86501. * @param buffer defines the buffer to encode
  86502. * @returns the encoded string
  86503. */
  86504. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  86505. /**
  86506. * Extracts minimum and maximum values from a list of indexed positions
  86507. * @param positions defines the positions to use
  86508. * @param indices defines the indices to the positions
  86509. * @param indexStart defines the start index
  86510. * @param indexCount defines the end index
  86511. * @param bias defines bias value to add to the result
  86512. * @return minimum and maximum values
  86513. */
  86514. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  86515. minimum: Vector3;
  86516. maximum: Vector3;
  86517. };
  86518. /**
  86519. * Extracts minimum and maximum values from a list of positions
  86520. * @param positions defines the positions to use
  86521. * @param start defines the start index in the positions array
  86522. * @param count defines the number of positions to handle
  86523. * @param bias defines bias value to add to the result
  86524. * @param stride defines the stride size to use (distance between two positions in the positions array)
  86525. * @return minimum and maximum values
  86526. */
  86527. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  86528. minimum: Vector3;
  86529. maximum: Vector3;
  86530. };
  86531. /**
  86532. * Returns an array if obj is not an array
  86533. * @param obj defines the object to evaluate as an array
  86534. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  86535. * @returns either obj directly if obj is an array or a new array containing obj
  86536. */
  86537. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  86538. /**
  86539. * Gets the pointer prefix to use
  86540. * @returns "pointer" if touch is enabled. Else returns "mouse"
  86541. */
  86542. static GetPointerPrefix(): string;
  86543. /**
  86544. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  86545. * @param func - the function to be called
  86546. * @param requester - the object that will request the next frame. Falls back to window.
  86547. * @returns frame number
  86548. */
  86549. static QueueNewFrame(func: () => void, requester?: any): number;
  86550. /**
  86551. * Ask the browser to promote the current element to fullscreen rendering mode
  86552. * @param element defines the DOM element to promote
  86553. */
  86554. static RequestFullscreen(element: HTMLElement): void;
  86555. /**
  86556. * Asks the browser to exit fullscreen mode
  86557. */
  86558. static ExitFullscreen(): void;
  86559. /**
  86560. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  86561. * @param url define the url we are trying
  86562. * @param element define the dom element where to configure the cors policy
  86563. */
  86564. static SetCorsBehavior(url: string | string[], element: {
  86565. crossOrigin: string | null;
  86566. }): void;
  86567. /**
  86568. * Removes unwanted characters from an url
  86569. * @param url defines the url to clean
  86570. * @returns the cleaned url
  86571. */
  86572. static CleanUrl(url: string): string;
  86573. /**
  86574. * Gets or sets a function used to pre-process url before using them to load assets
  86575. */
  86576. static PreprocessUrl: (url: string) => string;
  86577. /**
  86578. * Loads an image as an HTMLImageElement.
  86579. * @param input url string, ArrayBuffer, or Blob to load
  86580. * @param onLoad callback called when the image successfully loads
  86581. * @param onError callback called when the image fails to load
  86582. * @param offlineProvider offline provider for caching
  86583. * @returns the HTMLImageElement of the loaded image
  86584. */
  86585. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  86586. /**
  86587. * Loads a file
  86588. * @param url url string, ArrayBuffer, or Blob to load
  86589. * @param onSuccess callback called when the file successfully loads
  86590. * @param onProgress callback called while file is loading (if the server supports this mode)
  86591. * @param offlineProvider defines the offline provider for caching
  86592. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  86593. * @param onError callback called when the file fails to load
  86594. * @returns a file request object
  86595. */
  86596. 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;
  86597. /**
  86598. * Load a script (identified by an url). When the url returns, the
  86599. * content of this file is added into a new script element, attached to the DOM (body element)
  86600. * @param scriptUrl defines the url of the script to laod
  86601. * @param onSuccess defines the callback called when the script is loaded
  86602. * @param onError defines the callback to call if an error occurs
  86603. */
  86604. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  86605. /**
  86606. * Loads a file from a blob
  86607. * @param fileToLoad defines the blob to use
  86608. * @param callback defines the callback to call when data is loaded
  86609. * @param progressCallback defines the callback to call during loading process
  86610. * @returns a file request object
  86611. */
  86612. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  86613. /**
  86614. * Loads a file
  86615. * @param fileToLoad defines the file to load
  86616. * @param callback defines the callback to call when data is loaded
  86617. * @param progressCallBack defines the callback to call during loading process
  86618. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  86619. * @returns a file request object
  86620. */
  86621. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  86622. /**
  86623. * Creates a data url from a given string content
  86624. * @param content defines the content to convert
  86625. * @returns the new data url link
  86626. */
  86627. static FileAsURL(content: string): string;
  86628. /**
  86629. * Format the given number to a specific decimal format
  86630. * @param value defines the number to format
  86631. * @param decimals defines the number of decimals to use
  86632. * @returns the formatted string
  86633. */
  86634. static Format(value: number, decimals?: number): string;
  86635. /**
  86636. * Checks if a given vector is inside a specific range
  86637. * @param v defines the vector to test
  86638. * @param min defines the minimum range
  86639. * @param max defines the maximum range
  86640. */
  86641. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  86642. /**
  86643. * Tries to copy an object by duplicating every property
  86644. * @param source defines the source object
  86645. * @param destination defines the target object
  86646. * @param doNotCopyList defines a list of properties to avoid
  86647. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  86648. */
  86649. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  86650. /**
  86651. * Gets a boolean indicating if the given object has no own property
  86652. * @param obj defines the object to test
  86653. * @returns true if object has no own property
  86654. */
  86655. static IsEmpty(obj: any): boolean;
  86656. /**
  86657. * Function used to register events at window level
  86658. * @param events defines the events to register
  86659. */
  86660. static RegisterTopRootEvents(events: {
  86661. name: string;
  86662. handler: Nullable<(e: FocusEvent) => any>;
  86663. }[]): void;
  86664. /**
  86665. * Function used to unregister events from window level
  86666. * @param events defines the events to unregister
  86667. */
  86668. static UnregisterTopRootEvents(events: {
  86669. name: string;
  86670. handler: Nullable<(e: FocusEvent) => any>;
  86671. }[]): void;
  86672. /**
  86673. * Dumps the current bound framebuffer
  86674. * @param width defines the rendering width
  86675. * @param height defines the rendering height
  86676. * @param engine defines the hosting engine
  86677. * @param successCallback defines the callback triggered once the data are available
  86678. * @param mimeType defines the mime type of the result
  86679. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  86680. */
  86681. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  86682. /**
  86683. * Converts the canvas data to blob.
  86684. * This acts as a polyfill for browsers not supporting the to blob function.
  86685. * @param canvas Defines the canvas to extract the data from
  86686. * @param successCallback Defines the callback triggered once the data are available
  86687. * @param mimeType Defines the mime type of the result
  86688. */
  86689. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  86690. /**
  86691. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  86692. * @param successCallback defines the callback triggered once the data are available
  86693. * @param mimeType defines the mime type of the result
  86694. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  86695. */
  86696. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  86697. /**
  86698. * Downloads a blob in the browser
  86699. * @param blob defines the blob to download
  86700. * @param fileName defines the name of the downloaded file
  86701. */
  86702. static Download(blob: Blob, fileName: string): void;
  86703. /**
  86704. * Captures a screenshot of the current rendering
  86705. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  86706. * @param engine defines the rendering engine
  86707. * @param camera defines the source camera
  86708. * @param size This parameter can be set to a single number or to an object with the
  86709. * following (optional) properties: precision, width, height. If a single number is passed,
  86710. * it will be used for both width and height. If an object is passed, the screenshot size
  86711. * will be derived from the parameters. The precision property is a multiplier allowing
  86712. * rendering at a higher or lower resolution
  86713. * @param successCallback defines the callback receives a single parameter which contains the
  86714. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  86715. * src parameter of an <img> to display it
  86716. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  86717. * Check your browser for supported MIME types
  86718. */
  86719. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  86720. /**
  86721. * Generates an image screenshot from the specified camera.
  86722. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  86723. * @param engine The engine to use for rendering
  86724. * @param camera The camera to use for rendering
  86725. * @param size This parameter can be set to a single number or to an object with the
  86726. * following (optional) properties: precision, width, height. If a single number is passed,
  86727. * it will be used for both width and height. If an object is passed, the screenshot size
  86728. * will be derived from the parameters. The precision property is a multiplier allowing
  86729. * rendering at a higher or lower resolution
  86730. * @param successCallback The callback receives a single parameter which contains the
  86731. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  86732. * src parameter of an <img> to display it
  86733. * @param mimeType The MIME type of the screenshot image (default: image/png).
  86734. * Check your browser for supported MIME types
  86735. * @param samples Texture samples (default: 1)
  86736. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  86737. * @param fileName A name for for the downloaded file.
  86738. */
  86739. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  86740. /**
  86741. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86742. * Be aware Math.random() could cause collisions, but:
  86743. * "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"
  86744. * @returns a pseudo random id
  86745. */
  86746. static RandomId(): string;
  86747. /**
  86748. * Test if the given uri is a base64 string
  86749. * @param uri The uri to test
  86750. * @return True if the uri is a base64 string or false otherwise
  86751. */
  86752. static IsBase64(uri: string): boolean;
  86753. /**
  86754. * Decode the given base64 uri.
  86755. * @param uri The uri to decode
  86756. * @return The decoded base64 data.
  86757. */
  86758. static DecodeBase64(uri: string): ArrayBuffer;
  86759. /**
  86760. * No log
  86761. */
  86762. static readonly NoneLogLevel: number;
  86763. /**
  86764. * Only message logs
  86765. */
  86766. static readonly MessageLogLevel: number;
  86767. /**
  86768. * Only warning logs
  86769. */
  86770. static readonly WarningLogLevel: number;
  86771. /**
  86772. * Only error logs
  86773. */
  86774. static readonly ErrorLogLevel: number;
  86775. /**
  86776. * All logs
  86777. */
  86778. static readonly AllLogLevel: number;
  86779. /**
  86780. * Gets a value indicating the number of loading errors
  86781. * @ignorenaming
  86782. */
  86783. static readonly errorsCount: number;
  86784. /**
  86785. * Callback called when a new log is added
  86786. */
  86787. static OnNewCacheEntry: (entry: string) => void;
  86788. /**
  86789. * Log a message to the console
  86790. * @param message defines the message to log
  86791. */
  86792. static Log(message: string): void;
  86793. /**
  86794. * Write a warning message to the console
  86795. * @param message defines the message to log
  86796. */
  86797. static Warn(message: string): void;
  86798. /**
  86799. * Write an error message to the console
  86800. * @param message defines the message to log
  86801. */
  86802. static Error(message: string): void;
  86803. /**
  86804. * Gets current log cache (list of logs)
  86805. */
  86806. static readonly LogCache: string;
  86807. /**
  86808. * Clears the log cache
  86809. */
  86810. static ClearLogCache(): void;
  86811. /**
  86812. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  86813. */
  86814. static LogLevels: number;
  86815. /**
  86816. * Checks if the loaded document was accessed via `file:`-Protocol.
  86817. * @returns boolean
  86818. */
  86819. static IsFileURL(): boolean;
  86820. /**
  86821. * Checks if the window object exists
  86822. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  86823. */
  86824. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  86825. /**
  86826. * No performance log
  86827. */
  86828. static readonly PerformanceNoneLogLevel: number;
  86829. /**
  86830. * Use user marks to log performance
  86831. */
  86832. static readonly PerformanceUserMarkLogLevel: number;
  86833. /**
  86834. * Log performance to the console
  86835. */
  86836. static readonly PerformanceConsoleLogLevel: number;
  86837. private static _performance;
  86838. /**
  86839. * Sets the current performance log level
  86840. */
  86841. static PerformanceLogLevel: number;
  86842. private static _StartPerformanceCounterDisabled;
  86843. private static _EndPerformanceCounterDisabled;
  86844. private static _StartUserMark;
  86845. private static _EndUserMark;
  86846. private static _StartPerformanceConsole;
  86847. private static _EndPerformanceConsole;
  86848. /**
  86849. * Injects the @see CustomRequestHeaders into the given request
  86850. * @param request the request that should be used for injection
  86851. */
  86852. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  86853. /**
  86854. * Starts a performance counter
  86855. */
  86856. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  86857. /**
  86858. * Ends a specific performance coutner
  86859. */
  86860. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  86861. /**
  86862. * Gets either window.performance.now() if supported or Date.now() else
  86863. */
  86864. static readonly Now: number;
  86865. /**
  86866. * This method will return the name of the class used to create the instance of the given object.
  86867. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  86868. * @param object the object to get the class name from
  86869. * @param isType defines if the object is actually a type
  86870. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  86871. */
  86872. static GetClassName(object: any, isType?: boolean): string;
  86873. /**
  86874. * Gets the first element of an array satisfying a given predicate
  86875. * @param array defines the array to browse
  86876. * @param predicate defines the predicate to use
  86877. * @returns null if not found or the element
  86878. */
  86879. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  86880. /**
  86881. * This method will return the name of the full name of the class, including its owning module (if any).
  86882. * 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).
  86883. * @param object the object to get the class name from
  86884. * @param isType defines if the object is actually a type
  86885. * @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.
  86886. * @ignorenaming
  86887. */
  86888. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  86889. /**
  86890. * Returns a promise that resolves after the given amount of time.
  86891. * @param delay Number of milliseconds to delay
  86892. * @returns Promise that resolves after the given amount of time
  86893. */
  86894. static DelayAsync(delay: number): Promise<void>;
  86895. /**
  86896. * Gets the current gradient from an array of IValueGradient
  86897. * @param ratio defines the current ratio to get
  86898. * @param gradients defines the array of IValueGradient
  86899. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  86900. */
  86901. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  86902. }
  86903. /**
  86904. * This class is used to track a performance counter which is number based.
  86905. * The user has access to many properties which give statistics of different nature.
  86906. *
  86907. * The implementer can track two kinds of Performance Counter: time and count.
  86908. * 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.
  86909. * 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.
  86910. */
  86911. export class PerfCounter {
  86912. /**
  86913. * Gets or sets a global boolean to turn on and off all the counters
  86914. */
  86915. static Enabled: boolean;
  86916. /**
  86917. * Returns the smallest value ever
  86918. */
  86919. readonly min: number;
  86920. /**
  86921. * Returns the biggest value ever
  86922. */
  86923. readonly max: number;
  86924. /**
  86925. * Returns the average value since the performance counter is running
  86926. */
  86927. readonly average: number;
  86928. /**
  86929. * Returns the average value of the last second the counter was monitored
  86930. */
  86931. readonly lastSecAverage: number;
  86932. /**
  86933. * Returns the current value
  86934. */
  86935. readonly current: number;
  86936. /**
  86937. * Gets the accumulated total
  86938. */
  86939. readonly total: number;
  86940. /**
  86941. * Gets the total value count
  86942. */
  86943. readonly count: number;
  86944. /**
  86945. * Creates a new counter
  86946. */
  86947. constructor();
  86948. /**
  86949. * Call this method to start monitoring a new frame.
  86950. * 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.
  86951. */
  86952. fetchNewFrame(): void;
  86953. /**
  86954. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  86955. * @param newCount the count value to add to the monitored count
  86956. * @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.
  86957. */
  86958. addCount(newCount: number, fetchResult: boolean): void;
  86959. /**
  86960. * Start monitoring this performance counter
  86961. */
  86962. beginMonitoring(): void;
  86963. /**
  86964. * Compute the time lapsed since the previous beginMonitoring() call.
  86965. * @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
  86966. */
  86967. endMonitoring(newFrame?: boolean): void;
  86968. private _fetchResult;
  86969. private _startMonitoringTime;
  86970. private _min;
  86971. private _max;
  86972. private _average;
  86973. private _current;
  86974. private _totalValueCount;
  86975. private _totalAccumulated;
  86976. private _lastSecAverage;
  86977. private _lastSecAccumulated;
  86978. private _lastSecTime;
  86979. private _lastSecValueCount;
  86980. }
  86981. /**
  86982. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  86983. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  86984. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  86985. * @param name The name of the class, case should be preserved
  86986. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  86987. */
  86988. export function className(name: string, module?: string): (target: Object) => void;
  86989. /**
  86990. * An implementation of a loop for asynchronous functions.
  86991. */
  86992. export class AsyncLoop {
  86993. /**
  86994. * Defines the number of iterations for the loop
  86995. */
  86996. iterations: number;
  86997. /**
  86998. * Defines the current index of the loop.
  86999. */
  87000. index: number;
  87001. private _done;
  87002. private _fn;
  87003. private _successCallback;
  87004. /**
  87005. * Constructor.
  87006. * @param iterations the number of iterations.
  87007. * @param func the function to run each iteration
  87008. * @param successCallback the callback that will be called upon succesful execution
  87009. * @param offset starting offset.
  87010. */
  87011. constructor(
  87012. /**
  87013. * Defines the number of iterations for the loop
  87014. */
  87015. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  87016. /**
  87017. * Execute the next iteration. Must be called after the last iteration was finished.
  87018. */
  87019. executeNext(): void;
  87020. /**
  87021. * Break the loop and run the success callback.
  87022. */
  87023. breakLoop(): void;
  87024. /**
  87025. * Create and run an async loop.
  87026. * @param iterations the number of iterations.
  87027. * @param fn the function to run each iteration
  87028. * @param successCallback the callback that will be called upon succesful execution
  87029. * @param offset starting offset.
  87030. * @returns the created async loop object
  87031. */
  87032. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  87033. /**
  87034. * A for-loop that will run a given number of iterations synchronous and the rest async.
  87035. * @param iterations total number of iterations
  87036. * @param syncedIterations number of synchronous iterations in each async iteration.
  87037. * @param fn the function to call each iteration.
  87038. * @param callback a success call back that will be called when iterating stops.
  87039. * @param breakFunction a break condition (optional)
  87040. * @param timeout timeout settings for the setTimeout function. default - 0.
  87041. * @returns the created async loop object
  87042. */
  87043. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  87044. }
  87045. }
  87046. declare module BABYLON {
  87047. /** @hidden */
  87048. export interface ICollisionCoordinator {
  87049. createCollider(): Collider;
  87050. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  87051. init(scene: Scene): void;
  87052. }
  87053. /** @hidden */
  87054. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  87055. private _scene;
  87056. private _scaledPosition;
  87057. private _scaledVelocity;
  87058. private _finalPosition;
  87059. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  87060. createCollider(): Collider;
  87061. init(scene: Scene): void;
  87062. private _collideWithWorld;
  87063. }
  87064. }
  87065. declare module BABYLON {
  87066. /**
  87067. * This class defines the direct association between an animation and a target
  87068. */
  87069. export class TargetedAnimation {
  87070. /**
  87071. * Animation to perform
  87072. */
  87073. animation: Animation;
  87074. /**
  87075. * Target to animate
  87076. */
  87077. target: any;
  87078. }
  87079. /**
  87080. * Use this class to create coordinated animations on multiple targets
  87081. */
  87082. export class AnimationGroup implements IDisposable {
  87083. /** The name of the animation group */
  87084. name: string;
  87085. private _scene;
  87086. private _targetedAnimations;
  87087. private _animatables;
  87088. private _from;
  87089. private _to;
  87090. private _isStarted;
  87091. private _isPaused;
  87092. private _speedRatio;
  87093. /**
  87094. * Gets or sets the unique id of the node
  87095. */
  87096. uniqueId: number;
  87097. /**
  87098. * This observable will notify when one animation have ended
  87099. */
  87100. onAnimationEndObservable: Observable<TargetedAnimation>;
  87101. /**
  87102. * Observer raised when one animation loops
  87103. */
  87104. onAnimationLoopObservable: Observable<TargetedAnimation>;
  87105. /**
  87106. * This observable will notify when all animations have ended.
  87107. */
  87108. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  87109. /**
  87110. * This observable will notify when all animations have paused.
  87111. */
  87112. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  87113. /**
  87114. * This observable will notify when all animations are playing.
  87115. */
  87116. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  87117. /**
  87118. * Gets the first frame
  87119. */
  87120. readonly from: number;
  87121. /**
  87122. * Gets the last frame
  87123. */
  87124. readonly to: number;
  87125. /**
  87126. * Define if the animations are started
  87127. */
  87128. readonly isStarted: boolean;
  87129. /**
  87130. * Gets a value indicating that the current group is playing
  87131. */
  87132. readonly isPlaying: boolean;
  87133. /**
  87134. * Gets or sets the speed ratio to use for all animations
  87135. */
  87136. /**
  87137. * Gets or sets the speed ratio to use for all animations
  87138. */
  87139. speedRatio: number;
  87140. /**
  87141. * Gets the targeted animations for this animation group
  87142. */
  87143. readonly targetedAnimations: Array<TargetedAnimation>;
  87144. /**
  87145. * returning the list of animatables controlled by this animation group.
  87146. */
  87147. readonly animatables: Array<Animatable>;
  87148. /**
  87149. * Instantiates a new Animation Group.
  87150. * This helps managing several animations at once.
  87151. * @see http://doc.babylonjs.com/how_to/group
  87152. * @param name Defines the name of the group
  87153. * @param scene Defines the scene the group belongs to
  87154. */
  87155. constructor(
  87156. /** The name of the animation group */
  87157. name: string, scene?: Nullable<Scene>);
  87158. /**
  87159. * Add an animation (with its target) in the group
  87160. * @param animation defines the animation we want to add
  87161. * @param target defines the target of the animation
  87162. * @returns the TargetedAnimation object
  87163. */
  87164. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  87165. /**
  87166. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  87167. * It can add constant keys at begin or end
  87168. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  87169. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  87170. * @returns the animation group
  87171. */
  87172. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  87173. /**
  87174. * Start all animations on given targets
  87175. * @param loop defines if animations must loop
  87176. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  87177. * @param from defines the from key (optional)
  87178. * @param to defines the to key (optional)
  87179. * @returns the current animation group
  87180. */
  87181. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  87182. /**
  87183. * Pause all animations
  87184. * @returns the animation group
  87185. */
  87186. pause(): AnimationGroup;
  87187. /**
  87188. * Play all animations to initial state
  87189. * This function will start() the animations if they were not started or will restart() them if they were paused
  87190. * @param loop defines if animations must loop
  87191. * @returns the animation group
  87192. */
  87193. play(loop?: boolean): AnimationGroup;
  87194. /**
  87195. * Reset all animations to initial state
  87196. * @returns the animation group
  87197. */
  87198. reset(): AnimationGroup;
  87199. /**
  87200. * Restart animations from key 0
  87201. * @returns the animation group
  87202. */
  87203. restart(): AnimationGroup;
  87204. /**
  87205. * Stop all animations
  87206. * @returns the animation group
  87207. */
  87208. stop(): AnimationGroup;
  87209. /**
  87210. * Set animation weight for all animatables
  87211. * @param weight defines the weight to use
  87212. * @return the animationGroup
  87213. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  87214. */
  87215. setWeightForAllAnimatables(weight: number): AnimationGroup;
  87216. /**
  87217. * Synchronize and normalize all animatables with a source animatable
  87218. * @param root defines the root animatable to synchronize with
  87219. * @return the animationGroup
  87220. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  87221. */
  87222. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  87223. /**
  87224. * Goes to a specific frame in this animation group
  87225. * @param frame the frame number to go to
  87226. * @return the animationGroup
  87227. */
  87228. goToFrame(frame: number): AnimationGroup;
  87229. /**
  87230. * Dispose all associated resources
  87231. */
  87232. dispose(): void;
  87233. private _checkAnimationGroupEnded;
  87234. /**
  87235. * Returns a new AnimationGroup object parsed from the source provided.
  87236. * @param parsedAnimationGroup defines the source
  87237. * @param scene defines the scene that will receive the animationGroup
  87238. * @returns a new AnimationGroup
  87239. */
  87240. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  87241. /**
  87242. * Returns the string "AnimationGroup"
  87243. * @returns "AnimationGroup"
  87244. */
  87245. getClassName(): string;
  87246. /**
  87247. * Creates a detailled string about the object
  87248. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  87249. * @returns a string representing the object
  87250. */
  87251. toString(fullDetails?: boolean): string;
  87252. }
  87253. }
  87254. declare module BABYLON {
  87255. /**
  87256. * Define an interface for all classes that will hold resources
  87257. */
  87258. export interface IDisposable {
  87259. /**
  87260. * Releases all held resources
  87261. */
  87262. dispose(): void;
  87263. }
  87264. /** Interface defining initialization parameters for Scene class */
  87265. export interface SceneOptions {
  87266. /**
  87267. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  87268. * It will improve performance when the number of geometries becomes important.
  87269. */
  87270. useGeometryUniqueIdsMap?: boolean;
  87271. /**
  87272. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  87273. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  87274. */
  87275. useMaterialMeshMap?: boolean;
  87276. /**
  87277. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  87278. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  87279. */
  87280. useClonedMeshhMap?: boolean;
  87281. }
  87282. /**
  87283. * Represents a scene to be rendered by the engine.
  87284. * @see http://doc.babylonjs.com/features/scene
  87285. */
  87286. export class Scene extends AbstractScene implements IAnimatable {
  87287. private static _uniqueIdCounter;
  87288. /** The fog is deactivated */
  87289. static readonly FOGMODE_NONE: number;
  87290. /** The fog density is following an exponential function */
  87291. static readonly FOGMODE_EXP: number;
  87292. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  87293. static readonly FOGMODE_EXP2: number;
  87294. /** The fog density is following a linear function. */
  87295. static readonly FOGMODE_LINEAR: number;
  87296. /**
  87297. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  87298. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87299. */
  87300. static MinDeltaTime: number;
  87301. /**
  87302. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  87303. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87304. */
  87305. static MaxDeltaTime: number;
  87306. /**
  87307. * Factory used to create the default material.
  87308. * @param name The name of the material to create
  87309. * @param scene The scene to create the material for
  87310. * @returns The default material
  87311. */
  87312. static DefaultMaterialFactory(scene: Scene): Material;
  87313. /**
  87314. * Factory used to create the a collision coordinator.
  87315. * @returns The collision coordinator
  87316. */
  87317. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  87318. /** @hidden */
  87319. readonly _isScene: boolean;
  87320. /**
  87321. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  87322. */
  87323. autoClear: boolean;
  87324. /**
  87325. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  87326. */
  87327. autoClearDepthAndStencil: boolean;
  87328. /**
  87329. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  87330. */
  87331. clearColor: Color4;
  87332. /**
  87333. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  87334. */
  87335. ambientColor: Color3;
  87336. /** @hidden */
  87337. _environmentBRDFTexture: BaseTexture;
  87338. /** @hidden */
  87339. protected _environmentTexture: Nullable<BaseTexture>;
  87340. /**
  87341. * Texture used in all pbr material as the reflection texture.
  87342. * As in the majority of the scene they are the same (exception for multi room and so on),
  87343. * this is easier to reference from here than from all the materials.
  87344. */
  87345. /**
  87346. * Texture used in all pbr material as the reflection texture.
  87347. * As in the majority of the scene they are the same (exception for multi room and so on),
  87348. * this is easier to set here than in all the materials.
  87349. */
  87350. environmentTexture: Nullable<BaseTexture>;
  87351. /** @hidden */
  87352. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87353. /**
  87354. * Default image processing configuration used either in the rendering
  87355. * Forward main pass or through the imageProcessingPostProcess if present.
  87356. * As in the majority of the scene they are the same (exception for multi camera),
  87357. * this is easier to reference from here than from all the materials and post process.
  87358. *
  87359. * No setter as we it is a shared configuration, you can set the values instead.
  87360. */
  87361. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  87362. private _forceWireframe;
  87363. /**
  87364. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  87365. */
  87366. forceWireframe: boolean;
  87367. private _forcePointsCloud;
  87368. /**
  87369. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  87370. */
  87371. forcePointsCloud: boolean;
  87372. /**
  87373. * Gets or sets the active clipplane 1
  87374. */
  87375. clipPlane: Nullable<Plane>;
  87376. /**
  87377. * Gets or sets the active clipplane 2
  87378. */
  87379. clipPlane2: Nullable<Plane>;
  87380. /**
  87381. * Gets or sets the active clipplane 3
  87382. */
  87383. clipPlane3: Nullable<Plane>;
  87384. /**
  87385. * Gets or sets the active clipplane 4
  87386. */
  87387. clipPlane4: Nullable<Plane>;
  87388. /**
  87389. * Gets or sets a boolean indicating if animations are enabled
  87390. */
  87391. animationsEnabled: boolean;
  87392. private _animationPropertiesOverride;
  87393. /**
  87394. * Gets or sets the animation properties override
  87395. */
  87396. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87397. /**
  87398. * Gets or sets a boolean indicating if a constant deltatime has to be used
  87399. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  87400. */
  87401. useConstantAnimationDeltaTime: boolean;
  87402. /**
  87403. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  87404. * Please note that it requires to run a ray cast through the scene on every frame
  87405. */
  87406. constantlyUpdateMeshUnderPointer: boolean;
  87407. /**
  87408. * Defines the HTML cursor to use when hovering over interactive elements
  87409. */
  87410. hoverCursor: string;
  87411. /**
  87412. * Defines the HTML default cursor to use (empty by default)
  87413. */
  87414. defaultCursor: string;
  87415. /**
  87416. * This is used to call preventDefault() on pointer down
  87417. * in order to block unwanted artifacts like system double clicks
  87418. */
  87419. preventDefaultOnPointerDown: boolean;
  87420. /**
  87421. * This is used to call preventDefault() on pointer up
  87422. * in order to block unwanted artifacts like system double clicks
  87423. */
  87424. preventDefaultOnPointerUp: boolean;
  87425. /**
  87426. * Gets or sets user defined metadata
  87427. */
  87428. metadata: any;
  87429. /**
  87430. * For internal use only. Please do not use.
  87431. */
  87432. reservedDataStore: any;
  87433. /**
  87434. * Gets the name of the plugin used to load this scene (null by default)
  87435. */
  87436. loadingPluginName: string;
  87437. /**
  87438. * Use this array to add regular expressions used to disable offline support for specific urls
  87439. */
  87440. disableOfflineSupportExceptionRules: RegExp[];
  87441. /**
  87442. * An event triggered when the scene is disposed.
  87443. */
  87444. onDisposeObservable: Observable<Scene>;
  87445. private _onDisposeObserver;
  87446. /** Sets a function to be executed when this scene is disposed. */
  87447. onDispose: () => void;
  87448. /**
  87449. * An event triggered before rendering the scene (right after animations and physics)
  87450. */
  87451. onBeforeRenderObservable: Observable<Scene>;
  87452. private _onBeforeRenderObserver;
  87453. /** Sets a function to be executed before rendering this scene */
  87454. beforeRender: Nullable<() => void>;
  87455. /**
  87456. * An event triggered after rendering the scene
  87457. */
  87458. onAfterRenderObservable: Observable<Scene>;
  87459. private _onAfterRenderObserver;
  87460. /** Sets a function to be executed after rendering this scene */
  87461. afterRender: Nullable<() => void>;
  87462. /**
  87463. * An event triggered before animating the scene
  87464. */
  87465. onBeforeAnimationsObservable: Observable<Scene>;
  87466. /**
  87467. * An event triggered after animations processing
  87468. */
  87469. onAfterAnimationsObservable: Observable<Scene>;
  87470. /**
  87471. * An event triggered before draw calls are ready to be sent
  87472. */
  87473. onBeforeDrawPhaseObservable: Observable<Scene>;
  87474. /**
  87475. * An event triggered after draw calls have been sent
  87476. */
  87477. onAfterDrawPhaseObservable: Observable<Scene>;
  87478. /**
  87479. * An event triggered when the scene is ready
  87480. */
  87481. onReadyObservable: Observable<Scene>;
  87482. /**
  87483. * An event triggered before rendering a camera
  87484. */
  87485. onBeforeCameraRenderObservable: Observable<Camera>;
  87486. private _onBeforeCameraRenderObserver;
  87487. /** Sets a function to be executed before rendering a camera*/
  87488. beforeCameraRender: () => void;
  87489. /**
  87490. * An event triggered after rendering a camera
  87491. */
  87492. onAfterCameraRenderObservable: Observable<Camera>;
  87493. private _onAfterCameraRenderObserver;
  87494. /** Sets a function to be executed after rendering a camera*/
  87495. afterCameraRender: () => void;
  87496. /**
  87497. * An event triggered when active meshes evaluation is about to start
  87498. */
  87499. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  87500. /**
  87501. * An event triggered when active meshes evaluation is done
  87502. */
  87503. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  87504. /**
  87505. * An event triggered when particles rendering is about to start
  87506. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  87507. */
  87508. onBeforeParticlesRenderingObservable: Observable<Scene>;
  87509. /**
  87510. * An event triggered when particles rendering is done
  87511. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  87512. */
  87513. onAfterParticlesRenderingObservable: Observable<Scene>;
  87514. /**
  87515. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  87516. */
  87517. onDataLoadedObservable: Observable<Scene>;
  87518. /**
  87519. * An event triggered when a camera is created
  87520. */
  87521. onNewCameraAddedObservable: Observable<Camera>;
  87522. /**
  87523. * An event triggered when a camera is removed
  87524. */
  87525. onCameraRemovedObservable: Observable<Camera>;
  87526. /**
  87527. * An event triggered when a light is created
  87528. */
  87529. onNewLightAddedObservable: Observable<Light>;
  87530. /**
  87531. * An event triggered when a light is removed
  87532. */
  87533. onLightRemovedObservable: Observable<Light>;
  87534. /**
  87535. * An event triggered when a geometry is created
  87536. */
  87537. onNewGeometryAddedObservable: Observable<Geometry>;
  87538. /**
  87539. * An event triggered when a geometry is removed
  87540. */
  87541. onGeometryRemovedObservable: Observable<Geometry>;
  87542. /**
  87543. * An event triggered when a transform node is created
  87544. */
  87545. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  87546. /**
  87547. * An event triggered when a transform node is removed
  87548. */
  87549. onTransformNodeRemovedObservable: Observable<TransformNode>;
  87550. /**
  87551. * An event triggered when a mesh is created
  87552. */
  87553. onNewMeshAddedObservable: Observable<AbstractMesh>;
  87554. /**
  87555. * An event triggered when a mesh is removed
  87556. */
  87557. onMeshRemovedObservable: Observable<AbstractMesh>;
  87558. /**
  87559. * An event triggered when a material is created
  87560. */
  87561. onNewMaterialAddedObservable: Observable<Material>;
  87562. /**
  87563. * An event triggered when a material is removed
  87564. */
  87565. onMaterialRemovedObservable: Observable<Material>;
  87566. /**
  87567. * An event triggered when a texture is created
  87568. */
  87569. onNewTextureAddedObservable: Observable<BaseTexture>;
  87570. /**
  87571. * An event triggered when a texture is removed
  87572. */
  87573. onTextureRemovedObservable: Observable<BaseTexture>;
  87574. /**
  87575. * An event triggered when render targets are about to be rendered
  87576. * Can happen multiple times per frame.
  87577. */
  87578. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  87579. /**
  87580. * An event triggered when render targets were rendered.
  87581. * Can happen multiple times per frame.
  87582. */
  87583. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  87584. /**
  87585. * An event triggered before calculating deterministic simulation step
  87586. */
  87587. onBeforeStepObservable: Observable<Scene>;
  87588. /**
  87589. * An event triggered after calculating deterministic simulation step
  87590. */
  87591. onAfterStepObservable: Observable<Scene>;
  87592. /**
  87593. * An event triggered when the activeCamera property is updated
  87594. */
  87595. onActiveCameraChanged: Observable<Scene>;
  87596. /**
  87597. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  87598. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  87599. * 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)
  87600. */
  87601. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  87602. /**
  87603. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  87604. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  87605. * 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)
  87606. */
  87607. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  87608. /**
  87609. * This Observable will when a mesh has been imported into the scene.
  87610. */
  87611. onMeshImportedObservable: Observable<AbstractMesh>;
  87612. /** @hidden */
  87613. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  87614. /**
  87615. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  87616. */
  87617. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  87618. /**
  87619. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  87620. */
  87621. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  87622. /**
  87623. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  87624. */
  87625. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  87626. private _onPointerMove;
  87627. private _onPointerDown;
  87628. private _onPointerUp;
  87629. /** Callback called when a pointer move is detected */
  87630. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  87631. /** Callback called when a pointer down is detected */
  87632. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  87633. /** Callback called when a pointer up is detected */
  87634. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  87635. /** Callback called when a pointer pick is detected */
  87636. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  87637. /**
  87638. * 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).
  87639. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  87640. */
  87641. onPrePointerObservable: Observable<PointerInfoPre>;
  87642. /**
  87643. * Observable event triggered each time an input event is received from the rendering canvas
  87644. */
  87645. onPointerObservable: Observable<PointerInfo>;
  87646. /**
  87647. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  87648. */
  87649. readonly unTranslatedPointer: Vector2;
  87650. /** The distance in pixel that you have to move to prevent some events */
  87651. static DragMovementThreshold: number;
  87652. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  87653. static LongPressDelay: number;
  87654. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  87655. static DoubleClickDelay: number;
  87656. /** If you need to check double click without raising a single click at first click, enable this flag */
  87657. static ExclusiveDoubleClickMode: boolean;
  87658. private _initClickEvent;
  87659. private _initActionManager;
  87660. private _delayedSimpleClick;
  87661. private _delayedSimpleClickTimeout;
  87662. private _previousDelayedSimpleClickTimeout;
  87663. private _meshPickProceed;
  87664. private _previousButtonPressed;
  87665. private _currentPickResult;
  87666. private _previousPickResult;
  87667. private _totalPointersPressed;
  87668. private _doubleClickOccured;
  87669. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  87670. cameraToUseForPointers: Nullable<Camera>;
  87671. private _pointerX;
  87672. private _pointerY;
  87673. private _unTranslatedPointerX;
  87674. private _unTranslatedPointerY;
  87675. private _startingPointerPosition;
  87676. private _previousStartingPointerPosition;
  87677. private _startingPointerTime;
  87678. private _previousStartingPointerTime;
  87679. private _pointerCaptures;
  87680. private _timeAccumulator;
  87681. private _currentStepId;
  87682. private _currentInternalStep;
  87683. /** @hidden */
  87684. _mirroredCameraPosition: Nullable<Vector3>;
  87685. /**
  87686. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  87687. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  87688. */
  87689. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  87690. /**
  87691. * Observable event triggered each time an keyboard event is received from the hosting window
  87692. */
  87693. onKeyboardObservable: Observable<KeyboardInfo>;
  87694. private _onKeyDown;
  87695. private _onKeyUp;
  87696. private _onCanvasFocusObserver;
  87697. private _onCanvasBlurObserver;
  87698. private _useRightHandedSystem;
  87699. /**
  87700. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  87701. */
  87702. useRightHandedSystem: boolean;
  87703. /**
  87704. * Sets the step Id used by deterministic lock step
  87705. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87706. * @param newStepId defines the step Id
  87707. */
  87708. setStepId(newStepId: number): void;
  87709. /**
  87710. * Gets the step Id used by deterministic lock step
  87711. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87712. * @returns the step Id
  87713. */
  87714. getStepId(): number;
  87715. /**
  87716. * Gets the internal step used by deterministic lock step
  87717. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87718. * @returns the internal step
  87719. */
  87720. getInternalStep(): number;
  87721. private _fogEnabled;
  87722. /**
  87723. * Gets or sets a boolean indicating if fog is enabled on this scene
  87724. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87725. * (Default is true)
  87726. */
  87727. fogEnabled: boolean;
  87728. private _fogMode;
  87729. /**
  87730. * Gets or sets the fog mode to use
  87731. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87732. * | mode | value |
  87733. * | --- | --- |
  87734. * | FOGMODE_NONE | 0 |
  87735. * | FOGMODE_EXP | 1 |
  87736. * | FOGMODE_EXP2 | 2 |
  87737. * | FOGMODE_LINEAR | 3 |
  87738. */
  87739. fogMode: number;
  87740. /**
  87741. * Gets or sets the fog color to use
  87742. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87743. * (Default is Color3(0.2, 0.2, 0.3))
  87744. */
  87745. fogColor: Color3;
  87746. /**
  87747. * Gets or sets the fog density to use
  87748. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87749. * (Default is 0.1)
  87750. */
  87751. fogDensity: number;
  87752. /**
  87753. * Gets or sets the fog start distance to use
  87754. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87755. * (Default is 0)
  87756. */
  87757. fogStart: number;
  87758. /**
  87759. * Gets or sets the fog end distance to use
  87760. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87761. * (Default is 1000)
  87762. */
  87763. fogEnd: number;
  87764. private _shadowsEnabled;
  87765. /**
  87766. * Gets or sets a boolean indicating if shadows are enabled on this scene
  87767. */
  87768. shadowsEnabled: boolean;
  87769. private _lightsEnabled;
  87770. /**
  87771. * Gets or sets a boolean indicating if lights are enabled on this scene
  87772. */
  87773. lightsEnabled: boolean;
  87774. /** All of the active cameras added to this scene. */
  87775. activeCameras: Camera[];
  87776. private _activeCamera;
  87777. /** Gets or sets the current active camera */
  87778. activeCamera: Nullable<Camera>;
  87779. private _defaultMaterial;
  87780. /** The default material used on meshes when no material is affected */
  87781. /** The default material used on meshes when no material is affected */
  87782. defaultMaterial: Material;
  87783. private _texturesEnabled;
  87784. /**
  87785. * Gets or sets a boolean indicating if textures are enabled on this scene
  87786. */
  87787. texturesEnabled: boolean;
  87788. /**
  87789. * Gets or sets a boolean indicating if particles are enabled on this scene
  87790. */
  87791. particlesEnabled: boolean;
  87792. /**
  87793. * Gets or sets a boolean indicating if sprites are enabled on this scene
  87794. */
  87795. spritesEnabled: boolean;
  87796. private _skeletonsEnabled;
  87797. /**
  87798. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  87799. */
  87800. skeletonsEnabled: boolean;
  87801. /**
  87802. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  87803. */
  87804. lensFlaresEnabled: boolean;
  87805. /**
  87806. * Gets or sets a boolean indicating if collisions are enabled on this scene
  87807. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87808. */
  87809. collisionsEnabled: boolean;
  87810. private _collisionCoordinator;
  87811. /** @hidden */
  87812. readonly collisionCoordinator: ICollisionCoordinator;
  87813. /**
  87814. * Defines the gravity applied to this scene (used only for collisions)
  87815. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87816. */
  87817. gravity: Vector3;
  87818. /**
  87819. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  87820. */
  87821. postProcessesEnabled: boolean;
  87822. /**
  87823. * The list of postprocesses added to the scene
  87824. */
  87825. postProcesses: PostProcess[];
  87826. /**
  87827. * Gets the current postprocess manager
  87828. */
  87829. postProcessManager: PostProcessManager;
  87830. /**
  87831. * Gets or sets a boolean indicating if render targets are enabled on this scene
  87832. */
  87833. renderTargetsEnabled: boolean;
  87834. /**
  87835. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  87836. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  87837. */
  87838. dumpNextRenderTargets: boolean;
  87839. /**
  87840. * The list of user defined render targets added to the scene
  87841. */
  87842. customRenderTargets: RenderTargetTexture[];
  87843. /**
  87844. * Defines if texture loading must be delayed
  87845. * If true, textures will only be loaded when they need to be rendered
  87846. */
  87847. useDelayedTextureLoading: boolean;
  87848. /**
  87849. * Gets the list of meshes imported to the scene through SceneLoader
  87850. */
  87851. importedMeshesFiles: String[];
  87852. /**
  87853. * Gets or sets a boolean indicating if probes are enabled on this scene
  87854. */
  87855. probesEnabled: boolean;
  87856. /**
  87857. * Gets or sets the current offline provider to use to store scene data
  87858. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  87859. */
  87860. offlineProvider: IOfflineProvider;
  87861. /**
  87862. * Gets or sets the action manager associated with the scene
  87863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87864. */
  87865. actionManager: AbstractActionManager;
  87866. private _meshesForIntersections;
  87867. /**
  87868. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  87869. */
  87870. proceduralTexturesEnabled: boolean;
  87871. private _engine;
  87872. private _totalVertices;
  87873. /** @hidden */
  87874. _activeIndices: PerfCounter;
  87875. /** @hidden */
  87876. _activeParticles: PerfCounter;
  87877. /** @hidden */
  87878. _activeBones: PerfCounter;
  87879. private _animationRatio;
  87880. /** @hidden */
  87881. _animationTimeLast: number;
  87882. /** @hidden */
  87883. _animationTime: number;
  87884. /**
  87885. * Gets or sets a general scale for animation speed
  87886. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  87887. */
  87888. animationTimeScale: number;
  87889. /** @hidden */
  87890. _cachedMaterial: Nullable<Material>;
  87891. /** @hidden */
  87892. _cachedEffect: Nullable<Effect>;
  87893. /** @hidden */
  87894. _cachedVisibility: Nullable<number>;
  87895. private _renderId;
  87896. private _frameId;
  87897. private _executeWhenReadyTimeoutId;
  87898. private _intermediateRendering;
  87899. private _viewUpdateFlag;
  87900. private _projectionUpdateFlag;
  87901. private _alternateViewUpdateFlag;
  87902. private _alternateProjectionUpdateFlag;
  87903. /** @hidden */
  87904. _toBeDisposed: Nullable<IDisposable>[];
  87905. private _activeRequests;
  87906. /** @hidden */
  87907. _pendingData: any[];
  87908. private _isDisposed;
  87909. /**
  87910. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  87911. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  87912. */
  87913. dispatchAllSubMeshesOfActiveMeshes: boolean;
  87914. private _activeMeshes;
  87915. private _processedMaterials;
  87916. private _renderTargets;
  87917. /** @hidden */
  87918. _activeParticleSystems: SmartArray<IParticleSystem>;
  87919. private _activeSkeletons;
  87920. private _softwareSkinnedMeshes;
  87921. private _renderingManager;
  87922. /** @hidden */
  87923. _activeAnimatables: Animatable[];
  87924. private _transformMatrix;
  87925. private _sceneUbo;
  87926. private _alternateSceneUbo;
  87927. private _viewMatrix;
  87928. private _projectionMatrix;
  87929. private _alternateViewMatrix;
  87930. private _alternateProjectionMatrix;
  87931. private _alternateTransformMatrix;
  87932. private _useAlternateCameraConfiguration;
  87933. private _alternateRendering;
  87934. private _wheelEventName;
  87935. /** @hidden */
  87936. _forcedViewPosition: Nullable<Vector3>;
  87937. /** @hidden */
  87938. readonly _isAlternateRenderingEnabled: boolean;
  87939. private _frustumPlanes;
  87940. /**
  87941. * Gets the list of frustum planes (built from the active camera)
  87942. */
  87943. readonly frustumPlanes: Plane[];
  87944. /**
  87945. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  87946. * This is useful if there are more lights that the maximum simulteanous authorized
  87947. */
  87948. requireLightSorting: boolean;
  87949. /** @hidden */
  87950. readonly useMaterialMeshMap: boolean;
  87951. /** @hidden */
  87952. readonly useClonedMeshhMap: boolean;
  87953. private _pointerOverMesh;
  87954. private _pickedDownMesh;
  87955. private _pickedUpMesh;
  87956. private _externalData;
  87957. private _uid;
  87958. /**
  87959. * @hidden
  87960. * Backing store of defined scene components.
  87961. */
  87962. _components: ISceneComponent[];
  87963. /**
  87964. * @hidden
  87965. * Backing store of defined scene components.
  87966. */
  87967. _serializableComponents: ISceneSerializableComponent[];
  87968. /**
  87969. * List of components to register on the next registration step.
  87970. */
  87971. private _transientComponents;
  87972. /**
  87973. * Registers the transient components if needed.
  87974. */
  87975. private _registerTransientComponents;
  87976. /**
  87977. * @hidden
  87978. * Add a component to the scene.
  87979. * Note that the ccomponent could be registered on th next frame if this is called after
  87980. * the register component stage.
  87981. * @param component Defines the component to add to the scene
  87982. */
  87983. _addComponent(component: ISceneComponent): void;
  87984. /**
  87985. * @hidden
  87986. * Gets a component from the scene.
  87987. * @param name defines the name of the component to retrieve
  87988. * @returns the component or null if not present
  87989. */
  87990. _getComponent(name: string): Nullable<ISceneComponent>;
  87991. /**
  87992. * @hidden
  87993. * Defines the actions happening before camera updates.
  87994. */
  87995. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  87996. /**
  87997. * @hidden
  87998. * Defines the actions happening before clear the canvas.
  87999. */
  88000. _beforeClearStage: Stage<SimpleStageAction>;
  88001. /**
  88002. * @hidden
  88003. * Defines the actions when collecting render targets for the frame.
  88004. */
  88005. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  88006. /**
  88007. * @hidden
  88008. * Defines the actions happening for one camera in the frame.
  88009. */
  88010. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  88011. /**
  88012. * @hidden
  88013. * Defines the actions happening during the per mesh ready checks.
  88014. */
  88015. _isReadyForMeshStage: Stage<MeshStageAction>;
  88016. /**
  88017. * @hidden
  88018. * Defines the actions happening before evaluate active mesh checks.
  88019. */
  88020. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  88021. /**
  88022. * @hidden
  88023. * Defines the actions happening during the evaluate sub mesh checks.
  88024. */
  88025. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  88026. /**
  88027. * @hidden
  88028. * Defines the actions happening during the active mesh stage.
  88029. */
  88030. _activeMeshStage: Stage<ActiveMeshStageAction>;
  88031. /**
  88032. * @hidden
  88033. * Defines the actions happening during the per camera render target step.
  88034. */
  88035. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  88036. /**
  88037. * @hidden
  88038. * Defines the actions happening just before the active camera is drawing.
  88039. */
  88040. _beforeCameraDrawStage: Stage<CameraStageAction>;
  88041. /**
  88042. * @hidden
  88043. * Defines the actions happening just before a render target is drawing.
  88044. */
  88045. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  88046. /**
  88047. * @hidden
  88048. * Defines the actions happening just before a rendering group is drawing.
  88049. */
  88050. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  88051. /**
  88052. * @hidden
  88053. * Defines the actions happening just before a mesh is drawing.
  88054. */
  88055. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  88056. /**
  88057. * @hidden
  88058. * Defines the actions happening just after a mesh has been drawn.
  88059. */
  88060. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  88061. /**
  88062. * @hidden
  88063. * Defines the actions happening just after a rendering group has been drawn.
  88064. */
  88065. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  88066. /**
  88067. * @hidden
  88068. * Defines the actions happening just after the active camera has been drawn.
  88069. */
  88070. _afterCameraDrawStage: Stage<CameraStageAction>;
  88071. /**
  88072. * @hidden
  88073. * Defines the actions happening just after a render target has been drawn.
  88074. */
  88075. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  88076. /**
  88077. * @hidden
  88078. * Defines the actions happening just after rendering all cameras and computing intersections.
  88079. */
  88080. _afterRenderStage: Stage<SimpleStageAction>;
  88081. /**
  88082. * @hidden
  88083. * Defines the actions happening when a pointer move event happens.
  88084. */
  88085. _pointerMoveStage: Stage<PointerMoveStageAction>;
  88086. /**
  88087. * @hidden
  88088. * Defines the actions happening when a pointer down event happens.
  88089. */
  88090. _pointerDownStage: Stage<PointerUpDownStageAction>;
  88091. /**
  88092. * @hidden
  88093. * Defines the actions happening when a pointer up event happens.
  88094. */
  88095. _pointerUpStage: Stage<PointerUpDownStageAction>;
  88096. /**
  88097. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  88098. */
  88099. private geometriesByUniqueId;
  88100. /**
  88101. * Creates a new Scene
  88102. * @param engine defines the engine to use to render this scene
  88103. * @param options defines the scene options
  88104. */
  88105. constructor(engine: Engine, options?: SceneOptions);
  88106. private _defaultMeshCandidates;
  88107. /**
  88108. * @hidden
  88109. */
  88110. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  88111. private _defaultSubMeshCandidates;
  88112. /**
  88113. * @hidden
  88114. */
  88115. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  88116. /**
  88117. * Sets the default candidate providers for the scene.
  88118. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  88119. * and getCollidingSubMeshCandidates to their default function
  88120. */
  88121. setDefaultCandidateProviders(): void;
  88122. /**
  88123. * Gets the mesh that is currently under the pointer
  88124. */
  88125. readonly meshUnderPointer: Nullable<AbstractMesh>;
  88126. /**
  88127. * Gets or sets the current on-screen X position of the pointer
  88128. */
  88129. pointerX: number;
  88130. /**
  88131. * Gets or sets the current on-screen Y position of the pointer
  88132. */
  88133. pointerY: number;
  88134. /**
  88135. * Gets the cached material (ie. the latest rendered one)
  88136. * @returns the cached material
  88137. */
  88138. getCachedMaterial(): Nullable<Material>;
  88139. /**
  88140. * Gets the cached effect (ie. the latest rendered one)
  88141. * @returns the cached effect
  88142. */
  88143. getCachedEffect(): Nullable<Effect>;
  88144. /**
  88145. * Gets the cached visibility state (ie. the latest rendered one)
  88146. * @returns the cached visibility state
  88147. */
  88148. getCachedVisibility(): Nullable<number>;
  88149. /**
  88150. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  88151. * @param material defines the current material
  88152. * @param effect defines the current effect
  88153. * @param visibility defines the current visibility state
  88154. * @returns true if one parameter is not cached
  88155. */
  88156. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  88157. /**
  88158. * Gets the engine associated with the scene
  88159. * @returns an Engine
  88160. */
  88161. getEngine(): Engine;
  88162. /**
  88163. * Gets the total number of vertices rendered per frame
  88164. * @returns the total number of vertices rendered per frame
  88165. */
  88166. getTotalVertices(): number;
  88167. /**
  88168. * Gets the performance counter for total vertices
  88169. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88170. */
  88171. readonly totalVerticesPerfCounter: PerfCounter;
  88172. /**
  88173. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  88174. * @returns the total number of active indices rendered per frame
  88175. */
  88176. getActiveIndices(): number;
  88177. /**
  88178. * Gets the performance counter for active indices
  88179. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88180. */
  88181. readonly totalActiveIndicesPerfCounter: PerfCounter;
  88182. /**
  88183. * Gets the total number of active particles rendered per frame
  88184. * @returns the total number of active particles rendered per frame
  88185. */
  88186. getActiveParticles(): number;
  88187. /**
  88188. * Gets the performance counter for active particles
  88189. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88190. */
  88191. readonly activeParticlesPerfCounter: PerfCounter;
  88192. /**
  88193. * Gets the total number of active bones rendered per frame
  88194. * @returns the total number of active bones rendered per frame
  88195. */
  88196. getActiveBones(): number;
  88197. /**
  88198. * Gets the performance counter for active bones
  88199. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88200. */
  88201. readonly activeBonesPerfCounter: PerfCounter;
  88202. /**
  88203. * Gets the array of active meshes
  88204. * @returns an array of AbstractMesh
  88205. */
  88206. getActiveMeshes(): SmartArray<AbstractMesh>;
  88207. /**
  88208. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  88209. * @returns a number
  88210. */
  88211. getAnimationRatio(): number;
  88212. /**
  88213. * Gets an unique Id for the current render phase
  88214. * @returns a number
  88215. */
  88216. getRenderId(): number;
  88217. /**
  88218. * Gets an unique Id for the current frame
  88219. * @returns a number
  88220. */
  88221. getFrameId(): number;
  88222. /** Call this function if you want to manually increment the render Id*/
  88223. incrementRenderId(): void;
  88224. private _updatePointerPosition;
  88225. private _createUbo;
  88226. private _createAlternateUbo;
  88227. private _setRayOnPointerInfo;
  88228. /**
  88229. * Use this method to simulate a pointer move on a mesh
  88230. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88231. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88232. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88233. * @returns the current scene
  88234. */
  88235. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  88236. private _processPointerMove;
  88237. private _checkPrePointerObservable;
  88238. /**
  88239. * Use this method to simulate a pointer down on a mesh
  88240. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88241. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88242. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88243. * @returns the current scene
  88244. */
  88245. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  88246. private _processPointerDown;
  88247. /**
  88248. * Use this method to simulate a pointer up on a mesh
  88249. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88250. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88251. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88252. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  88253. * @returns the current scene
  88254. */
  88255. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  88256. private _processPointerUp;
  88257. /**
  88258. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  88259. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  88260. * @returns true if the pointer was captured
  88261. */
  88262. isPointerCaptured(pointerId?: number): boolean;
  88263. /** @hidden */
  88264. _isPointerSwiping(): boolean;
  88265. /**
  88266. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  88267. * @param attachUp defines if you want to attach events to pointerup
  88268. * @param attachDown defines if you want to attach events to pointerdown
  88269. * @param attachMove defines if you want to attach events to pointermove
  88270. */
  88271. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  88272. /** Detaches all event handlers*/
  88273. detachControl(): void;
  88274. /**
  88275. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  88276. * Delay loaded resources are not taking in account
  88277. * @return true if all required resources are ready
  88278. */
  88279. isReady(): boolean;
  88280. /** Resets all cached information relative to material (including effect and visibility) */
  88281. resetCachedMaterial(): void;
  88282. /**
  88283. * Registers a function to be called before every frame render
  88284. * @param func defines the function to register
  88285. */
  88286. registerBeforeRender(func: () => void): void;
  88287. /**
  88288. * Unregisters a function called before every frame render
  88289. * @param func defines the function to unregister
  88290. */
  88291. unregisterBeforeRender(func: () => void): void;
  88292. /**
  88293. * Registers a function to be called after every frame render
  88294. * @param func defines the function to register
  88295. */
  88296. registerAfterRender(func: () => void): void;
  88297. /**
  88298. * Unregisters a function called after every frame render
  88299. * @param func defines the function to unregister
  88300. */
  88301. unregisterAfterRender(func: () => void): void;
  88302. private _executeOnceBeforeRender;
  88303. /**
  88304. * The provided function will run before render once and will be disposed afterwards.
  88305. * A timeout delay can be provided so that the function will be executed in N ms.
  88306. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  88307. * @param func The function to be executed.
  88308. * @param timeout optional delay in ms
  88309. */
  88310. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  88311. /** @hidden */
  88312. _addPendingData(data: any): void;
  88313. /** @hidden */
  88314. _removePendingData(data: any): void;
  88315. /**
  88316. * Returns the number of items waiting to be loaded
  88317. * @returns the number of items waiting to be loaded
  88318. */
  88319. getWaitingItemsCount(): number;
  88320. /**
  88321. * Returns a boolean indicating if the scene is still loading data
  88322. */
  88323. readonly isLoading: boolean;
  88324. /**
  88325. * Registers a function to be executed when the scene is ready
  88326. * @param {Function} func - the function to be executed
  88327. */
  88328. executeWhenReady(func: () => void): void;
  88329. /**
  88330. * Returns a promise that resolves when the scene is ready
  88331. * @returns A promise that resolves when the scene is ready
  88332. */
  88333. whenReadyAsync(): Promise<void>;
  88334. /** @hidden */
  88335. _checkIsReady(): void;
  88336. /**
  88337. * Gets all animatable attached to the scene
  88338. */
  88339. readonly animatables: Animatable[];
  88340. /**
  88341. * Resets the last animation time frame.
  88342. * Useful to override when animations start running when loading a scene for the first time.
  88343. */
  88344. resetLastAnimationTimeFrame(): void;
  88345. /** @hidden */
  88346. _switchToAlternateCameraConfiguration(active: boolean): void;
  88347. /**
  88348. * Gets the current view matrix
  88349. * @returns a Matrix
  88350. */
  88351. getViewMatrix(): Matrix;
  88352. /**
  88353. * Gets the current projection matrix
  88354. * @returns a Matrix
  88355. */
  88356. getProjectionMatrix(): Matrix;
  88357. /**
  88358. * Gets the current transform matrix
  88359. * @returns a Matrix made of View * Projection
  88360. */
  88361. getTransformMatrix(): Matrix;
  88362. /**
  88363. * Sets the current transform matrix
  88364. * @param view defines the View matrix to use
  88365. * @param projection defines the Projection matrix to use
  88366. */
  88367. setTransformMatrix(view: Matrix, projection: Matrix): void;
  88368. /** @hidden */
  88369. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  88370. /**
  88371. * Gets the uniform buffer used to store scene data
  88372. * @returns a UniformBuffer
  88373. */
  88374. getSceneUniformBuffer(): UniformBuffer;
  88375. /**
  88376. * Gets an unique (relatively to the current scene) Id
  88377. * @returns an unique number for the scene
  88378. */
  88379. getUniqueId(): number;
  88380. /**
  88381. * Add a mesh to the list of scene's meshes
  88382. * @param newMesh defines the mesh to add
  88383. * @param recursive if all child meshes should also be added to the scene
  88384. */
  88385. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  88386. /**
  88387. * Remove a mesh for the list of scene's meshes
  88388. * @param toRemove defines the mesh to remove
  88389. * @param recursive if all child meshes should also be removed from the scene
  88390. * @returns the index where the mesh was in the mesh list
  88391. */
  88392. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  88393. /**
  88394. * Add a transform node to the list of scene's transform nodes
  88395. * @param newTransformNode defines the transform node to add
  88396. */
  88397. addTransformNode(newTransformNode: TransformNode): void;
  88398. /**
  88399. * Remove a transform node for the list of scene's transform nodes
  88400. * @param toRemove defines the transform node to remove
  88401. * @returns the index where the transform node was in the transform node list
  88402. */
  88403. removeTransformNode(toRemove: TransformNode): number;
  88404. /**
  88405. * Remove a skeleton for the list of scene's skeletons
  88406. * @param toRemove defines the skeleton to remove
  88407. * @returns the index where the skeleton was in the skeleton list
  88408. */
  88409. removeSkeleton(toRemove: Skeleton): number;
  88410. /**
  88411. * Remove a morph target for the list of scene's morph targets
  88412. * @param toRemove defines the morph target to remove
  88413. * @returns the index where the morph target was in the morph target list
  88414. */
  88415. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  88416. /**
  88417. * Remove a light for the list of scene's lights
  88418. * @param toRemove defines the light to remove
  88419. * @returns the index where the light was in the light list
  88420. */
  88421. removeLight(toRemove: Light): number;
  88422. /**
  88423. * Remove a camera for the list of scene's cameras
  88424. * @param toRemove defines the camera to remove
  88425. * @returns the index where the camera was in the camera list
  88426. */
  88427. removeCamera(toRemove: Camera): number;
  88428. /**
  88429. * Remove a particle system for the list of scene's particle systems
  88430. * @param toRemove defines the particle system to remove
  88431. * @returns the index where the particle system was in the particle system list
  88432. */
  88433. removeParticleSystem(toRemove: IParticleSystem): number;
  88434. /**
  88435. * Remove a animation for the list of scene's animations
  88436. * @param toRemove defines the animation to remove
  88437. * @returns the index where the animation was in the animation list
  88438. */
  88439. removeAnimation(toRemove: Animation): number;
  88440. /**
  88441. * Removes the given animation group from this scene.
  88442. * @param toRemove The animation group to remove
  88443. * @returns The index of the removed animation group
  88444. */
  88445. removeAnimationGroup(toRemove: AnimationGroup): number;
  88446. /**
  88447. * Removes the given multi-material from this scene.
  88448. * @param toRemove The multi-material to remove
  88449. * @returns The index of the removed multi-material
  88450. */
  88451. removeMultiMaterial(toRemove: MultiMaterial): number;
  88452. /**
  88453. * Removes the given material from this scene.
  88454. * @param toRemove The material to remove
  88455. * @returns The index of the removed material
  88456. */
  88457. removeMaterial(toRemove: Material): number;
  88458. /**
  88459. * Removes the given action manager from this scene.
  88460. * @param toRemove The action manager to remove
  88461. * @returns The index of the removed action manager
  88462. */
  88463. removeActionManager(toRemove: AbstractActionManager): number;
  88464. /**
  88465. * Removes the given texture from this scene.
  88466. * @param toRemove The texture to remove
  88467. * @returns The index of the removed texture
  88468. */
  88469. removeTexture(toRemove: BaseTexture): number;
  88470. /**
  88471. * Adds the given light to this scene
  88472. * @param newLight The light to add
  88473. */
  88474. addLight(newLight: Light): void;
  88475. /**
  88476. * Sorts the list list based on light priorities
  88477. */
  88478. sortLightsByPriority(): void;
  88479. /**
  88480. * Adds the given camera to this scene
  88481. * @param newCamera The camera to add
  88482. */
  88483. addCamera(newCamera: Camera): void;
  88484. /**
  88485. * Adds the given skeleton to this scene
  88486. * @param newSkeleton The skeleton to add
  88487. */
  88488. addSkeleton(newSkeleton: Skeleton): void;
  88489. /**
  88490. * Adds the given particle system to this scene
  88491. * @param newParticleSystem The particle system to add
  88492. */
  88493. addParticleSystem(newParticleSystem: IParticleSystem): void;
  88494. /**
  88495. * Adds the given animation to this scene
  88496. * @param newAnimation The animation to add
  88497. */
  88498. addAnimation(newAnimation: Animation): void;
  88499. /**
  88500. * Adds the given animation group to this scene.
  88501. * @param newAnimationGroup The animation group to add
  88502. */
  88503. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  88504. /**
  88505. * Adds the given multi-material to this scene
  88506. * @param newMultiMaterial The multi-material to add
  88507. */
  88508. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  88509. /**
  88510. * Adds the given material to this scene
  88511. * @param newMaterial The material to add
  88512. */
  88513. addMaterial(newMaterial: Material): void;
  88514. /**
  88515. * Adds the given morph target to this scene
  88516. * @param newMorphTargetManager The morph target to add
  88517. */
  88518. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  88519. /**
  88520. * Adds the given geometry to this scene
  88521. * @param newGeometry The geometry to add
  88522. */
  88523. addGeometry(newGeometry: Geometry): void;
  88524. /**
  88525. * Adds the given action manager to this scene
  88526. * @param newActionManager The action manager to add
  88527. */
  88528. addActionManager(newActionManager: AbstractActionManager): void;
  88529. /**
  88530. * Adds the given texture to this scene.
  88531. * @param newTexture The texture to add
  88532. */
  88533. addTexture(newTexture: BaseTexture): void;
  88534. /**
  88535. * Switch active camera
  88536. * @param newCamera defines the new active camera
  88537. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  88538. */
  88539. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  88540. /**
  88541. * sets the active camera of the scene using its ID
  88542. * @param id defines the camera's ID
  88543. * @return the new active camera or null if none found.
  88544. */
  88545. setActiveCameraByID(id: string): Nullable<Camera>;
  88546. /**
  88547. * sets the active camera of the scene using its name
  88548. * @param name defines the camera's name
  88549. * @returns the new active camera or null if none found.
  88550. */
  88551. setActiveCameraByName(name: string): Nullable<Camera>;
  88552. /**
  88553. * get an animation group using its name
  88554. * @param name defines the material's name
  88555. * @return the animation group or null if none found.
  88556. */
  88557. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  88558. /**
  88559. * get a material using its id
  88560. * @param id defines the material's ID
  88561. * @return the material or null if none found.
  88562. */
  88563. getMaterialByID(id: string): Nullable<Material>;
  88564. /**
  88565. * Gets a material using its name
  88566. * @param name defines the material's name
  88567. * @return the material or null if none found.
  88568. */
  88569. getMaterialByName(name: string): Nullable<Material>;
  88570. /**
  88571. * Gets a camera using its id
  88572. * @param id defines the id to look for
  88573. * @returns the camera or null if not found
  88574. */
  88575. getCameraByID(id: string): Nullable<Camera>;
  88576. /**
  88577. * Gets a camera using its unique id
  88578. * @param uniqueId defines the unique id to look for
  88579. * @returns the camera or null if not found
  88580. */
  88581. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  88582. /**
  88583. * Gets a camera using its name
  88584. * @param name defines the camera's name
  88585. * @return the camera or null if none found.
  88586. */
  88587. getCameraByName(name: string): Nullable<Camera>;
  88588. /**
  88589. * Gets a bone using its id
  88590. * @param id defines the bone's id
  88591. * @return the bone or null if not found
  88592. */
  88593. getBoneByID(id: string): Nullable<Bone>;
  88594. /**
  88595. * Gets a bone using its id
  88596. * @param name defines the bone's name
  88597. * @return the bone or null if not found
  88598. */
  88599. getBoneByName(name: string): Nullable<Bone>;
  88600. /**
  88601. * Gets a light node using its name
  88602. * @param name defines the the light's name
  88603. * @return the light or null if none found.
  88604. */
  88605. getLightByName(name: string): Nullable<Light>;
  88606. /**
  88607. * Gets a light node using its id
  88608. * @param id defines the light's id
  88609. * @return the light or null if none found.
  88610. */
  88611. getLightByID(id: string): Nullable<Light>;
  88612. /**
  88613. * Gets a light node using its scene-generated unique ID
  88614. * @param uniqueId defines the light's unique id
  88615. * @return the light or null if none found.
  88616. */
  88617. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  88618. /**
  88619. * Gets a particle system by id
  88620. * @param id defines the particle system id
  88621. * @return the corresponding system or null if none found
  88622. */
  88623. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  88624. /**
  88625. * Gets a geometry using its ID
  88626. * @param id defines the geometry's id
  88627. * @return the geometry or null if none found.
  88628. */
  88629. getGeometryByID(id: string): Nullable<Geometry>;
  88630. private _getGeometryByUniqueID;
  88631. /**
  88632. * Add a new geometry to this scene
  88633. * @param geometry defines the geometry to be added to the scene.
  88634. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  88635. * @return a boolean defining if the geometry was added or not
  88636. */
  88637. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  88638. /**
  88639. * Removes an existing geometry
  88640. * @param geometry defines the geometry to be removed from the scene
  88641. * @return a boolean defining if the geometry was removed or not
  88642. */
  88643. removeGeometry(geometry: Geometry): boolean;
  88644. /**
  88645. * Gets the list of geometries attached to the scene
  88646. * @returns an array of Geometry
  88647. */
  88648. getGeometries(): Geometry[];
  88649. /**
  88650. * Gets the first added mesh found of a given ID
  88651. * @param id defines the id to search for
  88652. * @return the mesh found or null if not found at all
  88653. */
  88654. getMeshByID(id: string): Nullable<AbstractMesh>;
  88655. /**
  88656. * Gets a list of meshes using their id
  88657. * @param id defines the id to search for
  88658. * @returns a list of meshes
  88659. */
  88660. getMeshesByID(id: string): Array<AbstractMesh>;
  88661. /**
  88662. * Gets the first added transform node found of a given ID
  88663. * @param id defines the id to search for
  88664. * @return the found transform node or null if not found at all.
  88665. */
  88666. getTransformNodeByID(id: string): Nullable<TransformNode>;
  88667. /**
  88668. * Gets a list of transform nodes using their id
  88669. * @param id defines the id to search for
  88670. * @returns a list of transform nodes
  88671. */
  88672. getTransformNodesByID(id: string): Array<TransformNode>;
  88673. /**
  88674. * Gets a mesh with its auto-generated unique id
  88675. * @param uniqueId defines the unique id to search for
  88676. * @return the found mesh or null if not found at all.
  88677. */
  88678. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  88679. /**
  88680. * Gets a the last added mesh using a given id
  88681. * @param id defines the id to search for
  88682. * @return the found mesh or null if not found at all.
  88683. */
  88684. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  88685. /**
  88686. * Gets a the last added node (Mesh, Camera, Light) using a given id
  88687. * @param id defines the id to search for
  88688. * @return the found node or null if not found at all
  88689. */
  88690. getLastEntryByID(id: string): Nullable<Node>;
  88691. /**
  88692. * Gets a node (Mesh, Camera, Light) using a given id
  88693. * @param id defines the id to search for
  88694. * @return the found node or null if not found at all
  88695. */
  88696. getNodeByID(id: string): Nullable<Node>;
  88697. /**
  88698. * Gets a node (Mesh, Camera, Light) using a given name
  88699. * @param name defines the name to search for
  88700. * @return the found node or null if not found at all.
  88701. */
  88702. getNodeByName(name: string): Nullable<Node>;
  88703. /**
  88704. * Gets a mesh using a given name
  88705. * @param name defines the name to search for
  88706. * @return the found mesh or null if not found at all.
  88707. */
  88708. getMeshByName(name: string): Nullable<AbstractMesh>;
  88709. /**
  88710. * Gets a transform node using a given name
  88711. * @param name defines the name to search for
  88712. * @return the found transform node or null if not found at all.
  88713. */
  88714. getTransformNodeByName(name: string): Nullable<TransformNode>;
  88715. /**
  88716. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  88717. * @param id defines the id to search for
  88718. * @return the found skeleton or null if not found at all.
  88719. */
  88720. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  88721. /**
  88722. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  88723. * @param id defines the id to search for
  88724. * @return the found skeleton or null if not found at all.
  88725. */
  88726. getSkeletonById(id: string): Nullable<Skeleton>;
  88727. /**
  88728. * Gets a skeleton using a given name
  88729. * @param name defines the name to search for
  88730. * @return the found skeleton or null if not found at all.
  88731. */
  88732. getSkeletonByName(name: string): Nullable<Skeleton>;
  88733. /**
  88734. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  88735. * @param id defines the id to search for
  88736. * @return the found morph target manager or null if not found at all.
  88737. */
  88738. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  88739. /**
  88740. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  88741. * @param id defines the id to search for
  88742. * @return the found morph target or null if not found at all.
  88743. */
  88744. getMorphTargetById(id: string): Nullable<MorphTarget>;
  88745. /**
  88746. * Gets a boolean indicating if the given mesh is active
  88747. * @param mesh defines the mesh to look for
  88748. * @returns true if the mesh is in the active list
  88749. */
  88750. isActiveMesh(mesh: AbstractMesh): boolean;
  88751. /**
  88752. * Return a unique id as a string which can serve as an identifier for the scene
  88753. */
  88754. readonly uid: string;
  88755. /**
  88756. * Add an externaly attached data from its key.
  88757. * This method call will fail and return false, if such key already exists.
  88758. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88759. * @param key the unique key that identifies the data
  88760. * @param data the data object to associate to the key for this Engine instance
  88761. * @return true if no such key were already present and the data was added successfully, false otherwise
  88762. */
  88763. addExternalData<T>(key: string, data: T): boolean;
  88764. /**
  88765. * Get an externaly attached data from its key
  88766. * @param key the unique key that identifies the data
  88767. * @return the associated data, if present (can be null), or undefined if not present
  88768. */
  88769. getExternalData<T>(key: string): Nullable<T>;
  88770. /**
  88771. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88772. * @param key the unique key that identifies the data
  88773. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88774. * @return the associated data, can be null if the factory returned null.
  88775. */
  88776. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88777. /**
  88778. * Remove an externaly attached data from the Engine instance
  88779. * @param key the unique key that identifies the data
  88780. * @return true if the data was successfully removed, false if it doesn't exist
  88781. */
  88782. removeExternalData(key: string): boolean;
  88783. private _evaluateSubMesh;
  88784. /**
  88785. * Clear the processed materials smart array preventing retention point in material dispose.
  88786. */
  88787. freeProcessedMaterials(): void;
  88788. private _preventFreeActiveMeshesAndRenderingGroups;
  88789. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  88790. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  88791. * when disposing several meshes in a row or a hierarchy of meshes.
  88792. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  88793. */
  88794. blockfreeActiveMeshesAndRenderingGroups: boolean;
  88795. /**
  88796. * Clear the active meshes smart array preventing retention point in mesh dispose.
  88797. */
  88798. freeActiveMeshes(): void;
  88799. /**
  88800. * Clear the info related to rendering groups preventing retention points during dispose.
  88801. */
  88802. freeRenderingGroups(): void;
  88803. /** @hidden */
  88804. _isInIntermediateRendering(): boolean;
  88805. /**
  88806. * Lambda returning the list of potentially active meshes.
  88807. */
  88808. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  88809. /**
  88810. * Lambda returning the list of potentially active sub meshes.
  88811. */
  88812. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  88813. /**
  88814. * Lambda returning the list of potentially intersecting sub meshes.
  88815. */
  88816. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  88817. /**
  88818. * Lambda returning the list of potentially colliding sub meshes.
  88819. */
  88820. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  88821. private _activeMeshesFrozen;
  88822. /**
  88823. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  88824. * @returns the current scene
  88825. */
  88826. freezeActiveMeshes(): Scene;
  88827. /**
  88828. * Use this function to restart evaluating active meshes on every frame
  88829. * @returns the current scene
  88830. */
  88831. unfreezeActiveMeshes(): Scene;
  88832. private _evaluateActiveMeshes;
  88833. private _activeMesh;
  88834. /**
  88835. * Update the transform matrix to update from the current active camera
  88836. * @param force defines a boolean used to force the update even if cache is up to date
  88837. */
  88838. updateTransformMatrix(force?: boolean): void;
  88839. /**
  88840. * 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)
  88841. * @param alternateCamera defines the camera to use
  88842. */
  88843. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  88844. /** @hidden */
  88845. _allowPostProcessClearColor: boolean;
  88846. private _renderForCamera;
  88847. private _processSubCameras;
  88848. private _checkIntersections;
  88849. /** @hidden */
  88850. _advancePhysicsEngineStep(step: number): void;
  88851. /**
  88852. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  88853. */
  88854. getDeterministicFrameTime: () => number;
  88855. /** @hidden */
  88856. _animate(): void;
  88857. /**
  88858. * Render the scene
  88859. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  88860. */
  88861. render(updateCameras?: boolean): void;
  88862. /**
  88863. * Freeze all materials
  88864. * A frozen material will not be updatable but should be faster to render
  88865. */
  88866. freezeMaterials(): void;
  88867. /**
  88868. * Unfreeze all materials
  88869. * A frozen material will not be updatable but should be faster to render
  88870. */
  88871. unfreezeMaterials(): void;
  88872. /**
  88873. * Releases all held ressources
  88874. */
  88875. dispose(): void;
  88876. /**
  88877. * Gets if the scene is already disposed
  88878. */
  88879. readonly isDisposed: boolean;
  88880. /**
  88881. * Call this function to reduce memory footprint of the scene.
  88882. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  88883. */
  88884. clearCachedVertexData(): void;
  88885. /**
  88886. * This function will remove the local cached buffer data from texture.
  88887. * It will save memory but will prevent the texture from being rebuilt
  88888. */
  88889. cleanCachedTextureBuffer(): void;
  88890. /**
  88891. * Get the world extend vectors with an optional filter
  88892. *
  88893. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  88894. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  88895. */
  88896. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  88897. min: Vector3;
  88898. max: Vector3;
  88899. };
  88900. /**
  88901. * Creates a ray that can be used to pick in the scene
  88902. * @param x defines the x coordinate of the origin (on-screen)
  88903. * @param y defines the y coordinate of the origin (on-screen)
  88904. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  88905. * @param camera defines the camera to use for the picking
  88906. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  88907. * @returns a Ray
  88908. */
  88909. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  88910. /**
  88911. * Creates a ray that can be used to pick in the scene
  88912. * @param x defines the x coordinate of the origin (on-screen)
  88913. * @param y defines the y coordinate of the origin (on-screen)
  88914. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  88915. * @param result defines the ray where to store the picking ray
  88916. * @param camera defines the camera to use for the picking
  88917. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  88918. * @returns the current scene
  88919. */
  88920. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  88921. /**
  88922. * Creates a ray that can be used to pick in the scene
  88923. * @param x defines the x coordinate of the origin (on-screen)
  88924. * @param y defines the y coordinate of the origin (on-screen)
  88925. * @param camera defines the camera to use for the picking
  88926. * @returns a Ray
  88927. */
  88928. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  88929. /**
  88930. * Creates a ray that can be used to pick in the scene
  88931. * @param x defines the x coordinate of the origin (on-screen)
  88932. * @param y defines the y coordinate of the origin (on-screen)
  88933. * @param result defines the ray where to store the picking ray
  88934. * @param camera defines the camera to use for the picking
  88935. * @returns the current scene
  88936. */
  88937. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  88938. /** Launch a ray to try to pick a mesh in the scene
  88939. * @param x position on screen
  88940. * @param y position on screen
  88941. * @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
  88942. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  88943. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88944. * @returns a PickingInfo
  88945. */
  88946. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  88947. /** Use the given ray to pick a mesh in the scene
  88948. * @param ray The ray to use to pick meshes
  88949. * @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
  88950. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  88951. * @returns a PickingInfo
  88952. */
  88953. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88954. /**
  88955. * Launch a ray to try to pick a mesh in the scene
  88956. * @param x X position on screen
  88957. * @param y Y position on screen
  88958. * @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
  88959. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88960. * @returns an array of PickingInfo
  88961. */
  88962. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88963. /**
  88964. * Launch a ray to try to pick a mesh in the scene
  88965. * @param ray Ray to use
  88966. * @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
  88967. * @returns an array of PickingInfo
  88968. */
  88969. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  88970. /**
  88971. * Force the value of meshUnderPointer
  88972. * @param mesh defines the mesh to use
  88973. */
  88974. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  88975. /**
  88976. * Gets the mesh under the pointer
  88977. * @returns a Mesh or null if no mesh is under the pointer
  88978. */
  88979. getPointerOverMesh(): Nullable<AbstractMesh>;
  88980. /** @hidden */
  88981. _rebuildGeometries(): void;
  88982. /** @hidden */
  88983. _rebuildTextures(): void;
  88984. private _getByTags;
  88985. /**
  88986. * Get a list of meshes by tags
  88987. * @param tagsQuery defines the tags query to use
  88988. * @param forEach defines a predicate used to filter results
  88989. * @returns an array of Mesh
  88990. */
  88991. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  88992. /**
  88993. * Get a list of cameras by tags
  88994. * @param tagsQuery defines the tags query to use
  88995. * @param forEach defines a predicate used to filter results
  88996. * @returns an array of Camera
  88997. */
  88998. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  88999. /**
  89000. * Get a list of lights by tags
  89001. * @param tagsQuery defines the tags query to use
  89002. * @param forEach defines a predicate used to filter results
  89003. * @returns an array of Light
  89004. */
  89005. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  89006. /**
  89007. * Get a list of materials by tags
  89008. * @param tagsQuery defines the tags query to use
  89009. * @param forEach defines a predicate used to filter results
  89010. * @returns an array of Material
  89011. */
  89012. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  89013. /**
  89014. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89015. * This allowed control for front to back rendering or reversly depending of the special needs.
  89016. *
  89017. * @param renderingGroupId The rendering group id corresponding to its index
  89018. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89019. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89020. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89021. */
  89022. 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;
  89023. /**
  89024. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89025. *
  89026. * @param renderingGroupId The rendering group id corresponding to its index
  89027. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89028. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89029. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89030. */
  89031. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89032. /**
  89033. * Gets the current auto clear configuration for one rendering group of the rendering
  89034. * manager.
  89035. * @param index the rendering group index to get the information for
  89036. * @returns The auto clear setup for the requested rendering group
  89037. */
  89038. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89039. private _blockMaterialDirtyMechanism;
  89040. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  89041. blockMaterialDirtyMechanism: boolean;
  89042. /**
  89043. * Will flag all materials as dirty to trigger new shader compilation
  89044. * @param flag defines the flag used to specify which material part must be marked as dirty
  89045. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  89046. */
  89047. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  89048. /** @hidden */
  89049. _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;
  89050. /** @hidden */
  89051. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  89052. }
  89053. }
  89054. declare module BABYLON {
  89055. /**
  89056. * Set of assets to keep when moving a scene into an asset container.
  89057. */
  89058. export class KeepAssets extends AbstractScene {
  89059. }
  89060. /**
  89061. * Container with a set of assets that can be added or removed from a scene.
  89062. */
  89063. export class AssetContainer extends AbstractScene {
  89064. /**
  89065. * The scene the AssetContainer belongs to.
  89066. */
  89067. scene: Scene;
  89068. /**
  89069. * Instantiates an AssetContainer.
  89070. * @param scene The scene the AssetContainer belongs to.
  89071. */
  89072. constructor(scene: Scene);
  89073. /**
  89074. * Adds all the assets from the container to the scene.
  89075. */
  89076. addAllToScene(): void;
  89077. /**
  89078. * Removes all the assets in the container from the scene
  89079. */
  89080. removeAllFromScene(): void;
  89081. /**
  89082. * Disposes all the assets in the container
  89083. */
  89084. dispose(): void;
  89085. private _moveAssets;
  89086. /**
  89087. * Removes all the assets contained in the scene and adds them to the container.
  89088. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  89089. */
  89090. moveAllFromScene(keepAssets?: KeepAssets): void;
  89091. /**
  89092. * 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.
  89093. * @returns the root mesh
  89094. */
  89095. createRootMesh(): Mesh;
  89096. }
  89097. }
  89098. declare module BABYLON {
  89099. /**
  89100. * Defines how the parser contract is defined.
  89101. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  89102. */
  89103. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  89104. /**
  89105. * Defines how the individual parser contract is defined.
  89106. * These parser can parse an individual asset
  89107. */
  89108. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  89109. /**
  89110. * Base class of the scene acting as a container for the different elements composing a scene.
  89111. * This class is dynamically extended by the different components of the scene increasing
  89112. * flexibility and reducing coupling
  89113. */
  89114. export abstract class AbstractScene {
  89115. /**
  89116. * Stores the list of available parsers in the application.
  89117. */
  89118. private static _BabylonFileParsers;
  89119. /**
  89120. * Stores the list of available individual parsers in the application.
  89121. */
  89122. private static _IndividualBabylonFileParsers;
  89123. /**
  89124. * Adds a parser in the list of available ones
  89125. * @param name Defines the name of the parser
  89126. * @param parser Defines the parser to add
  89127. */
  89128. static AddParser(name: string, parser: BabylonFileParser): void;
  89129. /**
  89130. * Gets a general parser from the list of avaialble ones
  89131. * @param name Defines the name of the parser
  89132. * @returns the requested parser or null
  89133. */
  89134. static GetParser(name: string): Nullable<BabylonFileParser>;
  89135. /**
  89136. * Adds n individual parser in the list of available ones
  89137. * @param name Defines the name of the parser
  89138. * @param parser Defines the parser to add
  89139. */
  89140. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  89141. /**
  89142. * Gets an individual parser from the list of avaialble ones
  89143. * @param name Defines the name of the parser
  89144. * @returns the requested parser or null
  89145. */
  89146. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  89147. /**
  89148. * Parser json data and populate both a scene and its associated container object
  89149. * @param jsonData Defines the data to parse
  89150. * @param scene Defines the scene to parse the data for
  89151. * @param container Defines the container attached to the parsing sequence
  89152. * @param rootUrl Defines the root url of the data
  89153. */
  89154. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  89155. /**
  89156. * Gets the list of root nodes (ie. nodes with no parent)
  89157. */
  89158. rootNodes: Node[];
  89159. /** All of the cameras added to this scene
  89160. * @see http://doc.babylonjs.com/babylon101/cameras
  89161. */
  89162. cameras: Camera[];
  89163. /**
  89164. * All of the lights added to this scene
  89165. * @see http://doc.babylonjs.com/babylon101/lights
  89166. */
  89167. lights: Light[];
  89168. /**
  89169. * All of the (abstract) meshes added to this scene
  89170. */
  89171. meshes: AbstractMesh[];
  89172. /**
  89173. * The list of skeletons added to the scene
  89174. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89175. */
  89176. skeletons: Skeleton[];
  89177. /**
  89178. * All of the particle systems added to this scene
  89179. * @see http://doc.babylonjs.com/babylon101/particles
  89180. */
  89181. particleSystems: IParticleSystem[];
  89182. /**
  89183. * Gets a list of Animations associated with the scene
  89184. */
  89185. animations: Animation[];
  89186. /**
  89187. * All of the animation groups added to this scene
  89188. * @see http://doc.babylonjs.com/how_to/group
  89189. */
  89190. animationGroups: AnimationGroup[];
  89191. /**
  89192. * All of the multi-materials added to this scene
  89193. * @see http://doc.babylonjs.com/how_to/multi_materials
  89194. */
  89195. multiMaterials: MultiMaterial[];
  89196. /**
  89197. * All of the materials added to this scene
  89198. * In the context of a Scene, it is not supposed to be modified manually.
  89199. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  89200. * Note also that the order of the Material wihin the array is not significant and might change.
  89201. * @see http://doc.babylonjs.com/babylon101/materials
  89202. */
  89203. materials: Material[];
  89204. /**
  89205. * The list of morph target managers added to the scene
  89206. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  89207. */
  89208. morphTargetManagers: MorphTargetManager[];
  89209. /**
  89210. * The list of geometries used in the scene.
  89211. */
  89212. geometries: Geometry[];
  89213. /**
  89214. * All of the tranform nodes added to this scene
  89215. * In the context of a Scene, it is not supposed to be modified manually.
  89216. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  89217. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  89218. * @see http://doc.babylonjs.com/how_to/transformnode
  89219. */
  89220. transformNodes: TransformNode[];
  89221. /**
  89222. * ActionManagers available on the scene.
  89223. */
  89224. actionManagers: AbstractActionManager[];
  89225. /**
  89226. * Textures to keep.
  89227. */
  89228. textures: BaseTexture[];
  89229. }
  89230. }
  89231. declare module BABYLON {
  89232. /**
  89233. * Defines a sound that can be played in the application.
  89234. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  89235. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89236. */
  89237. export class Sound {
  89238. /**
  89239. * The name of the sound in the scene.
  89240. */
  89241. name: string;
  89242. /**
  89243. * Does the sound autoplay once loaded.
  89244. */
  89245. autoplay: boolean;
  89246. /**
  89247. * Does the sound loop after it finishes playing once.
  89248. */
  89249. loop: boolean;
  89250. /**
  89251. * Does the sound use a custom attenuation curve to simulate the falloff
  89252. * happening when the source gets further away from the camera.
  89253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  89254. */
  89255. useCustomAttenuation: boolean;
  89256. /**
  89257. * The sound track id this sound belongs to.
  89258. */
  89259. soundTrackId: number;
  89260. /**
  89261. * Is this sound currently played.
  89262. */
  89263. isPlaying: boolean;
  89264. /**
  89265. * Is this sound currently paused.
  89266. */
  89267. isPaused: boolean;
  89268. /**
  89269. * Does this sound enables spatial sound.
  89270. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89271. */
  89272. spatialSound: boolean;
  89273. /**
  89274. * Define the reference distance the sound should be heard perfectly.
  89275. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89276. */
  89277. refDistance: number;
  89278. /**
  89279. * Define the roll off factor of spatial sounds.
  89280. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89281. */
  89282. rolloffFactor: number;
  89283. /**
  89284. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  89285. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89286. */
  89287. maxDistance: number;
  89288. /**
  89289. * Define the distance attenuation model the sound will follow.
  89290. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89291. */
  89292. distanceModel: string;
  89293. /**
  89294. * @hidden
  89295. * Back Compat
  89296. **/
  89297. onended: () => any;
  89298. /**
  89299. * Observable event when the current playing sound finishes.
  89300. */
  89301. onEndedObservable: Observable<Sound>;
  89302. private _panningModel;
  89303. private _playbackRate;
  89304. private _streaming;
  89305. private _startTime;
  89306. private _startOffset;
  89307. private _position;
  89308. /** @hidden */
  89309. _positionInEmitterSpace: boolean;
  89310. private _localDirection;
  89311. private _volume;
  89312. private _isReadyToPlay;
  89313. private _isDirectional;
  89314. private _readyToPlayCallback;
  89315. private _audioBuffer;
  89316. private _soundSource;
  89317. private _streamingSource;
  89318. private _soundPanner;
  89319. private _soundGain;
  89320. private _inputAudioNode;
  89321. private _outputAudioNode;
  89322. private _coneInnerAngle;
  89323. private _coneOuterAngle;
  89324. private _coneOuterGain;
  89325. private _scene;
  89326. private _connectedTransformNode;
  89327. private _customAttenuationFunction;
  89328. private _registerFunc;
  89329. private _isOutputConnected;
  89330. private _htmlAudioElement;
  89331. private _urlType;
  89332. /** @hidden */
  89333. static _SceneComponentInitialization: (scene: Scene) => void;
  89334. /**
  89335. * Create a sound and attach it to a scene
  89336. * @param name Name of your sound
  89337. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  89338. * @param scene defines the scene the sound belongs to
  89339. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  89340. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  89341. */
  89342. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  89343. /**
  89344. * Release the sound and its associated resources
  89345. */
  89346. dispose(): void;
  89347. /**
  89348. * Gets if the sounds is ready to be played or not.
  89349. * @returns true if ready, otherwise false
  89350. */
  89351. isReady(): boolean;
  89352. private _soundLoaded;
  89353. /**
  89354. * Sets the data of the sound from an audiobuffer
  89355. * @param audioBuffer The audioBuffer containing the data
  89356. */
  89357. setAudioBuffer(audioBuffer: AudioBuffer): void;
  89358. /**
  89359. * Updates the current sounds options such as maxdistance, loop...
  89360. * @param options A JSON object containing values named as the object properties
  89361. */
  89362. updateOptions(options: any): void;
  89363. private _createSpatialParameters;
  89364. private _updateSpatialParameters;
  89365. /**
  89366. * Switch the panning model to HRTF:
  89367. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  89368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89369. */
  89370. switchPanningModelToHRTF(): void;
  89371. /**
  89372. * Switch the panning model to Equal Power:
  89373. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  89374. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89375. */
  89376. switchPanningModelToEqualPower(): void;
  89377. private _switchPanningModel;
  89378. /**
  89379. * Connect this sound to a sound track audio node like gain...
  89380. * @param soundTrackAudioNode the sound track audio node to connect to
  89381. */
  89382. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  89383. /**
  89384. * Transform this sound into a directional source
  89385. * @param coneInnerAngle Size of the inner cone in degree
  89386. * @param coneOuterAngle Size of the outer cone in degree
  89387. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  89388. */
  89389. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  89390. /**
  89391. * Gets or sets the inner angle for the directional cone.
  89392. */
  89393. /**
  89394. * Gets or sets the inner angle for the directional cone.
  89395. */
  89396. directionalConeInnerAngle: number;
  89397. /**
  89398. * Gets or sets the outer angle for the directional cone.
  89399. */
  89400. /**
  89401. * Gets or sets the outer angle for the directional cone.
  89402. */
  89403. directionalConeOuterAngle: number;
  89404. /**
  89405. * Sets the position of the emitter if spatial sound is enabled
  89406. * @param newPosition Defines the new posisiton
  89407. */
  89408. setPosition(newPosition: Vector3): void;
  89409. /**
  89410. * Sets the local direction of the emitter if spatial sound is enabled
  89411. * @param newLocalDirection Defines the new local direction
  89412. */
  89413. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  89414. private _updateDirection;
  89415. /** @hidden */
  89416. updateDistanceFromListener(): void;
  89417. /**
  89418. * Sets a new custom attenuation function for the sound.
  89419. * @param callback Defines the function used for the attenuation
  89420. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  89421. */
  89422. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  89423. /**
  89424. * Play the sound
  89425. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  89426. * @param offset (optional) Start the sound setting it at a specific time
  89427. */
  89428. play(time?: number, offset?: number): void;
  89429. private _onended;
  89430. /**
  89431. * Stop the sound
  89432. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  89433. */
  89434. stop(time?: number): void;
  89435. /**
  89436. * Put the sound in pause
  89437. */
  89438. pause(): void;
  89439. /**
  89440. * Sets a dedicated volume for this sounds
  89441. * @param newVolume Define the new volume of the sound
  89442. * @param time Define in how long the sound should be at this value
  89443. */
  89444. setVolume(newVolume: number, time?: number): void;
  89445. /**
  89446. * Set the sound play back rate
  89447. * @param newPlaybackRate Define the playback rate the sound should be played at
  89448. */
  89449. setPlaybackRate(newPlaybackRate: number): void;
  89450. /**
  89451. * Gets the volume of the sound.
  89452. * @returns the volume of the sound
  89453. */
  89454. getVolume(): number;
  89455. /**
  89456. * Attach the sound to a dedicated mesh
  89457. * @param transformNode The transform node to connect the sound with
  89458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  89459. */
  89460. attachToMesh(transformNode: TransformNode): void;
  89461. /**
  89462. * Detach the sound from the previously attached mesh
  89463. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  89464. */
  89465. detachFromMesh(): void;
  89466. private _onRegisterAfterWorldMatrixUpdate;
  89467. /**
  89468. * Clone the current sound in the scene.
  89469. * @returns the new sound clone
  89470. */
  89471. clone(): Nullable<Sound>;
  89472. /**
  89473. * Gets the current underlying audio buffer containing the data
  89474. * @returns the audio buffer
  89475. */
  89476. getAudioBuffer(): Nullable<AudioBuffer>;
  89477. /**
  89478. * Serializes the Sound in a JSON representation
  89479. * @returns the JSON representation of the sound
  89480. */
  89481. serialize(): any;
  89482. /**
  89483. * Parse a JSON representation of a sound to innstantiate in a given scene
  89484. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  89485. * @param scene Define the scene the new parsed sound should be created in
  89486. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  89487. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  89488. * @returns the newly parsed sound
  89489. */
  89490. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  89491. }
  89492. }
  89493. declare module BABYLON {
  89494. /**
  89495. * This defines an action helpful to play a defined sound on a triggered action.
  89496. */
  89497. export class PlaySoundAction extends Action {
  89498. private _sound;
  89499. /**
  89500. * Instantiate the action
  89501. * @param triggerOptions defines the trigger options
  89502. * @param sound defines the sound to play
  89503. * @param condition defines the trigger related conditions
  89504. */
  89505. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  89506. /** @hidden */
  89507. _prepare(): void;
  89508. /**
  89509. * Execute the action and play the sound.
  89510. */
  89511. execute(): void;
  89512. /**
  89513. * Serializes the actions and its related information.
  89514. * @param parent defines the object to serialize in
  89515. * @returns the serialized object
  89516. */
  89517. serialize(parent: any): any;
  89518. }
  89519. /**
  89520. * This defines an action helpful to stop a defined sound on a triggered action.
  89521. */
  89522. export class StopSoundAction extends Action {
  89523. private _sound;
  89524. /**
  89525. * Instantiate the action
  89526. * @param triggerOptions defines the trigger options
  89527. * @param sound defines the sound to stop
  89528. * @param condition defines the trigger related conditions
  89529. */
  89530. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  89531. /** @hidden */
  89532. _prepare(): void;
  89533. /**
  89534. * Execute the action and stop the sound.
  89535. */
  89536. execute(): void;
  89537. /**
  89538. * Serializes the actions and its related information.
  89539. * @param parent defines the object to serialize in
  89540. * @returns the serialized object
  89541. */
  89542. serialize(parent: any): any;
  89543. }
  89544. }
  89545. declare module BABYLON {
  89546. /**
  89547. * This defines an action responsible to change the value of a property
  89548. * by interpolating between its current value and the newly set one once triggered.
  89549. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89550. */
  89551. export class InterpolateValueAction extends Action {
  89552. /**
  89553. * Defines the path of the property where the value should be interpolated
  89554. */
  89555. propertyPath: string;
  89556. /**
  89557. * Defines the target value at the end of the interpolation.
  89558. */
  89559. value: any;
  89560. /**
  89561. * Defines the time it will take for the property to interpolate to the value.
  89562. */
  89563. duration: number;
  89564. /**
  89565. * Defines if the other scene animations should be stopped when the action has been triggered
  89566. */
  89567. stopOtherAnimations?: boolean;
  89568. /**
  89569. * Defines a callback raised once the interpolation animation has been done.
  89570. */
  89571. onInterpolationDone?: () => void;
  89572. /**
  89573. * Observable triggered once the interpolation animation has been done.
  89574. */
  89575. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  89576. private _target;
  89577. private _effectiveTarget;
  89578. private _property;
  89579. /**
  89580. * Instantiate the action
  89581. * @param triggerOptions defines the trigger options
  89582. * @param target defines the object containing the value to interpolate
  89583. * @param propertyPath defines the path to the property in the target object
  89584. * @param value defines the target value at the end of the interpolation
  89585. * @param duration deines the time it will take for the property to interpolate to the value.
  89586. * @param condition defines the trigger related conditions
  89587. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  89588. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  89589. */
  89590. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  89591. /** @hidden */
  89592. _prepare(): void;
  89593. /**
  89594. * Execute the action starts the value interpolation.
  89595. */
  89596. execute(): void;
  89597. /**
  89598. * Serializes the actions and its related information.
  89599. * @param parent defines the object to serialize in
  89600. * @returns the serialized object
  89601. */
  89602. serialize(parent: any): any;
  89603. }
  89604. }
  89605. declare module BABYLON {
  89606. /**
  89607. * Options allowed during the creation of a sound track.
  89608. */
  89609. export interface ISoundTrackOptions {
  89610. /**
  89611. * The volume the sound track should take during creation
  89612. */
  89613. volume?: number;
  89614. /**
  89615. * Define if the sound track is the main sound track of the scene
  89616. */
  89617. mainTrack?: boolean;
  89618. }
  89619. /**
  89620. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  89621. * It will be also used in a future release to apply effects on a specific track.
  89622. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  89623. */
  89624. export class SoundTrack {
  89625. /**
  89626. * The unique identifier of the sound track in the scene.
  89627. */
  89628. id: number;
  89629. /**
  89630. * The list of sounds included in the sound track.
  89631. */
  89632. soundCollection: Array<Sound>;
  89633. private _outputAudioNode;
  89634. private _scene;
  89635. private _isMainTrack;
  89636. private _connectedAnalyser;
  89637. private _options;
  89638. private _isInitialized;
  89639. /**
  89640. * Creates a new sound track.
  89641. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  89642. * @param scene Define the scene the sound track belongs to
  89643. * @param options
  89644. */
  89645. constructor(scene: Scene, options?: ISoundTrackOptions);
  89646. private _initializeSoundTrackAudioGraph;
  89647. /**
  89648. * Release the sound track and its associated resources
  89649. */
  89650. dispose(): void;
  89651. /**
  89652. * Adds a sound to this sound track
  89653. * @param sound define the cound to add
  89654. * @ignoreNaming
  89655. */
  89656. AddSound(sound: Sound): void;
  89657. /**
  89658. * Removes a sound to this sound track
  89659. * @param sound define the cound to remove
  89660. * @ignoreNaming
  89661. */
  89662. RemoveSound(sound: Sound): void;
  89663. /**
  89664. * Set a global volume for the full sound track.
  89665. * @param newVolume Define the new volume of the sound track
  89666. */
  89667. setVolume(newVolume: number): void;
  89668. /**
  89669. * Switch the panning model to HRTF:
  89670. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  89671. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89672. */
  89673. switchPanningModelToHRTF(): void;
  89674. /**
  89675. * Switch the panning model to Equal Power:
  89676. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  89677. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89678. */
  89679. switchPanningModelToEqualPower(): void;
  89680. /**
  89681. * Connect the sound track to an audio analyser allowing some amazing
  89682. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  89683. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  89684. * @param analyser The analyser to connect to the engine
  89685. */
  89686. connectToAnalyser(analyser: Analyser): void;
  89687. }
  89688. }
  89689. declare module BABYLON {
  89690. interface AbstractScene {
  89691. /**
  89692. * The list of sounds used in the scene.
  89693. */
  89694. sounds: Nullable<Array<Sound>>;
  89695. }
  89696. interface Scene {
  89697. /**
  89698. * @hidden
  89699. * Backing field
  89700. */
  89701. _mainSoundTrack: SoundTrack;
  89702. /**
  89703. * The main sound track played by the scene.
  89704. * It cotains your primary collection of sounds.
  89705. */
  89706. mainSoundTrack: SoundTrack;
  89707. /**
  89708. * The list of sound tracks added to the scene
  89709. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89710. */
  89711. soundTracks: Nullable<Array<SoundTrack>>;
  89712. /**
  89713. * Gets a sound using a given name
  89714. * @param name defines the name to search for
  89715. * @return the found sound or null if not found at all.
  89716. */
  89717. getSoundByName(name: string): Nullable<Sound>;
  89718. /**
  89719. * Gets or sets if audio support is enabled
  89720. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89721. */
  89722. audioEnabled: boolean;
  89723. /**
  89724. * Gets or sets if audio will be output to headphones
  89725. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89726. */
  89727. headphone: boolean;
  89728. }
  89729. /**
  89730. * Defines the sound scene component responsible to manage any sounds
  89731. * in a given scene.
  89732. */
  89733. export class AudioSceneComponent implements ISceneSerializableComponent {
  89734. /**
  89735. * The component name helpfull to identify the component in the list of scene components.
  89736. */
  89737. readonly name: string;
  89738. /**
  89739. * The scene the component belongs to.
  89740. */
  89741. scene: Scene;
  89742. private _audioEnabled;
  89743. /**
  89744. * Gets whether audio is enabled or not.
  89745. * Please use related enable/disable method to switch state.
  89746. */
  89747. readonly audioEnabled: boolean;
  89748. private _headphone;
  89749. /**
  89750. * Gets whether audio is outputing to headphone or not.
  89751. * Please use the according Switch methods to change output.
  89752. */
  89753. readonly headphone: boolean;
  89754. /**
  89755. * Creates a new instance of the component for the given scene
  89756. * @param scene Defines the scene to register the component in
  89757. */
  89758. constructor(scene: Scene);
  89759. /**
  89760. * Registers the component in a given scene
  89761. */
  89762. register(): void;
  89763. /**
  89764. * Rebuilds the elements related to this component in case of
  89765. * context lost for instance.
  89766. */
  89767. rebuild(): void;
  89768. /**
  89769. * Serializes the component data to the specified json object
  89770. * @param serializationObject The object to serialize to
  89771. */
  89772. serialize(serializationObject: any): void;
  89773. /**
  89774. * Adds all the element from the container to the scene
  89775. * @param container the container holding the elements
  89776. */
  89777. addFromContainer(container: AbstractScene): void;
  89778. /**
  89779. * Removes all the elements in the container from the scene
  89780. * @param container contains the elements to remove
  89781. */
  89782. removeFromContainer(container: AbstractScene): void;
  89783. /**
  89784. * Disposes the component and the associated ressources.
  89785. */
  89786. dispose(): void;
  89787. /**
  89788. * Disables audio in the associated scene.
  89789. */
  89790. disableAudio(): void;
  89791. /**
  89792. * Enables audio in the associated scene.
  89793. */
  89794. enableAudio(): void;
  89795. /**
  89796. * Switch audio to headphone output.
  89797. */
  89798. switchAudioModeForHeadphones(): void;
  89799. /**
  89800. * Switch audio to normal speakers.
  89801. */
  89802. switchAudioModeForNormalSpeakers(): void;
  89803. private _afterRender;
  89804. }
  89805. }
  89806. declare module BABYLON {
  89807. /**
  89808. * Wraps one or more Sound objects and selects one with random weight for playback.
  89809. */
  89810. export class WeightedSound {
  89811. /** When true a Sound will be selected and played when the current playing Sound completes. */
  89812. loop: boolean;
  89813. private _coneInnerAngle;
  89814. private _coneOuterAngle;
  89815. private _volume;
  89816. /** A Sound is currently playing. */
  89817. isPlaying: boolean;
  89818. /** A Sound is currently paused. */
  89819. isPaused: boolean;
  89820. private _sounds;
  89821. private _weights;
  89822. private _currentIndex?;
  89823. /**
  89824. * Creates a new WeightedSound from the list of sounds given.
  89825. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  89826. * @param sounds Array of Sounds that will be selected from.
  89827. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  89828. */
  89829. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  89830. /**
  89831. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  89832. */
  89833. /**
  89834. * The size of cone in degress for a directional sound in which there will be no attenuation.
  89835. */
  89836. directionalConeInnerAngle: number;
  89837. /**
  89838. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  89839. * Listener angles between innerAngle and outerAngle will falloff linearly.
  89840. */
  89841. /**
  89842. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  89843. * Listener angles between innerAngle and outerAngle will falloff linearly.
  89844. */
  89845. directionalConeOuterAngle: number;
  89846. /**
  89847. * Playback volume.
  89848. */
  89849. /**
  89850. * Playback volume.
  89851. */
  89852. volume: number;
  89853. private _onended;
  89854. /**
  89855. * Suspend playback
  89856. */
  89857. pause(): void;
  89858. /**
  89859. * Stop playback
  89860. */
  89861. stop(): void;
  89862. /**
  89863. * Start playback.
  89864. * @param startOffset Position the clip head at a specific time in seconds.
  89865. */
  89866. play(startOffset?: number): void;
  89867. }
  89868. }
  89869. declare module BABYLON {
  89870. /**
  89871. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  89872. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  89873. */
  89874. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  89875. /**
  89876. * Gets the name of the behavior.
  89877. */
  89878. readonly name: string;
  89879. /**
  89880. * The easing function used by animations
  89881. */
  89882. static EasingFunction: BackEase;
  89883. /**
  89884. * The easing mode used by animations
  89885. */
  89886. static EasingMode: number;
  89887. /**
  89888. * The duration of the animation, in milliseconds
  89889. */
  89890. transitionDuration: number;
  89891. /**
  89892. * Length of the distance animated by the transition when lower radius is reached
  89893. */
  89894. lowerRadiusTransitionRange: number;
  89895. /**
  89896. * Length of the distance animated by the transition when upper radius is reached
  89897. */
  89898. upperRadiusTransitionRange: number;
  89899. private _autoTransitionRange;
  89900. /**
  89901. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  89902. */
  89903. /**
  89904. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  89905. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  89906. */
  89907. autoTransitionRange: boolean;
  89908. private _attachedCamera;
  89909. private _onAfterCheckInputsObserver;
  89910. private _onMeshTargetChangedObserver;
  89911. /**
  89912. * Initializes the behavior.
  89913. */
  89914. init(): void;
  89915. /**
  89916. * Attaches the behavior to its arc rotate camera.
  89917. * @param camera Defines the camera to attach the behavior to
  89918. */
  89919. attach(camera: ArcRotateCamera): void;
  89920. /**
  89921. * Detaches the behavior from its current arc rotate camera.
  89922. */
  89923. detach(): void;
  89924. private _radiusIsAnimating;
  89925. private _radiusBounceTransition;
  89926. private _animatables;
  89927. private _cachedWheelPrecision;
  89928. /**
  89929. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  89930. * @param radiusLimit The limit to check against.
  89931. * @return Bool to indicate if at limit.
  89932. */
  89933. private _isRadiusAtLimit;
  89934. /**
  89935. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  89936. * @param radiusDelta The delta by which to animate to. Can be negative.
  89937. */
  89938. private _applyBoundRadiusAnimation;
  89939. /**
  89940. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  89941. */
  89942. protected _clearAnimationLocks(): void;
  89943. /**
  89944. * Stops and removes all animations that have been applied to the camera
  89945. */
  89946. stopAllAnimations(): void;
  89947. }
  89948. }
  89949. declare module BABYLON {
  89950. /**
  89951. * 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.
  89952. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  89953. */
  89954. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  89955. /**
  89956. * Gets the name of the behavior.
  89957. */
  89958. readonly name: string;
  89959. private _mode;
  89960. private _radiusScale;
  89961. private _positionScale;
  89962. private _defaultElevation;
  89963. private _elevationReturnTime;
  89964. private _elevationReturnWaitTime;
  89965. private _zoomStopsAnimation;
  89966. private _framingTime;
  89967. /**
  89968. * The easing function used by animations
  89969. */
  89970. static EasingFunction: ExponentialEase;
  89971. /**
  89972. * The easing mode used by animations
  89973. */
  89974. static EasingMode: number;
  89975. /**
  89976. * Sets the current mode used by the behavior
  89977. */
  89978. /**
  89979. * Gets current mode used by the behavior.
  89980. */
  89981. mode: number;
  89982. /**
  89983. * Sets the scale applied to the radius (1 by default)
  89984. */
  89985. /**
  89986. * Gets the scale applied to the radius
  89987. */
  89988. radiusScale: number;
  89989. /**
  89990. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  89991. */
  89992. /**
  89993. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  89994. */
  89995. positionScale: number;
  89996. /**
  89997. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  89998. * behaviour is triggered, in radians.
  89999. */
  90000. /**
  90001. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  90002. * behaviour is triggered, in radians.
  90003. */
  90004. defaultElevation: number;
  90005. /**
  90006. * Sets the time (in milliseconds) taken to return to the default beta position.
  90007. * Negative value indicates camera should not return to default.
  90008. */
  90009. /**
  90010. * Gets the time (in milliseconds) taken to return to the default beta position.
  90011. * Negative value indicates camera should not return to default.
  90012. */
  90013. elevationReturnTime: number;
  90014. /**
  90015. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  90016. */
  90017. /**
  90018. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  90019. */
  90020. elevationReturnWaitTime: number;
  90021. /**
  90022. * Sets the flag that indicates if user zooming should stop animation.
  90023. */
  90024. /**
  90025. * Gets the flag that indicates if user zooming should stop animation.
  90026. */
  90027. zoomStopsAnimation: boolean;
  90028. /**
  90029. * Sets the transition time when framing the mesh, in milliseconds
  90030. */
  90031. /**
  90032. * Gets the transition time when framing the mesh, in milliseconds
  90033. */
  90034. framingTime: number;
  90035. /**
  90036. * Define if the behavior should automatically change the configured
  90037. * camera limits and sensibilities.
  90038. */
  90039. autoCorrectCameraLimitsAndSensibility: boolean;
  90040. private _onPrePointerObservableObserver;
  90041. private _onAfterCheckInputsObserver;
  90042. private _onMeshTargetChangedObserver;
  90043. private _attachedCamera;
  90044. private _isPointerDown;
  90045. private _lastInteractionTime;
  90046. /**
  90047. * Initializes the behavior.
  90048. */
  90049. init(): void;
  90050. /**
  90051. * Attaches the behavior to its arc rotate camera.
  90052. * @param camera Defines the camera to attach the behavior to
  90053. */
  90054. attach(camera: ArcRotateCamera): void;
  90055. /**
  90056. * Detaches the behavior from its current arc rotate camera.
  90057. */
  90058. detach(): void;
  90059. private _animatables;
  90060. private _betaIsAnimating;
  90061. private _betaTransition;
  90062. private _radiusTransition;
  90063. private _vectorTransition;
  90064. /**
  90065. * Targets the given mesh and updates zoom level accordingly.
  90066. * @param mesh The mesh to target.
  90067. * @param radius Optional. If a cached radius position already exists, overrides default.
  90068. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90069. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90070. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90071. */
  90072. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90073. /**
  90074. * Targets the given mesh with its children and updates zoom level accordingly.
  90075. * @param mesh The mesh to target.
  90076. * @param radius Optional. If a cached radius position already exists, overrides default.
  90077. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90078. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90079. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90080. */
  90081. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90082. /**
  90083. * Targets the given meshes with their children and updates zoom level accordingly.
  90084. * @param meshes The mesh to target.
  90085. * @param radius Optional. If a cached radius position already exists, overrides default.
  90086. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90087. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90088. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90089. */
  90090. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90091. /**
  90092. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  90093. * @param minimumWorld Determines the smaller position of the bounding box extend
  90094. * @param maximumWorld Determines the bigger position of the bounding box extend
  90095. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90096. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90097. */
  90098. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90099. /**
  90100. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  90101. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  90102. * frustum width.
  90103. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  90104. * to fully enclose the mesh in the viewing frustum.
  90105. */
  90106. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  90107. /**
  90108. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  90109. * is automatically returned to its default position (expected to be above ground plane).
  90110. */
  90111. private _maintainCameraAboveGround;
  90112. /**
  90113. * Returns the frustum slope based on the canvas ratio and camera FOV
  90114. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  90115. */
  90116. private _getFrustumSlope;
  90117. /**
  90118. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  90119. */
  90120. private _clearAnimationLocks;
  90121. /**
  90122. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  90123. */
  90124. private _applyUserInteraction;
  90125. /**
  90126. * Stops and removes all animations that have been applied to the camera
  90127. */
  90128. stopAllAnimations(): void;
  90129. /**
  90130. * Gets a value indicating if the user is moving the camera
  90131. */
  90132. readonly isUserIsMoving: boolean;
  90133. /**
  90134. * The camera can move all the way towards the mesh.
  90135. */
  90136. static IgnoreBoundsSizeMode: number;
  90137. /**
  90138. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  90139. */
  90140. static FitFrustumSidesMode: number;
  90141. }
  90142. }
  90143. declare module BABYLON {
  90144. /**
  90145. * Manage the pointers inputs to control an arc rotate camera.
  90146. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90147. */
  90148. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  90149. /**
  90150. * Defines the camera the input is attached to.
  90151. */
  90152. camera: ArcRotateCamera;
  90153. /**
  90154. * Defines the buttons associated with the input to handle camera move.
  90155. */
  90156. buttons: number[];
  90157. /**
  90158. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  90159. */
  90160. angularSensibilityX: number;
  90161. /**
  90162. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  90163. */
  90164. angularSensibilityY: number;
  90165. /**
  90166. * Defines the pointer pinch precision or how fast is the camera zooming.
  90167. */
  90168. pinchPrecision: number;
  90169. /**
  90170. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  90171. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90172. */
  90173. pinchDeltaPercentage: number;
  90174. /**
  90175. * Defines the pointer panning sensibility or how fast is the camera moving.
  90176. */
  90177. panningSensibility: number;
  90178. /**
  90179. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  90180. */
  90181. multiTouchPanning: boolean;
  90182. /**
  90183. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  90184. */
  90185. multiTouchPanAndZoom: boolean;
  90186. /**
  90187. * Revers pinch action direction.
  90188. */
  90189. pinchInwards: boolean;
  90190. private _isPanClick;
  90191. private _pointerInput;
  90192. private _observer;
  90193. private _onMouseMove;
  90194. private _onGestureStart;
  90195. private _onGesture;
  90196. private _MSGestureHandler;
  90197. private _onLostFocus;
  90198. private _onContextMenu;
  90199. /**
  90200. * Attach the input controls to a specific dom element to get the input from.
  90201. * @param element Defines the element the controls should be listened from
  90202. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90203. */
  90204. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90205. /**
  90206. * Detach the current controls from the specified dom element.
  90207. * @param element Defines the element to stop listening the inputs from
  90208. */
  90209. detachControl(element: Nullable<HTMLElement>): void;
  90210. /**
  90211. * Gets the class name of the current intput.
  90212. * @returns the class name
  90213. */
  90214. getClassName(): string;
  90215. /**
  90216. * Get the friendly name associated with the input class.
  90217. * @returns the input friendly name
  90218. */
  90219. getSimpleName(): string;
  90220. }
  90221. }
  90222. declare module BABYLON {
  90223. /**
  90224. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  90225. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90226. */
  90227. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  90228. /**
  90229. * Defines the camera the input is attached to.
  90230. */
  90231. camera: ArcRotateCamera;
  90232. /**
  90233. * Defines the list of key codes associated with the up action (increase alpha)
  90234. */
  90235. keysUp: number[];
  90236. /**
  90237. * Defines the list of key codes associated with the down action (decrease alpha)
  90238. */
  90239. keysDown: number[];
  90240. /**
  90241. * Defines the list of key codes associated with the left action (increase beta)
  90242. */
  90243. keysLeft: number[];
  90244. /**
  90245. * Defines the list of key codes associated with the right action (decrease beta)
  90246. */
  90247. keysRight: number[];
  90248. /**
  90249. * Defines the list of key codes associated with the reset action.
  90250. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  90251. */
  90252. keysReset: number[];
  90253. /**
  90254. * Defines the panning sensibility of the inputs.
  90255. * (How fast is the camera paning)
  90256. */
  90257. panningSensibility: number;
  90258. /**
  90259. * Defines the zooming sensibility of the inputs.
  90260. * (How fast is the camera zooming)
  90261. */
  90262. zoomingSensibility: number;
  90263. /**
  90264. * Defines wether maintaining the alt key down switch the movement mode from
  90265. * orientation to zoom.
  90266. */
  90267. useAltToZoom: boolean;
  90268. /**
  90269. * Rotation speed of the camera
  90270. */
  90271. angularSpeed: number;
  90272. private _keys;
  90273. private _ctrlPressed;
  90274. private _altPressed;
  90275. private _onCanvasBlurObserver;
  90276. private _onKeyboardObserver;
  90277. private _engine;
  90278. private _scene;
  90279. /**
  90280. * Attach the input controls to a specific dom element to get the input from.
  90281. * @param element Defines the element the controls should be listened from
  90282. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90283. */
  90284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90285. /**
  90286. * Detach the current controls from the specified dom element.
  90287. * @param element Defines the element to stop listening the inputs from
  90288. */
  90289. detachControl(element: Nullable<HTMLElement>): void;
  90290. /**
  90291. * Update the current camera state depending on the inputs that have been used this frame.
  90292. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90293. */
  90294. checkInputs(): void;
  90295. /**
  90296. * Gets the class name of the current intput.
  90297. * @returns the class name
  90298. */
  90299. getClassName(): string;
  90300. /**
  90301. * Get the friendly name associated with the input class.
  90302. * @returns the input friendly name
  90303. */
  90304. getSimpleName(): string;
  90305. }
  90306. }
  90307. declare module BABYLON {
  90308. /**
  90309. * Manage the mouse wheel inputs to control an arc rotate camera.
  90310. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90311. */
  90312. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  90313. /**
  90314. * Defines the camera the input is attached to.
  90315. */
  90316. camera: ArcRotateCamera;
  90317. /**
  90318. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  90319. */
  90320. wheelPrecision: number;
  90321. /**
  90322. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  90323. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  90324. */
  90325. wheelDeltaPercentage: number;
  90326. private _wheel;
  90327. private _observer;
  90328. /**
  90329. * Attach the input controls to a specific dom element to get the input from.
  90330. * @param element Defines the element the controls should be listened from
  90331. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90332. */
  90333. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90334. /**
  90335. * Detach the current controls from the specified dom element.
  90336. * @param element Defines the element to stop listening the inputs from
  90337. */
  90338. detachControl(element: Nullable<HTMLElement>): void;
  90339. /**
  90340. * Gets the class name of the current intput.
  90341. * @returns the class name
  90342. */
  90343. getClassName(): string;
  90344. /**
  90345. * Get the friendly name associated with the input class.
  90346. * @returns the input friendly name
  90347. */
  90348. getSimpleName(): string;
  90349. }
  90350. }
  90351. declare module BABYLON {
  90352. /**
  90353. * Default Inputs manager for the ArcRotateCamera.
  90354. * It groups all the default supported inputs for ease of use.
  90355. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90356. */
  90357. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  90358. /**
  90359. * Instantiates a new ArcRotateCameraInputsManager.
  90360. * @param camera Defines the camera the inputs belong to
  90361. */
  90362. constructor(camera: ArcRotateCamera);
  90363. /**
  90364. * Add mouse wheel input support to the input manager.
  90365. * @returns the current input manager
  90366. */
  90367. addMouseWheel(): ArcRotateCameraInputsManager;
  90368. /**
  90369. * Add pointers input support to the input manager.
  90370. * @returns the current input manager
  90371. */
  90372. addPointers(): ArcRotateCameraInputsManager;
  90373. /**
  90374. * Add keyboard input support to the input manager.
  90375. * @returns the current input manager
  90376. */
  90377. addKeyboard(): ArcRotateCameraInputsManager;
  90378. }
  90379. }
  90380. declare module BABYLON {
  90381. /**
  90382. * This represents an orbital type of camera.
  90383. *
  90384. * 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.
  90385. * 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.
  90386. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  90387. */
  90388. export class ArcRotateCamera extends TargetCamera {
  90389. /**
  90390. * Defines the rotation angle of the camera along the longitudinal axis.
  90391. */
  90392. alpha: number;
  90393. /**
  90394. * Defines the rotation angle of the camera along the latitudinal axis.
  90395. */
  90396. beta: number;
  90397. /**
  90398. * Defines the radius of the camera from it s target point.
  90399. */
  90400. radius: number;
  90401. protected _target: Vector3;
  90402. protected _targetHost: Nullable<AbstractMesh>;
  90403. /**
  90404. * Defines the target point of the camera.
  90405. * The camera looks towards it form the radius distance.
  90406. */
  90407. target: Vector3;
  90408. /**
  90409. * Current inertia value on the longitudinal axis.
  90410. * The bigger this number the longer it will take for the camera to stop.
  90411. */
  90412. inertialAlphaOffset: number;
  90413. /**
  90414. * Current inertia value on the latitudinal axis.
  90415. * The bigger this number the longer it will take for the camera to stop.
  90416. */
  90417. inertialBetaOffset: number;
  90418. /**
  90419. * Current inertia value on the radius axis.
  90420. * The bigger this number the longer it will take for the camera to stop.
  90421. */
  90422. inertialRadiusOffset: number;
  90423. /**
  90424. * Minimum allowed angle on the longitudinal axis.
  90425. * This can help limiting how the Camera is able to move in the scene.
  90426. */
  90427. lowerAlphaLimit: Nullable<number>;
  90428. /**
  90429. * Maximum allowed angle on the longitudinal axis.
  90430. * This can help limiting how the Camera is able to move in the scene.
  90431. */
  90432. upperAlphaLimit: Nullable<number>;
  90433. /**
  90434. * Minimum allowed angle on the latitudinal axis.
  90435. * This can help limiting how the Camera is able to move in the scene.
  90436. */
  90437. lowerBetaLimit: number;
  90438. /**
  90439. * Maximum allowed angle on the latitudinal axis.
  90440. * This can help limiting how the Camera is able to move in the scene.
  90441. */
  90442. upperBetaLimit: number;
  90443. /**
  90444. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  90445. * This can help limiting how the Camera is able to move in the scene.
  90446. */
  90447. lowerRadiusLimit: Nullable<number>;
  90448. /**
  90449. * Maximum allowed distance of the camera to the target (The camera can not get further).
  90450. * This can help limiting how the Camera is able to move in the scene.
  90451. */
  90452. upperRadiusLimit: Nullable<number>;
  90453. /**
  90454. * Defines the current inertia value used during panning of the camera along the X axis.
  90455. */
  90456. inertialPanningX: number;
  90457. /**
  90458. * Defines the current inertia value used during panning of the camera along the Y axis.
  90459. */
  90460. inertialPanningY: number;
  90461. /**
  90462. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  90463. * Basically if your fingers moves away from more than this distance you will be considered
  90464. * in pinch mode.
  90465. */
  90466. pinchToPanMaxDistance: number;
  90467. /**
  90468. * Defines the maximum distance the camera can pan.
  90469. * This could help keeping the cammera always in your scene.
  90470. */
  90471. panningDistanceLimit: Nullable<number>;
  90472. /**
  90473. * Defines the target of the camera before paning.
  90474. */
  90475. panningOriginTarget: Vector3;
  90476. /**
  90477. * Defines the value of the inertia used during panning.
  90478. * 0 would mean stop inertia and one would mean no decelleration at all.
  90479. */
  90480. panningInertia: number;
  90481. /**
  90482. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  90483. */
  90484. angularSensibilityX: number;
  90485. /**
  90486. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  90487. */
  90488. angularSensibilityY: number;
  90489. /**
  90490. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  90491. */
  90492. pinchPrecision: number;
  90493. /**
  90494. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  90495. * It will be used instead of pinchDeltaPrecision if different from 0.
  90496. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90497. */
  90498. pinchDeltaPercentage: number;
  90499. /**
  90500. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  90501. */
  90502. panningSensibility: number;
  90503. /**
  90504. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  90505. */
  90506. keysUp: number[];
  90507. /**
  90508. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  90509. */
  90510. keysDown: number[];
  90511. /**
  90512. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  90513. */
  90514. keysLeft: number[];
  90515. /**
  90516. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  90517. */
  90518. keysRight: number[];
  90519. /**
  90520. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  90521. */
  90522. wheelPrecision: number;
  90523. /**
  90524. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  90525. * It will be used instead of pinchDeltaPrecision if different from 0.
  90526. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90527. */
  90528. wheelDeltaPercentage: number;
  90529. /**
  90530. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  90531. */
  90532. zoomOnFactor: number;
  90533. /**
  90534. * Defines a screen offset for the camera position.
  90535. */
  90536. targetScreenOffset: Vector2;
  90537. /**
  90538. * Allows the camera to be completely reversed.
  90539. * If false the camera can not arrive upside down.
  90540. */
  90541. allowUpsideDown: boolean;
  90542. /**
  90543. * Define if double tap/click is used to restore the previously saved state of the camera.
  90544. */
  90545. useInputToRestoreState: boolean;
  90546. /** @hidden */
  90547. _viewMatrix: Matrix;
  90548. /** @hidden */
  90549. _useCtrlForPanning: boolean;
  90550. /** @hidden */
  90551. _panningMouseButton: number;
  90552. /**
  90553. * Defines the input associated to the camera.
  90554. */
  90555. inputs: ArcRotateCameraInputsManager;
  90556. /** @hidden */
  90557. _reset: () => void;
  90558. /**
  90559. * Defines the allowed panning axis.
  90560. */
  90561. panningAxis: Vector3;
  90562. protected _localDirection: Vector3;
  90563. protected _transformedDirection: Vector3;
  90564. private _bouncingBehavior;
  90565. /**
  90566. * Gets the bouncing behavior of the camera if it has been enabled.
  90567. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  90568. */
  90569. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  90570. /**
  90571. * Defines if the bouncing behavior of the camera is enabled on the camera.
  90572. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  90573. */
  90574. useBouncingBehavior: boolean;
  90575. private _framingBehavior;
  90576. /**
  90577. * Gets the framing behavior of the camera if it has been enabled.
  90578. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  90579. */
  90580. readonly framingBehavior: Nullable<FramingBehavior>;
  90581. /**
  90582. * Defines if the framing behavior of the camera is enabled on the camera.
  90583. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  90584. */
  90585. useFramingBehavior: boolean;
  90586. private _autoRotationBehavior;
  90587. /**
  90588. * Gets the auto rotation behavior of the camera if it has been enabled.
  90589. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  90590. */
  90591. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  90592. /**
  90593. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  90594. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  90595. */
  90596. useAutoRotationBehavior: boolean;
  90597. /**
  90598. * Observable triggered when the mesh target has been changed on the camera.
  90599. */
  90600. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  90601. /**
  90602. * Event raised when the camera is colliding with a mesh.
  90603. */
  90604. onCollide: (collidedMesh: AbstractMesh) => void;
  90605. /**
  90606. * Defines whether the camera should check collision with the objects oh the scene.
  90607. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  90608. */
  90609. checkCollisions: boolean;
  90610. /**
  90611. * Defines the collision radius of the camera.
  90612. * This simulates a sphere around the camera.
  90613. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  90614. */
  90615. collisionRadius: Vector3;
  90616. protected _collider: Collider;
  90617. protected _previousPosition: Vector3;
  90618. protected _collisionVelocity: Vector3;
  90619. protected _newPosition: Vector3;
  90620. protected _previousAlpha: number;
  90621. protected _previousBeta: number;
  90622. protected _previousRadius: number;
  90623. protected _collisionTriggered: boolean;
  90624. protected _targetBoundingCenter: Nullable<Vector3>;
  90625. private _computationVector;
  90626. private _tempAxisVector;
  90627. private _tempAxisRotationMatrix;
  90628. /**
  90629. * Instantiates a new ArcRotateCamera in a given scene
  90630. * @param name Defines the name of the camera
  90631. * @param alpha Defines the camera rotation along the logitudinal axis
  90632. * @param beta Defines the camera rotation along the latitudinal axis
  90633. * @param radius Defines the camera distance from its target
  90634. * @param target Defines the camera target
  90635. * @param scene Defines the scene the camera belongs to
  90636. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  90637. */
  90638. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90639. /** @hidden */
  90640. _initCache(): void;
  90641. /** @hidden */
  90642. _updateCache(ignoreParentClass?: boolean): void;
  90643. protected _getTargetPosition(): Vector3;
  90644. private _storedAlpha;
  90645. private _storedBeta;
  90646. private _storedRadius;
  90647. private _storedTarget;
  90648. /**
  90649. * Stores the current state of the camera (alpha, beta, radius and target)
  90650. * @returns the camera itself
  90651. */
  90652. storeState(): Camera;
  90653. /**
  90654. * @hidden
  90655. * Restored camera state. You must call storeState() first
  90656. */
  90657. _restoreStateValues(): boolean;
  90658. /** @hidden */
  90659. _isSynchronizedViewMatrix(): boolean;
  90660. /**
  90661. * Attached controls to the current camera.
  90662. * @param element Defines the element the controls should be listened from
  90663. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90664. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  90665. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  90666. */
  90667. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  90668. /**
  90669. * Detach the current controls from the camera.
  90670. * The camera will stop reacting to inputs.
  90671. * @param element Defines the element to stop listening the inputs from
  90672. */
  90673. detachControl(element: HTMLElement): void;
  90674. /** @hidden */
  90675. _checkInputs(): void;
  90676. protected _checkLimits(): void;
  90677. /**
  90678. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  90679. */
  90680. rebuildAnglesAndRadius(): void;
  90681. /**
  90682. * Use a position to define the current camera related information like aplha, beta and radius
  90683. * @param position Defines the position to set the camera at
  90684. */
  90685. setPosition(position: Vector3): void;
  90686. /**
  90687. * Defines the target the camera should look at.
  90688. * This will automatically adapt alpha beta and radius to fit within the new target.
  90689. * @param target Defines the new target as a Vector or a mesh
  90690. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  90691. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  90692. */
  90693. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  90694. /** @hidden */
  90695. _getViewMatrix(): Matrix;
  90696. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  90697. /**
  90698. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  90699. * @param meshes Defines the mesh to zoom on
  90700. * @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)
  90701. */
  90702. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  90703. /**
  90704. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  90705. * The target will be changed but the radius
  90706. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  90707. * @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)
  90708. */
  90709. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  90710. min: Vector3;
  90711. max: Vector3;
  90712. distance: number;
  90713. }, doNotUpdateMaxZ?: boolean): void;
  90714. /**
  90715. * @override
  90716. * Override Camera.createRigCamera
  90717. */
  90718. createRigCamera(name: string, cameraIndex: number): Camera;
  90719. /**
  90720. * @hidden
  90721. * @override
  90722. * Override Camera._updateRigCameras
  90723. */
  90724. _updateRigCameras(): void;
  90725. /**
  90726. * Destroy the camera and release the current resources hold by it.
  90727. */
  90728. dispose(): void;
  90729. /**
  90730. * Gets the current object class name.
  90731. * @return the class name
  90732. */
  90733. getClassName(): string;
  90734. }
  90735. }
  90736. declare module BABYLON {
  90737. /**
  90738. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  90739. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  90740. */
  90741. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  90742. /**
  90743. * Gets the name of the behavior.
  90744. */
  90745. readonly name: string;
  90746. private _zoomStopsAnimation;
  90747. private _idleRotationSpeed;
  90748. private _idleRotationWaitTime;
  90749. private _idleRotationSpinupTime;
  90750. /**
  90751. * Sets the flag that indicates if user zooming should stop animation.
  90752. */
  90753. /**
  90754. * Gets the flag that indicates if user zooming should stop animation.
  90755. */
  90756. zoomStopsAnimation: boolean;
  90757. /**
  90758. * Sets the default speed at which the camera rotates around the model.
  90759. */
  90760. /**
  90761. * Gets the default speed at which the camera rotates around the model.
  90762. */
  90763. idleRotationSpeed: number;
  90764. /**
  90765. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  90766. */
  90767. /**
  90768. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  90769. */
  90770. idleRotationWaitTime: number;
  90771. /**
  90772. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  90773. */
  90774. /**
  90775. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  90776. */
  90777. idleRotationSpinupTime: number;
  90778. /**
  90779. * Gets a value indicating if the camera is currently rotating because of this behavior
  90780. */
  90781. readonly rotationInProgress: boolean;
  90782. private _onPrePointerObservableObserver;
  90783. private _onAfterCheckInputsObserver;
  90784. private _attachedCamera;
  90785. private _isPointerDown;
  90786. private _lastFrameTime;
  90787. private _lastInteractionTime;
  90788. private _cameraRotationSpeed;
  90789. /**
  90790. * Initializes the behavior.
  90791. */
  90792. init(): void;
  90793. /**
  90794. * Attaches the behavior to its arc rotate camera.
  90795. * @param camera Defines the camera to attach the behavior to
  90796. */
  90797. attach(camera: ArcRotateCamera): void;
  90798. /**
  90799. * Detaches the behavior from its current arc rotate camera.
  90800. */
  90801. detach(): void;
  90802. /**
  90803. * Returns true if user is scrolling.
  90804. * @return true if user is scrolling.
  90805. */
  90806. private _userIsZooming;
  90807. private _lastFrameRadius;
  90808. private _shouldAnimationStopForInteraction;
  90809. /**
  90810. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  90811. */
  90812. private _applyUserInteraction;
  90813. private _userIsMoving;
  90814. }
  90815. }
  90816. declare module BABYLON {
  90817. /**
  90818. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  90819. */
  90820. export class AttachToBoxBehavior implements Behavior<Mesh> {
  90821. private ui;
  90822. /**
  90823. * The name of the behavior
  90824. */
  90825. name: string;
  90826. /**
  90827. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  90828. */
  90829. distanceAwayFromFace: number;
  90830. /**
  90831. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  90832. */
  90833. distanceAwayFromBottomOfFace: number;
  90834. private _faceVectors;
  90835. private _target;
  90836. private _scene;
  90837. private _onRenderObserver;
  90838. private _tmpMatrix;
  90839. private _tmpVector;
  90840. /**
  90841. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  90842. * @param ui The transform node that should be attched to the mesh
  90843. */
  90844. constructor(ui: TransformNode);
  90845. /**
  90846. * Initializes the behavior
  90847. */
  90848. init(): void;
  90849. private _closestFace;
  90850. private _zeroVector;
  90851. private _lookAtTmpMatrix;
  90852. private _lookAtToRef;
  90853. /**
  90854. * Attaches the AttachToBoxBehavior to the passed in mesh
  90855. * @param target The mesh that the specified node will be attached to
  90856. */
  90857. attach(target: Mesh): void;
  90858. /**
  90859. * Detaches the behavior from the mesh
  90860. */
  90861. detach(): void;
  90862. }
  90863. }
  90864. declare module BABYLON {
  90865. /**
  90866. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  90867. */
  90868. export class FadeInOutBehavior implements Behavior<Mesh> {
  90869. /**
  90870. * Time in milliseconds to delay before fading in (Default: 0)
  90871. */
  90872. delay: number;
  90873. /**
  90874. * Time in milliseconds for the mesh to fade in (Default: 300)
  90875. */
  90876. fadeInTime: number;
  90877. private _millisecondsPerFrame;
  90878. private _hovered;
  90879. private _hoverValue;
  90880. private _ownerNode;
  90881. /**
  90882. * Instatiates the FadeInOutBehavior
  90883. */
  90884. constructor();
  90885. /**
  90886. * The name of the behavior
  90887. */
  90888. readonly name: string;
  90889. /**
  90890. * Initializes the behavior
  90891. */
  90892. init(): void;
  90893. /**
  90894. * Attaches the fade behavior on the passed in mesh
  90895. * @param ownerNode The mesh that will be faded in/out once attached
  90896. */
  90897. attach(ownerNode: Mesh): void;
  90898. /**
  90899. * Detaches the behavior from the mesh
  90900. */
  90901. detach(): void;
  90902. /**
  90903. * Triggers the mesh to begin fading in or out
  90904. * @param value if the object should fade in or out (true to fade in)
  90905. */
  90906. fadeIn(value: boolean): void;
  90907. private _update;
  90908. private _setAllVisibility;
  90909. }
  90910. }
  90911. declare module BABYLON {
  90912. /**
  90913. * Class containing a set of static utilities functions for managing Pivots
  90914. * @hidden
  90915. */
  90916. export class PivotTools {
  90917. private static _PivotCached;
  90918. private static _OldPivotPoint;
  90919. private static _PivotTranslation;
  90920. private static _PivotTmpVector;
  90921. /** @hidden */
  90922. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  90923. /** @hidden */
  90924. static _RestorePivotPoint(mesh: AbstractMesh): void;
  90925. }
  90926. }
  90927. declare module BABYLON {
  90928. /**
  90929. * Class containing static functions to help procedurally build meshes
  90930. */
  90931. export class PlaneBuilder {
  90932. /**
  90933. * Creates a plane mesh
  90934. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  90935. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  90936. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  90937. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90938. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  90939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90940. * @param name defines the name of the mesh
  90941. * @param options defines the options used to create the mesh
  90942. * @param scene defines the hosting scene
  90943. * @returns the plane mesh
  90944. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  90945. */
  90946. static CreatePlane(name: string, options: {
  90947. size?: number;
  90948. width?: number;
  90949. height?: number;
  90950. sideOrientation?: number;
  90951. frontUVs?: Vector4;
  90952. backUVs?: Vector4;
  90953. updatable?: boolean;
  90954. sourcePlane?: Plane;
  90955. }, scene: Scene): Mesh;
  90956. }
  90957. }
  90958. declare module BABYLON {
  90959. /**
  90960. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  90961. */
  90962. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  90963. private static _AnyMouseID;
  90964. private _attachedNode;
  90965. private _dragPlane;
  90966. private _scene;
  90967. private _pointerObserver;
  90968. private _beforeRenderObserver;
  90969. private static _planeScene;
  90970. /**
  90971. * 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)
  90972. */
  90973. maxDragAngle: number;
  90974. /**
  90975. * @hidden
  90976. */
  90977. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  90978. /**
  90979. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  90980. */
  90981. currentDraggingPointerID: number;
  90982. /**
  90983. * The last position where the pointer hit the drag plane in world space
  90984. */
  90985. lastDragPosition: Vector3;
  90986. /**
  90987. * If the behavior is currently in a dragging state
  90988. */
  90989. dragging: boolean;
  90990. /**
  90991. * 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)
  90992. */
  90993. dragDeltaRatio: number;
  90994. /**
  90995. * If the drag plane orientation should be updated during the dragging (Default: true)
  90996. */
  90997. updateDragPlane: boolean;
  90998. private _debugMode;
  90999. private _moving;
  91000. /**
  91001. * Fires each time the attached mesh is dragged with the pointer
  91002. * * delta between last drag position and current drag position in world space
  91003. * * dragDistance along the drag axis
  91004. * * dragPlaneNormal normal of the current drag plane used during the drag
  91005. * * dragPlanePoint in world space where the drag intersects the drag plane
  91006. */
  91007. onDragObservable: Observable<{
  91008. delta: Vector3;
  91009. dragPlanePoint: Vector3;
  91010. dragPlaneNormal: Vector3;
  91011. dragDistance: number;
  91012. pointerId: number;
  91013. }>;
  91014. /**
  91015. * Fires each time a drag begins (eg. mouse down on mesh)
  91016. */
  91017. onDragStartObservable: Observable<{
  91018. dragPlanePoint: Vector3;
  91019. pointerId: number;
  91020. }>;
  91021. /**
  91022. * Fires each time a drag ends (eg. mouse release after drag)
  91023. */
  91024. onDragEndObservable: Observable<{
  91025. dragPlanePoint: Vector3;
  91026. pointerId: number;
  91027. }>;
  91028. /**
  91029. * If the attached mesh should be moved when dragged
  91030. */
  91031. moveAttached: boolean;
  91032. /**
  91033. * If the drag behavior will react to drag events (Default: true)
  91034. */
  91035. enabled: boolean;
  91036. /**
  91037. * If camera controls should be detached during the drag
  91038. */
  91039. detachCameraControls: boolean;
  91040. /**
  91041. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  91042. */
  91043. useObjectOrienationForDragging: boolean;
  91044. private _options;
  91045. /**
  91046. * Creates a pointer drag behavior that can be attached to a mesh
  91047. * @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)
  91048. */
  91049. constructor(options?: {
  91050. dragAxis?: Vector3;
  91051. dragPlaneNormal?: Vector3;
  91052. });
  91053. /**
  91054. * Predicate to determine if it is valid to move the object to a new position when it is moved
  91055. */
  91056. validateDrag: (targetPosition: Vector3) => boolean;
  91057. /**
  91058. * The name of the behavior
  91059. */
  91060. readonly name: string;
  91061. /**
  91062. * Initializes the behavior
  91063. */
  91064. init(): void;
  91065. private _tmpVector;
  91066. private _alternatePickedPoint;
  91067. private _worldDragAxis;
  91068. private _targetPosition;
  91069. private _attachedElement;
  91070. /**
  91071. * Attaches the drag behavior the passed in mesh
  91072. * @param ownerNode The mesh that will be dragged around once attached
  91073. */
  91074. attach(ownerNode: AbstractMesh): void;
  91075. /**
  91076. * Force relase the drag action by code.
  91077. */
  91078. releaseDrag(): void;
  91079. private _startDragRay;
  91080. private _lastPointerRay;
  91081. /**
  91082. * Simulates the start of a pointer drag event on the behavior
  91083. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  91084. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  91085. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  91086. */
  91087. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  91088. private _startDrag;
  91089. private _dragDelta;
  91090. private _moveDrag;
  91091. private _pickWithRayOnDragPlane;
  91092. private _pointA;
  91093. private _pointB;
  91094. private _pointC;
  91095. private _lineA;
  91096. private _lineB;
  91097. private _localAxis;
  91098. private _lookAt;
  91099. private _updateDragPlanePosition;
  91100. /**
  91101. * Detaches the behavior from the mesh
  91102. */
  91103. detach(): void;
  91104. }
  91105. }
  91106. declare module BABYLON {
  91107. /**
  91108. * A behavior that when attached to a mesh will allow the mesh to be scaled
  91109. */
  91110. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  91111. private _dragBehaviorA;
  91112. private _dragBehaviorB;
  91113. private _startDistance;
  91114. private _initialScale;
  91115. private _targetScale;
  91116. private _ownerNode;
  91117. private _sceneRenderObserver;
  91118. /**
  91119. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  91120. */
  91121. constructor();
  91122. /**
  91123. * The name of the behavior
  91124. */
  91125. readonly name: string;
  91126. /**
  91127. * Initializes the behavior
  91128. */
  91129. init(): void;
  91130. private _getCurrentDistance;
  91131. /**
  91132. * Attaches the scale behavior the passed in mesh
  91133. * @param ownerNode The mesh that will be scaled around once attached
  91134. */
  91135. attach(ownerNode: Mesh): void;
  91136. /**
  91137. * Detaches the behavior from the mesh
  91138. */
  91139. detach(): void;
  91140. }
  91141. }
  91142. declare module BABYLON {
  91143. /**
  91144. * 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
  91145. */
  91146. export class SixDofDragBehavior implements Behavior<Mesh> {
  91147. private static _virtualScene;
  91148. private _ownerNode;
  91149. private _sceneRenderObserver;
  91150. private _scene;
  91151. private _targetPosition;
  91152. private _virtualOriginMesh;
  91153. private _virtualDragMesh;
  91154. private _pointerObserver;
  91155. private _moving;
  91156. private _startingOrientation;
  91157. /**
  91158. * 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)
  91159. */
  91160. private zDragFactor;
  91161. /**
  91162. * If the object should rotate to face the drag origin
  91163. */
  91164. rotateDraggedObject: boolean;
  91165. /**
  91166. * If the behavior is currently in a dragging state
  91167. */
  91168. dragging: boolean;
  91169. /**
  91170. * 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)
  91171. */
  91172. dragDeltaRatio: number;
  91173. /**
  91174. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  91175. */
  91176. currentDraggingPointerID: number;
  91177. /**
  91178. * If camera controls should be detached during the drag
  91179. */
  91180. detachCameraControls: boolean;
  91181. /**
  91182. * Fires each time a drag starts
  91183. */
  91184. onDragStartObservable: Observable<{}>;
  91185. /**
  91186. * Fires each time a drag ends (eg. mouse release after drag)
  91187. */
  91188. onDragEndObservable: Observable<{}>;
  91189. /**
  91190. * 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
  91191. */
  91192. constructor();
  91193. /**
  91194. * The name of the behavior
  91195. */
  91196. readonly name: string;
  91197. /**
  91198. * Initializes the behavior
  91199. */
  91200. init(): void;
  91201. /**
  91202. * Attaches the scale behavior the passed in mesh
  91203. * @param ownerNode The mesh that will be scaled around once attached
  91204. */
  91205. attach(ownerNode: Mesh): void;
  91206. /**
  91207. * Detaches the behavior from the mesh
  91208. */
  91209. detach(): void;
  91210. }
  91211. }
  91212. declare module BABYLON {
  91213. /**
  91214. * Class used to apply inverse kinematics to bones
  91215. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  91216. */
  91217. export class BoneIKController {
  91218. private static _tmpVecs;
  91219. private static _tmpQuat;
  91220. private static _tmpMats;
  91221. /**
  91222. * Gets or sets the target mesh
  91223. */
  91224. targetMesh: AbstractMesh;
  91225. /** Gets or sets the mesh used as pole */
  91226. poleTargetMesh: AbstractMesh;
  91227. /**
  91228. * Gets or sets the bone used as pole
  91229. */
  91230. poleTargetBone: Nullable<Bone>;
  91231. /**
  91232. * Gets or sets the target position
  91233. */
  91234. targetPosition: Vector3;
  91235. /**
  91236. * Gets or sets the pole target position
  91237. */
  91238. poleTargetPosition: Vector3;
  91239. /**
  91240. * Gets or sets the pole target local offset
  91241. */
  91242. poleTargetLocalOffset: Vector3;
  91243. /**
  91244. * Gets or sets the pole angle
  91245. */
  91246. poleAngle: number;
  91247. /**
  91248. * Gets or sets the mesh associated with the controller
  91249. */
  91250. mesh: AbstractMesh;
  91251. /**
  91252. * 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)
  91253. */
  91254. slerpAmount: number;
  91255. private _bone1Quat;
  91256. private _bone1Mat;
  91257. private _bone2Ang;
  91258. private _bone1;
  91259. private _bone2;
  91260. private _bone1Length;
  91261. private _bone2Length;
  91262. private _maxAngle;
  91263. private _maxReach;
  91264. private _rightHandedSystem;
  91265. private _bendAxis;
  91266. private _slerping;
  91267. private _adjustRoll;
  91268. /**
  91269. * Gets or sets maximum allowed angle
  91270. */
  91271. maxAngle: number;
  91272. /**
  91273. * Creates a new BoneIKController
  91274. * @param mesh defines the mesh to control
  91275. * @param bone defines the bone to control
  91276. * @param options defines options to set up the controller
  91277. */
  91278. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  91279. targetMesh?: AbstractMesh;
  91280. poleTargetMesh?: AbstractMesh;
  91281. poleTargetBone?: Bone;
  91282. poleTargetLocalOffset?: Vector3;
  91283. poleAngle?: number;
  91284. bendAxis?: Vector3;
  91285. maxAngle?: number;
  91286. slerpAmount?: number;
  91287. });
  91288. private _setMaxAngle;
  91289. /**
  91290. * Force the controller to update the bones
  91291. */
  91292. update(): void;
  91293. }
  91294. }
  91295. declare module BABYLON {
  91296. /**
  91297. * Class used to make a bone look toward a point in space
  91298. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  91299. */
  91300. export class BoneLookController {
  91301. private static _tmpVecs;
  91302. private static _tmpQuat;
  91303. private static _tmpMats;
  91304. /**
  91305. * The target Vector3 that the bone will look at
  91306. */
  91307. target: Vector3;
  91308. /**
  91309. * The mesh that the bone is attached to
  91310. */
  91311. mesh: AbstractMesh;
  91312. /**
  91313. * The bone that will be looking to the target
  91314. */
  91315. bone: Bone;
  91316. /**
  91317. * The up axis of the coordinate system that is used when the bone is rotated
  91318. */
  91319. upAxis: Vector3;
  91320. /**
  91321. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  91322. */
  91323. upAxisSpace: Space;
  91324. /**
  91325. * Used to make an adjustment to the yaw of the bone
  91326. */
  91327. adjustYaw: number;
  91328. /**
  91329. * Used to make an adjustment to the pitch of the bone
  91330. */
  91331. adjustPitch: number;
  91332. /**
  91333. * Used to make an adjustment to the roll of the bone
  91334. */
  91335. adjustRoll: number;
  91336. /**
  91337. * 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)
  91338. */
  91339. slerpAmount: number;
  91340. private _minYaw;
  91341. private _maxYaw;
  91342. private _minPitch;
  91343. private _maxPitch;
  91344. private _minYawSin;
  91345. private _minYawCos;
  91346. private _maxYawSin;
  91347. private _maxYawCos;
  91348. private _midYawConstraint;
  91349. private _minPitchTan;
  91350. private _maxPitchTan;
  91351. private _boneQuat;
  91352. private _slerping;
  91353. private _transformYawPitch;
  91354. private _transformYawPitchInv;
  91355. private _firstFrameSkipped;
  91356. private _yawRange;
  91357. private _fowardAxis;
  91358. /**
  91359. * Gets or sets the minimum yaw angle that the bone can look to
  91360. */
  91361. minYaw: number;
  91362. /**
  91363. * Gets or sets the maximum yaw angle that the bone can look to
  91364. */
  91365. maxYaw: number;
  91366. /**
  91367. * Gets or sets the minimum pitch angle that the bone can look to
  91368. */
  91369. minPitch: number;
  91370. /**
  91371. * Gets or sets the maximum pitch angle that the bone can look to
  91372. */
  91373. maxPitch: number;
  91374. /**
  91375. * Create a BoneLookController
  91376. * @param mesh the mesh that the bone belongs to
  91377. * @param bone the bone that will be looking to the target
  91378. * @param target the target Vector3 to look at
  91379. * @param options optional settings:
  91380. * * maxYaw: the maximum angle the bone will yaw to
  91381. * * minYaw: the minimum angle the bone will yaw to
  91382. * * maxPitch: the maximum angle the bone will pitch to
  91383. * * minPitch: the minimum angle the bone will yaw to
  91384. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  91385. * * upAxis: the up axis of the coordinate system
  91386. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  91387. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  91388. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  91389. * * adjustYaw: used to make an adjustment to the yaw of the bone
  91390. * * adjustPitch: used to make an adjustment to the pitch of the bone
  91391. * * adjustRoll: used to make an adjustment to the roll of the bone
  91392. **/
  91393. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  91394. maxYaw?: number;
  91395. minYaw?: number;
  91396. maxPitch?: number;
  91397. minPitch?: number;
  91398. slerpAmount?: number;
  91399. upAxis?: Vector3;
  91400. upAxisSpace?: Space;
  91401. yawAxis?: Vector3;
  91402. pitchAxis?: Vector3;
  91403. adjustYaw?: number;
  91404. adjustPitch?: number;
  91405. adjustRoll?: number;
  91406. });
  91407. /**
  91408. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  91409. */
  91410. update(): void;
  91411. private _getAngleDiff;
  91412. private _getAngleBetween;
  91413. private _isAngleBetween;
  91414. }
  91415. }
  91416. declare module BABYLON {
  91417. /**
  91418. * Manage the gamepad inputs to control an arc rotate camera.
  91419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91420. */
  91421. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  91422. /**
  91423. * Defines the camera the input is attached to.
  91424. */
  91425. camera: ArcRotateCamera;
  91426. /**
  91427. * Defines the gamepad the input is gathering event from.
  91428. */
  91429. gamepad: Nullable<Gamepad>;
  91430. /**
  91431. * Defines the gamepad rotation sensiblity.
  91432. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  91433. */
  91434. gamepadRotationSensibility: number;
  91435. /**
  91436. * Defines the gamepad move sensiblity.
  91437. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  91438. */
  91439. gamepadMoveSensibility: number;
  91440. private _onGamepadConnectedObserver;
  91441. private _onGamepadDisconnectedObserver;
  91442. /**
  91443. * Attach the input controls to a specific dom element to get the input from.
  91444. * @param element Defines the element the controls should be listened from
  91445. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91446. */
  91447. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91448. /**
  91449. * Detach the current controls from the specified dom element.
  91450. * @param element Defines the element to stop listening the inputs from
  91451. */
  91452. detachControl(element: Nullable<HTMLElement>): void;
  91453. /**
  91454. * Update the current camera state depending on the inputs that have been used this frame.
  91455. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91456. */
  91457. checkInputs(): void;
  91458. /**
  91459. * Gets the class name of the current intput.
  91460. * @returns the class name
  91461. */
  91462. getClassName(): string;
  91463. /**
  91464. * Get the friendly name associated with the input class.
  91465. * @returns the input friendly name
  91466. */
  91467. getSimpleName(): string;
  91468. }
  91469. }
  91470. declare module BABYLON {
  91471. interface ArcRotateCameraInputsManager {
  91472. /**
  91473. * Add orientation input support to the input manager.
  91474. * @returns the current input manager
  91475. */
  91476. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  91477. }
  91478. /**
  91479. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  91480. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91481. */
  91482. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  91483. /**
  91484. * Defines the camera the input is attached to.
  91485. */
  91486. camera: ArcRotateCamera;
  91487. /**
  91488. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  91489. */
  91490. alphaCorrection: number;
  91491. /**
  91492. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  91493. */
  91494. gammaCorrection: number;
  91495. private _alpha;
  91496. private _gamma;
  91497. private _dirty;
  91498. private _deviceOrientationHandler;
  91499. /**
  91500. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  91501. */
  91502. constructor();
  91503. /**
  91504. * Attach the input controls to a specific dom element to get the input from.
  91505. * @param element Defines the element the controls should be listened from
  91506. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91507. */
  91508. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91509. /** @hidden */
  91510. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  91511. /**
  91512. * Update the current camera state depending on the inputs that have been used this frame.
  91513. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91514. */
  91515. checkInputs(): void;
  91516. /**
  91517. * Detach the current controls from the specified dom element.
  91518. * @param element Defines the element to stop listening the inputs from
  91519. */
  91520. detachControl(element: Nullable<HTMLElement>): void;
  91521. /**
  91522. * Gets the class name of the current intput.
  91523. * @returns the class name
  91524. */
  91525. getClassName(): string;
  91526. /**
  91527. * Get the friendly name associated with the input class.
  91528. * @returns the input friendly name
  91529. */
  91530. getSimpleName(): string;
  91531. }
  91532. }
  91533. declare module BABYLON {
  91534. /**
  91535. * Listen to mouse events to control the camera.
  91536. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91537. */
  91538. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  91539. /**
  91540. * Defines the camera the input is attached to.
  91541. */
  91542. camera: FlyCamera;
  91543. /**
  91544. * Defines if touch is enabled. (Default is true.)
  91545. */
  91546. touchEnabled: boolean;
  91547. /**
  91548. * Defines the buttons associated with the input to handle camera rotation.
  91549. */
  91550. buttons: number[];
  91551. /**
  91552. * Assign buttons for Yaw control.
  91553. */
  91554. buttonsYaw: number[];
  91555. /**
  91556. * Assign buttons for Pitch control.
  91557. */
  91558. buttonsPitch: number[];
  91559. /**
  91560. * Assign buttons for Roll control.
  91561. */
  91562. buttonsRoll: number[];
  91563. /**
  91564. * Detect if any button is being pressed while mouse is moved.
  91565. * -1 = Mouse locked.
  91566. * 0 = Left button.
  91567. * 1 = Middle Button.
  91568. * 2 = Right Button.
  91569. */
  91570. activeButton: number;
  91571. /**
  91572. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  91573. * Higher values reduce its sensitivity.
  91574. */
  91575. angularSensibility: number;
  91576. private _mousemoveCallback;
  91577. private _observer;
  91578. private _rollObserver;
  91579. private previousPosition;
  91580. private noPreventDefault;
  91581. private element;
  91582. /**
  91583. * Listen to mouse events to control the camera.
  91584. * @param touchEnabled Define if touch is enabled. (Default is true.)
  91585. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91586. */
  91587. constructor(touchEnabled?: boolean);
  91588. /**
  91589. * Attach the mouse control to the HTML DOM element.
  91590. * @param element Defines the element that listens to the input events.
  91591. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  91592. */
  91593. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91594. /**
  91595. * Detach the current controls from the specified dom element.
  91596. * @param element Defines the element to stop listening the inputs from
  91597. */
  91598. detachControl(element: Nullable<HTMLElement>): void;
  91599. /**
  91600. * Gets the class name of the current input.
  91601. * @returns the class name.
  91602. */
  91603. getClassName(): string;
  91604. /**
  91605. * Get the friendly name associated with the input class.
  91606. * @returns the input's friendly name.
  91607. */
  91608. getSimpleName(): string;
  91609. private _pointerInput;
  91610. private _onMouseMove;
  91611. /**
  91612. * Rotate camera by mouse offset.
  91613. */
  91614. private rotateCamera;
  91615. }
  91616. }
  91617. declare module BABYLON {
  91618. /**
  91619. * Default Inputs manager for the FlyCamera.
  91620. * It groups all the default supported inputs for ease of use.
  91621. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91622. */
  91623. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  91624. /**
  91625. * Instantiates a new FlyCameraInputsManager.
  91626. * @param camera Defines the camera the inputs belong to.
  91627. */
  91628. constructor(camera: FlyCamera);
  91629. /**
  91630. * Add keyboard input support to the input manager.
  91631. * @returns the new FlyCameraKeyboardMoveInput().
  91632. */
  91633. addKeyboard(): FlyCameraInputsManager;
  91634. /**
  91635. * Add mouse input support to the input manager.
  91636. * @param touchEnabled Enable touch screen support.
  91637. * @returns the new FlyCameraMouseInput().
  91638. */
  91639. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  91640. }
  91641. }
  91642. declare module BABYLON {
  91643. /**
  91644. * This is a flying camera, designed for 3D movement and rotation in all directions,
  91645. * such as in a 3D Space Shooter or a Flight Simulator.
  91646. */
  91647. export class FlyCamera extends TargetCamera {
  91648. /**
  91649. * Define the collision ellipsoid of the camera.
  91650. * This is helpful for simulating a camera body, like a player's body.
  91651. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91652. */
  91653. ellipsoid: Vector3;
  91654. /**
  91655. * Define an offset for the position of the ellipsoid around the camera.
  91656. * This can be helpful if the camera is attached away from the player's body center,
  91657. * such as at its head.
  91658. */
  91659. ellipsoidOffset: Vector3;
  91660. /**
  91661. * Enable or disable collisions of the camera with the rest of the scene objects.
  91662. */
  91663. checkCollisions: boolean;
  91664. /**
  91665. * Enable or disable gravity on the camera.
  91666. */
  91667. applyGravity: boolean;
  91668. /**
  91669. * Define the current direction the camera is moving to.
  91670. */
  91671. cameraDirection: Vector3;
  91672. /**
  91673. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  91674. * This overrides and empties cameraRotation.
  91675. */
  91676. rotationQuaternion: Quaternion;
  91677. /**
  91678. * Track Roll to maintain the wanted Rolling when looking around.
  91679. */
  91680. _trackRoll: number;
  91681. /**
  91682. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  91683. */
  91684. rollCorrect: number;
  91685. /**
  91686. * Mimic a banked turn, Rolling the camera when Yawing.
  91687. * It's recommended to use rollCorrect = 10 for faster banking correction.
  91688. */
  91689. bankedTurn: boolean;
  91690. /**
  91691. * Limit in radians for how much Roll banking will add. (Default: 90°)
  91692. */
  91693. bankedTurnLimit: number;
  91694. /**
  91695. * Value of 0 disables the banked Roll.
  91696. * Value of 1 is equal to the Yaw angle in radians.
  91697. */
  91698. bankedTurnMultiplier: number;
  91699. /**
  91700. * The inputs manager loads all the input sources, such as keyboard and mouse.
  91701. */
  91702. inputs: FlyCameraInputsManager;
  91703. /**
  91704. * Gets the input sensibility for mouse input.
  91705. * Higher values reduce sensitivity.
  91706. */
  91707. /**
  91708. * Sets the input sensibility for a mouse input.
  91709. * Higher values reduce sensitivity.
  91710. */
  91711. angularSensibility: number;
  91712. /**
  91713. * Get the keys for camera movement forward.
  91714. */
  91715. /**
  91716. * Set the keys for camera movement forward.
  91717. */
  91718. keysForward: number[];
  91719. /**
  91720. * Get the keys for camera movement backward.
  91721. */
  91722. keysBackward: number[];
  91723. /**
  91724. * Get the keys for camera movement up.
  91725. */
  91726. /**
  91727. * Set the keys for camera movement up.
  91728. */
  91729. keysUp: number[];
  91730. /**
  91731. * Get the keys for camera movement down.
  91732. */
  91733. /**
  91734. * Set the keys for camera movement down.
  91735. */
  91736. keysDown: number[];
  91737. /**
  91738. * Get the keys for camera movement left.
  91739. */
  91740. /**
  91741. * Set the keys for camera movement left.
  91742. */
  91743. keysLeft: number[];
  91744. /**
  91745. * Set the keys for camera movement right.
  91746. */
  91747. /**
  91748. * Set the keys for camera movement right.
  91749. */
  91750. keysRight: number[];
  91751. /**
  91752. * Event raised when the camera collides with a mesh in the scene.
  91753. */
  91754. onCollide: (collidedMesh: AbstractMesh) => void;
  91755. private _collider;
  91756. private _needMoveForGravity;
  91757. private _oldPosition;
  91758. private _diffPosition;
  91759. private _newPosition;
  91760. /** @hidden */
  91761. _localDirection: Vector3;
  91762. /** @hidden */
  91763. _transformedDirection: Vector3;
  91764. /**
  91765. * Instantiates a FlyCamera.
  91766. * This is a flying camera, designed for 3D movement and rotation in all directions,
  91767. * such as in a 3D Space Shooter or a Flight Simulator.
  91768. * @param name Define the name of the camera in the scene.
  91769. * @param position Define the starting position of the camera in the scene.
  91770. * @param scene Define the scene the camera belongs to.
  91771. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  91772. */
  91773. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91774. /**
  91775. * Attach a control to the HTML DOM element.
  91776. * @param element Defines the element that listens to the input events.
  91777. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  91778. */
  91779. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91780. /**
  91781. * Detach a control from the HTML DOM element.
  91782. * The camera will stop reacting to that input.
  91783. * @param element Defines the element that listens to the input events.
  91784. */
  91785. detachControl(element: HTMLElement): void;
  91786. private _collisionMask;
  91787. /**
  91788. * Get the mask that the camera ignores in collision events.
  91789. */
  91790. /**
  91791. * Set the mask that the camera ignores in collision events.
  91792. */
  91793. collisionMask: number;
  91794. /** @hidden */
  91795. _collideWithWorld(displacement: Vector3): void;
  91796. /** @hidden */
  91797. private _onCollisionPositionChange;
  91798. /** @hidden */
  91799. _checkInputs(): void;
  91800. /** @hidden */
  91801. _decideIfNeedsToMove(): boolean;
  91802. /** @hidden */
  91803. _updatePosition(): void;
  91804. /**
  91805. * Restore the Roll to its target value at the rate specified.
  91806. * @param rate - Higher means slower restoring.
  91807. * @hidden
  91808. */
  91809. restoreRoll(rate: number): void;
  91810. /**
  91811. * Destroy the camera and release the current resources held by it.
  91812. */
  91813. dispose(): void;
  91814. /**
  91815. * Get the current object class name.
  91816. * @returns the class name.
  91817. */
  91818. getClassName(): string;
  91819. }
  91820. }
  91821. declare module BABYLON {
  91822. /**
  91823. * Listen to keyboard events to control the camera.
  91824. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91825. */
  91826. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  91827. /**
  91828. * Defines the camera the input is attached to.
  91829. */
  91830. camera: FlyCamera;
  91831. /**
  91832. * The list of keyboard keys used to control the forward move of the camera.
  91833. */
  91834. keysForward: number[];
  91835. /**
  91836. * The list of keyboard keys used to control the backward move of the camera.
  91837. */
  91838. keysBackward: number[];
  91839. /**
  91840. * The list of keyboard keys used to control the forward move of the camera.
  91841. */
  91842. keysUp: number[];
  91843. /**
  91844. * The list of keyboard keys used to control the backward move of the camera.
  91845. */
  91846. keysDown: number[];
  91847. /**
  91848. * The list of keyboard keys used to control the right strafe move of the camera.
  91849. */
  91850. keysRight: number[];
  91851. /**
  91852. * The list of keyboard keys used to control the left strafe move of the camera.
  91853. */
  91854. keysLeft: number[];
  91855. private _keys;
  91856. private _onCanvasBlurObserver;
  91857. private _onKeyboardObserver;
  91858. private _engine;
  91859. private _scene;
  91860. /**
  91861. * Attach the input controls to a specific dom element to get the input from.
  91862. * @param element Defines the element the controls should be listened from
  91863. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91864. */
  91865. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91866. /**
  91867. * Detach the current controls from the specified dom element.
  91868. * @param element Defines the element to stop listening the inputs from
  91869. */
  91870. detachControl(element: Nullable<HTMLElement>): void;
  91871. /**
  91872. * Gets the class name of the current intput.
  91873. * @returns the class name
  91874. */
  91875. getClassName(): string;
  91876. /** @hidden */
  91877. _onLostFocus(e: FocusEvent): void;
  91878. /**
  91879. * Get the friendly name associated with the input class.
  91880. * @returns the input friendly name
  91881. */
  91882. getSimpleName(): string;
  91883. /**
  91884. * Update the current camera state depending on the inputs that have been used this frame.
  91885. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91886. */
  91887. checkInputs(): void;
  91888. }
  91889. }
  91890. declare module BABYLON {
  91891. interface FreeCameraInputsManager {
  91892. /**
  91893. * Add orientation input support to the input manager.
  91894. * @returns the current input manager
  91895. */
  91896. addDeviceOrientation(): FreeCameraInputsManager;
  91897. }
  91898. /**
  91899. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  91900. * Screen rotation is taken into account.
  91901. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91902. */
  91903. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  91904. private _camera;
  91905. private _screenOrientationAngle;
  91906. private _constantTranform;
  91907. private _screenQuaternion;
  91908. private _alpha;
  91909. private _beta;
  91910. private _gamma;
  91911. /**
  91912. * Instantiates a new input
  91913. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91914. */
  91915. constructor();
  91916. /**
  91917. * Define the camera controlled by the input.
  91918. */
  91919. camera: FreeCamera;
  91920. /**
  91921. * Attach the input controls to a specific dom element to get the input from.
  91922. * @param element Defines the element the controls should be listened from
  91923. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91924. */
  91925. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91926. private _orientationChanged;
  91927. private _deviceOrientation;
  91928. /**
  91929. * Detach the current controls from the specified dom element.
  91930. * @param element Defines the element to stop listening the inputs from
  91931. */
  91932. detachControl(element: Nullable<HTMLElement>): void;
  91933. /**
  91934. * Update the current camera state depending on the inputs that have been used this frame.
  91935. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91936. */
  91937. checkInputs(): void;
  91938. /**
  91939. * Gets the class name of the current intput.
  91940. * @returns the class name
  91941. */
  91942. getClassName(): string;
  91943. /**
  91944. * Get the friendly name associated with the input class.
  91945. * @returns the input friendly name
  91946. */
  91947. getSimpleName(): string;
  91948. }
  91949. }
  91950. declare module BABYLON {
  91951. /**
  91952. * Manage the gamepad inputs to control a free camera.
  91953. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91954. */
  91955. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  91956. /**
  91957. * Define the camera the input is attached to.
  91958. */
  91959. camera: FreeCamera;
  91960. /**
  91961. * Define the Gamepad controlling the input
  91962. */
  91963. gamepad: Nullable<Gamepad>;
  91964. /**
  91965. * Defines the gamepad rotation sensiblity.
  91966. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  91967. */
  91968. gamepadAngularSensibility: number;
  91969. /**
  91970. * Defines the gamepad move sensiblity.
  91971. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  91972. */
  91973. gamepadMoveSensibility: number;
  91974. private _onGamepadConnectedObserver;
  91975. private _onGamepadDisconnectedObserver;
  91976. private _cameraTransform;
  91977. private _deltaTransform;
  91978. private _vector3;
  91979. private _vector2;
  91980. /**
  91981. * Attach the input controls to a specific dom element to get the input from.
  91982. * @param element Defines the element the controls should be listened from
  91983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91984. */
  91985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91986. /**
  91987. * Detach the current controls from the specified dom element.
  91988. * @param element Defines the element to stop listening the inputs from
  91989. */
  91990. detachControl(element: Nullable<HTMLElement>): void;
  91991. /**
  91992. * Update the current camera state depending on the inputs that have been used this frame.
  91993. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91994. */
  91995. checkInputs(): void;
  91996. /**
  91997. * Gets the class name of the current intput.
  91998. * @returns the class name
  91999. */
  92000. getClassName(): string;
  92001. /**
  92002. * Get the friendly name associated with the input class.
  92003. * @returns the input friendly name
  92004. */
  92005. getSimpleName(): string;
  92006. }
  92007. }
  92008. declare module BABYLON {
  92009. /**
  92010. * Defines the potential axis of a Joystick
  92011. */
  92012. export enum JoystickAxis {
  92013. /** X axis */
  92014. X = 0,
  92015. /** Y axis */
  92016. Y = 1,
  92017. /** Z axis */
  92018. Z = 2
  92019. }
  92020. /**
  92021. * Class used to define virtual joystick (used in touch mode)
  92022. */
  92023. export class VirtualJoystick {
  92024. /**
  92025. * Gets or sets a boolean indicating that left and right values must be inverted
  92026. */
  92027. reverseLeftRight: boolean;
  92028. /**
  92029. * Gets or sets a boolean indicating that up and down values must be inverted
  92030. */
  92031. reverseUpDown: boolean;
  92032. /**
  92033. * Gets the offset value for the position (ie. the change of the position value)
  92034. */
  92035. deltaPosition: Vector3;
  92036. /**
  92037. * Gets a boolean indicating if the virtual joystick was pressed
  92038. */
  92039. pressed: boolean;
  92040. /**
  92041. * Canvas the virtual joystick will render onto, default z-index of this is 5
  92042. */
  92043. static Canvas: Nullable<HTMLCanvasElement>;
  92044. private static _globalJoystickIndex;
  92045. private static vjCanvasContext;
  92046. private static vjCanvasWidth;
  92047. private static vjCanvasHeight;
  92048. private static halfWidth;
  92049. private _action;
  92050. private _axisTargetedByLeftAndRight;
  92051. private _axisTargetedByUpAndDown;
  92052. private _joystickSensibility;
  92053. private _inversedSensibility;
  92054. private _joystickPointerID;
  92055. private _joystickColor;
  92056. private _joystickPointerPos;
  92057. private _joystickPreviousPointerPos;
  92058. private _joystickPointerStartPos;
  92059. private _deltaJoystickVector;
  92060. private _leftJoystick;
  92061. private _touches;
  92062. private _onPointerDownHandlerRef;
  92063. private _onPointerMoveHandlerRef;
  92064. private _onPointerUpHandlerRef;
  92065. private _onResize;
  92066. /**
  92067. * Creates a new virtual joystick
  92068. * @param leftJoystick defines that the joystick is for left hand (false by default)
  92069. */
  92070. constructor(leftJoystick?: boolean);
  92071. /**
  92072. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  92073. * @param newJoystickSensibility defines the new sensibility
  92074. */
  92075. setJoystickSensibility(newJoystickSensibility: number): void;
  92076. private _onPointerDown;
  92077. private _onPointerMove;
  92078. private _onPointerUp;
  92079. /**
  92080. * Change the color of the virtual joystick
  92081. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  92082. */
  92083. setJoystickColor(newColor: string): void;
  92084. /**
  92085. * Defines a callback to call when the joystick is touched
  92086. * @param action defines the callback
  92087. */
  92088. setActionOnTouch(action: () => any): void;
  92089. /**
  92090. * Defines which axis you'd like to control for left & right
  92091. * @param axis defines the axis to use
  92092. */
  92093. setAxisForLeftRight(axis: JoystickAxis): void;
  92094. /**
  92095. * Defines which axis you'd like to control for up & down
  92096. * @param axis defines the axis to use
  92097. */
  92098. setAxisForUpDown(axis: JoystickAxis): void;
  92099. private _drawVirtualJoystick;
  92100. /**
  92101. * Release internal HTML canvas
  92102. */
  92103. releaseCanvas(): void;
  92104. }
  92105. }
  92106. declare module BABYLON {
  92107. interface FreeCameraInputsManager {
  92108. /**
  92109. * Add virtual joystick input support to the input manager.
  92110. * @returns the current input manager
  92111. */
  92112. addVirtualJoystick(): FreeCameraInputsManager;
  92113. }
  92114. /**
  92115. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  92116. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92117. */
  92118. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  92119. /**
  92120. * Defines the camera the input is attached to.
  92121. */
  92122. camera: FreeCamera;
  92123. private _leftjoystick;
  92124. private _rightjoystick;
  92125. /**
  92126. * Gets the left stick of the virtual joystick.
  92127. * @returns The virtual Joystick
  92128. */
  92129. getLeftJoystick(): VirtualJoystick;
  92130. /**
  92131. * Gets the right stick of the virtual joystick.
  92132. * @returns The virtual Joystick
  92133. */
  92134. getRightJoystick(): VirtualJoystick;
  92135. /**
  92136. * Update the current camera state depending on the inputs that have been used this frame.
  92137. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92138. */
  92139. checkInputs(): void;
  92140. /**
  92141. * Attach the input controls to a specific dom element to get the input from.
  92142. * @param element Defines the element the controls should be listened from
  92143. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92144. */
  92145. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92146. /**
  92147. * Detach the current controls from the specified dom element.
  92148. * @param element Defines the element to stop listening the inputs from
  92149. */
  92150. detachControl(element: Nullable<HTMLElement>): void;
  92151. /**
  92152. * Gets the class name of the current intput.
  92153. * @returns the class name
  92154. */
  92155. getClassName(): string;
  92156. /**
  92157. * Get the friendly name associated with the input class.
  92158. * @returns the input friendly name
  92159. */
  92160. getSimpleName(): string;
  92161. }
  92162. }
  92163. declare module BABYLON {
  92164. /**
  92165. * This represents a FPS type of camera controlled by touch.
  92166. * This is like a universal camera minus the Gamepad controls.
  92167. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92168. */
  92169. export class TouchCamera extends FreeCamera {
  92170. /**
  92171. * Defines the touch sensibility for rotation.
  92172. * The higher the faster.
  92173. */
  92174. touchAngularSensibility: number;
  92175. /**
  92176. * Defines the touch sensibility for move.
  92177. * The higher the faster.
  92178. */
  92179. touchMoveSensibility: number;
  92180. /**
  92181. * Instantiates a new touch camera.
  92182. * This represents a FPS type of camera controlled by touch.
  92183. * This is like a universal camera minus the Gamepad controls.
  92184. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92185. * @param name Define the name of the camera in the scene
  92186. * @param position Define the start position of the camera in the scene
  92187. * @param scene Define the scene the camera belongs to
  92188. */
  92189. constructor(name: string, position: Vector3, scene: Scene);
  92190. /**
  92191. * Gets the current object class name.
  92192. * @return the class name
  92193. */
  92194. getClassName(): string;
  92195. /** @hidden */
  92196. _setupInputs(): void;
  92197. }
  92198. }
  92199. declare module BABYLON {
  92200. /**
  92201. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  92202. * being tilted forward or back and left or right.
  92203. */
  92204. export class DeviceOrientationCamera extends FreeCamera {
  92205. private _initialQuaternion;
  92206. private _quaternionCache;
  92207. /**
  92208. * Creates a new device orientation camera
  92209. * @param name The name of the camera
  92210. * @param position The start position camera
  92211. * @param scene The scene the camera belongs to
  92212. */
  92213. constructor(name: string, position: Vector3, scene: Scene);
  92214. /**
  92215. * Gets the current instance class name ("DeviceOrientationCamera").
  92216. * This helps avoiding instanceof at run time.
  92217. * @returns the class name
  92218. */
  92219. getClassName(): string;
  92220. /**
  92221. * @hidden
  92222. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  92223. */
  92224. _checkInputs(): void;
  92225. /**
  92226. * Reset the camera to its default orientation on the specified axis only.
  92227. * @param axis The axis to reset
  92228. */
  92229. resetToCurrentRotation(axis?: Axis): void;
  92230. }
  92231. }
  92232. declare module BABYLON {
  92233. /**
  92234. * Manage the keyboard inputs to control the movement of a follow camera.
  92235. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92236. */
  92237. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  92238. /**
  92239. * Defines the camera the input is attached to.
  92240. */
  92241. camera: FollowCamera;
  92242. /**
  92243. * Defines the list of key codes associated with the up action (increase heightOffset)
  92244. */
  92245. keysHeightOffsetIncr: number[];
  92246. /**
  92247. * Defines the list of key codes associated with the down action (decrease heightOffset)
  92248. */
  92249. keysHeightOffsetDecr: number[];
  92250. /**
  92251. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  92252. */
  92253. keysHeightOffsetModifierAlt: boolean;
  92254. /**
  92255. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  92256. */
  92257. keysHeightOffsetModifierCtrl: boolean;
  92258. /**
  92259. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  92260. */
  92261. keysHeightOffsetModifierShift: boolean;
  92262. /**
  92263. * Defines the list of key codes associated with the left action (increase rotationOffset)
  92264. */
  92265. keysRotationOffsetIncr: number[];
  92266. /**
  92267. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  92268. */
  92269. keysRotationOffsetDecr: number[];
  92270. /**
  92271. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  92272. */
  92273. keysRotationOffsetModifierAlt: boolean;
  92274. /**
  92275. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  92276. */
  92277. keysRotationOffsetModifierCtrl: boolean;
  92278. /**
  92279. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  92280. */
  92281. keysRotationOffsetModifierShift: boolean;
  92282. /**
  92283. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  92284. */
  92285. keysRadiusIncr: number[];
  92286. /**
  92287. * Defines the list of key codes associated with the zoom-out action (increase radius)
  92288. */
  92289. keysRadiusDecr: number[];
  92290. /**
  92291. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  92292. */
  92293. keysRadiusModifierAlt: boolean;
  92294. /**
  92295. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  92296. */
  92297. keysRadiusModifierCtrl: boolean;
  92298. /**
  92299. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  92300. */
  92301. keysRadiusModifierShift: boolean;
  92302. /**
  92303. * Defines the rate of change of heightOffset.
  92304. */
  92305. heightSensibility: number;
  92306. /**
  92307. * Defines the rate of change of rotationOffset.
  92308. */
  92309. rotationSensibility: number;
  92310. /**
  92311. * Defines the rate of change of radius.
  92312. */
  92313. radiusSensibility: number;
  92314. private _keys;
  92315. private _ctrlPressed;
  92316. private _altPressed;
  92317. private _shiftPressed;
  92318. private _onCanvasBlurObserver;
  92319. private _onKeyboardObserver;
  92320. private _engine;
  92321. private _scene;
  92322. /**
  92323. * Attach the input controls to a specific dom element to get the input from.
  92324. * @param element Defines the element the controls should be listened from
  92325. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92326. */
  92327. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92328. /**
  92329. * Detach the current controls from the specified dom element.
  92330. * @param element Defines the element to stop listening the inputs from
  92331. */
  92332. detachControl(element: Nullable<HTMLElement>): void;
  92333. /**
  92334. * Update the current camera state depending on the inputs that have been used this frame.
  92335. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92336. */
  92337. checkInputs(): void;
  92338. /**
  92339. * Gets the class name of the current input.
  92340. * @returns the class name
  92341. */
  92342. getClassName(): string;
  92343. /**
  92344. * Get the friendly name associated with the input class.
  92345. * @returns the input friendly name
  92346. */
  92347. getSimpleName(): string;
  92348. /**
  92349. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92350. * allow modification of the heightOffset value.
  92351. */
  92352. private _modifierHeightOffset;
  92353. /**
  92354. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92355. * allow modification of the rotationOffset value.
  92356. */
  92357. private _modifierRotationOffset;
  92358. /**
  92359. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92360. * allow modification of the radius value.
  92361. */
  92362. private _modifierRadius;
  92363. }
  92364. }
  92365. declare module BABYLON {
  92366. /**
  92367. * Manage the mouse wheel inputs to control a follow camera.
  92368. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92369. */
  92370. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  92371. /**
  92372. * Defines the camera the input is attached to.
  92373. */
  92374. camera: FollowCamera;
  92375. /**
  92376. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  92377. */
  92378. axisControlRadius: boolean;
  92379. /**
  92380. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  92381. */
  92382. axisControlHeight: boolean;
  92383. /**
  92384. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  92385. */
  92386. axisControlRotation: boolean;
  92387. /**
  92388. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  92389. * relation to mouseWheel events.
  92390. */
  92391. wheelPrecision: number;
  92392. /**
  92393. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  92394. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  92395. */
  92396. wheelDeltaPercentage: number;
  92397. private _wheel;
  92398. private _observer;
  92399. /**
  92400. * Attach the input controls to a specific dom element to get the input from.
  92401. * @param element Defines the element the controls should be listened from
  92402. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92403. */
  92404. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92405. /**
  92406. * Detach the current controls from the specified dom element.
  92407. * @param element Defines the element to stop listening the inputs from
  92408. */
  92409. detachControl(element: Nullable<HTMLElement>): void;
  92410. /**
  92411. * Gets the class name of the current intput.
  92412. * @returns the class name
  92413. */
  92414. getClassName(): string;
  92415. /**
  92416. * Get the friendly name associated with the input class.
  92417. * @returns the input friendly name
  92418. */
  92419. getSimpleName(): string;
  92420. }
  92421. }
  92422. declare module BABYLON {
  92423. /**
  92424. * Default Inputs manager for the FollowCamera.
  92425. * It groups all the default supported inputs for ease of use.
  92426. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92427. */
  92428. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  92429. /**
  92430. * Instantiates a new FollowCameraInputsManager.
  92431. * @param camera Defines the camera the inputs belong to
  92432. */
  92433. constructor(camera: FollowCamera);
  92434. /**
  92435. * Add keyboard input support to the input manager.
  92436. * @returns the current input manager
  92437. */
  92438. addKeyboard(): FollowCameraInputsManager;
  92439. /**
  92440. * Add mouse wheel input support to the input manager.
  92441. * @returns the current input manager
  92442. */
  92443. addMouseWheel(): FollowCameraInputsManager;
  92444. /**
  92445. * Add pointers input support to the input manager.
  92446. * @returns the current input manager
  92447. */
  92448. addPointers(): FollowCameraInputsManager;
  92449. /**
  92450. * Add orientation input support to the input manager.
  92451. * @returns the current input manager
  92452. */
  92453. addVRDeviceOrientation(): FollowCameraInputsManager;
  92454. }
  92455. }
  92456. declare module BABYLON {
  92457. /**
  92458. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  92459. * an arc rotate version arcFollowCamera are available.
  92460. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92461. */
  92462. export class FollowCamera extends TargetCamera {
  92463. /**
  92464. * Distance the follow camera should follow an object at
  92465. */
  92466. radius: number;
  92467. /**
  92468. * Minimum allowed distance of the camera to the axis of rotation
  92469. * (The camera can not get closer).
  92470. * This can help limiting how the Camera is able to move in the scene.
  92471. */
  92472. lowerRadiusLimit: Nullable<number>;
  92473. /**
  92474. * Maximum allowed distance of the camera to the axis of rotation
  92475. * (The camera can not get further).
  92476. * This can help limiting how the Camera is able to move in the scene.
  92477. */
  92478. upperRadiusLimit: Nullable<number>;
  92479. /**
  92480. * Define a rotation offset between the camera and the object it follows
  92481. */
  92482. rotationOffset: number;
  92483. /**
  92484. * Minimum allowed angle to camera position relative to target object.
  92485. * This can help limiting how the Camera is able to move in the scene.
  92486. */
  92487. lowerRotationOffsetLimit: Nullable<number>;
  92488. /**
  92489. * Maximum allowed angle to camera position relative to target object.
  92490. * This can help limiting how the Camera is able to move in the scene.
  92491. */
  92492. upperRotationOffsetLimit: Nullable<number>;
  92493. /**
  92494. * Define a height offset between the camera and the object it follows.
  92495. * It can help following an object from the top (like a car chaing a plane)
  92496. */
  92497. heightOffset: number;
  92498. /**
  92499. * Minimum allowed height of camera position relative to target object.
  92500. * This can help limiting how the Camera is able to move in the scene.
  92501. */
  92502. lowerHeightOffsetLimit: Nullable<number>;
  92503. /**
  92504. * Maximum allowed height of camera position relative to target object.
  92505. * This can help limiting how the Camera is able to move in the scene.
  92506. */
  92507. upperHeightOffsetLimit: Nullable<number>;
  92508. /**
  92509. * Define how fast the camera can accelerate to follow it s target.
  92510. */
  92511. cameraAcceleration: number;
  92512. /**
  92513. * Define the speed limit of the camera following an object.
  92514. */
  92515. maxCameraSpeed: number;
  92516. /**
  92517. * Define the target of the camera.
  92518. */
  92519. lockedTarget: Nullable<AbstractMesh>;
  92520. /**
  92521. * Defines the input associated with the camera.
  92522. */
  92523. inputs: FollowCameraInputsManager;
  92524. /**
  92525. * Instantiates the follow camera.
  92526. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92527. * @param name Define the name of the camera in the scene
  92528. * @param position Define the position of the camera
  92529. * @param scene Define the scene the camera belong to
  92530. * @param lockedTarget Define the target of the camera
  92531. */
  92532. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  92533. private _follow;
  92534. /**
  92535. * Attached controls to the current camera.
  92536. * @param element Defines the element the controls should be listened from
  92537. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92538. */
  92539. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92540. /**
  92541. * Detach the current controls from the camera.
  92542. * The camera will stop reacting to inputs.
  92543. * @param element Defines the element to stop listening the inputs from
  92544. */
  92545. detachControl(element: HTMLElement): void;
  92546. /** @hidden */
  92547. _checkInputs(): void;
  92548. private _checkLimits;
  92549. /**
  92550. * Gets the camera class name.
  92551. * @returns the class name
  92552. */
  92553. getClassName(): string;
  92554. }
  92555. /**
  92556. * Arc Rotate version of the follow camera.
  92557. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  92558. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92559. */
  92560. export class ArcFollowCamera extends TargetCamera {
  92561. /** The longitudinal angle of the camera */
  92562. alpha: number;
  92563. /** The latitudinal angle of the camera */
  92564. beta: number;
  92565. /** The radius of the camera from its target */
  92566. radius: number;
  92567. /** Define the camera target (the messh it should follow) */
  92568. target: Nullable<AbstractMesh>;
  92569. private _cartesianCoordinates;
  92570. /**
  92571. * Instantiates a new ArcFollowCamera
  92572. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92573. * @param name Define the name of the camera
  92574. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  92575. * @param beta Define the rotation angle of the camera around the elevation axis
  92576. * @param radius Define the radius of the camera from its target point
  92577. * @param target Define the target of the camera
  92578. * @param scene Define the scene the camera belongs to
  92579. */
  92580. constructor(name: string,
  92581. /** The longitudinal angle of the camera */
  92582. alpha: number,
  92583. /** The latitudinal angle of the camera */
  92584. beta: number,
  92585. /** The radius of the camera from its target */
  92586. radius: number,
  92587. /** Define the camera target (the messh it should follow) */
  92588. target: Nullable<AbstractMesh>, scene: Scene);
  92589. private _follow;
  92590. /** @hidden */
  92591. _checkInputs(): void;
  92592. /**
  92593. * Returns the class name of the object.
  92594. * It is mostly used internally for serialization purposes.
  92595. */
  92596. getClassName(): string;
  92597. }
  92598. }
  92599. declare module BABYLON {
  92600. /**
  92601. * 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,
  92602. * which still works and will still be found in many Playgrounds.
  92603. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92604. */
  92605. export class UniversalCamera extends TouchCamera {
  92606. /**
  92607. * Defines the gamepad rotation sensiblity.
  92608. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92609. */
  92610. gamepadAngularSensibility: number;
  92611. /**
  92612. * Defines the gamepad move sensiblity.
  92613. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92614. */
  92615. gamepadMoveSensibility: number;
  92616. /**
  92617. * 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,
  92618. * which still works and will still be found in many Playgrounds.
  92619. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92620. * @param name Define the name of the camera in the scene
  92621. * @param position Define the start position of the camera in the scene
  92622. * @param scene Define the scene the camera belongs to
  92623. */
  92624. constructor(name: string, position: Vector3, scene: Scene);
  92625. /**
  92626. * Gets the current object class name.
  92627. * @return the class name
  92628. */
  92629. getClassName(): string;
  92630. }
  92631. }
  92632. declare module BABYLON {
  92633. /**
  92634. * This represents a FPS type of camera. This is only here for back compat purpose.
  92635. * Please use the UniversalCamera instead as both are identical.
  92636. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92637. */
  92638. export class GamepadCamera extends UniversalCamera {
  92639. /**
  92640. * Instantiates a new Gamepad Camera
  92641. * This represents a FPS type of camera. This is only here for back compat purpose.
  92642. * Please use the UniversalCamera instead as both are identical.
  92643. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92644. * @param name Define the name of the camera in the scene
  92645. * @param position Define the start position of the camera in the scene
  92646. * @param scene Define the scene the camera belongs to
  92647. */
  92648. constructor(name: string, position: Vector3, scene: Scene);
  92649. /**
  92650. * Gets the current object class name.
  92651. * @return the class name
  92652. */
  92653. getClassName(): string;
  92654. }
  92655. }
  92656. declare module BABYLON {
  92657. /** @hidden */
  92658. export var passPixelShader: {
  92659. name: string;
  92660. shader: string;
  92661. };
  92662. }
  92663. declare module BABYLON {
  92664. /** @hidden */
  92665. export var passCubePixelShader: {
  92666. name: string;
  92667. shader: string;
  92668. };
  92669. }
  92670. declare module BABYLON {
  92671. /**
  92672. * PassPostProcess which produces an output the same as it's input
  92673. */
  92674. export class PassPostProcess extends PostProcess {
  92675. /**
  92676. * Creates the PassPostProcess
  92677. * @param name The name of the effect.
  92678. * @param options The required width/height ratio to downsize to before computing the render pass.
  92679. * @param camera The camera to apply the render pass to.
  92680. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  92681. * @param engine The engine which the post process will be applied. (default: current engine)
  92682. * @param reusable If the post process can be reused on the same frame. (default: false)
  92683. * @param textureType The type of texture to be used when performing the post processing.
  92684. * @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)
  92685. */
  92686. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  92687. }
  92688. /**
  92689. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  92690. */
  92691. export class PassCubePostProcess extends PostProcess {
  92692. private _face;
  92693. /**
  92694. * Gets or sets the cube face to display.
  92695. * * 0 is +X
  92696. * * 1 is -X
  92697. * * 2 is +Y
  92698. * * 3 is -Y
  92699. * * 4 is +Z
  92700. * * 5 is -Z
  92701. */
  92702. face: number;
  92703. /**
  92704. * Creates the PassCubePostProcess
  92705. * @param name The name of the effect.
  92706. * @param options The required width/height ratio to downsize to before computing the render pass.
  92707. * @param camera The camera to apply the render pass to.
  92708. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  92709. * @param engine The engine which the post process will be applied. (default: current engine)
  92710. * @param reusable If the post process can be reused on the same frame. (default: false)
  92711. * @param textureType The type of texture to be used when performing the post processing.
  92712. * @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)
  92713. */
  92714. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  92715. }
  92716. }
  92717. declare module BABYLON {
  92718. /** @hidden */
  92719. export var anaglyphPixelShader: {
  92720. name: string;
  92721. shader: string;
  92722. };
  92723. }
  92724. declare module BABYLON {
  92725. /**
  92726. * Postprocess used to generate anaglyphic rendering
  92727. */
  92728. export class AnaglyphPostProcess extends PostProcess {
  92729. private _passedProcess;
  92730. /**
  92731. * Creates a new AnaglyphPostProcess
  92732. * @param name defines postprocess name
  92733. * @param options defines creation options or target ratio scale
  92734. * @param rigCameras defines cameras using this postprocess
  92735. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  92736. * @param engine defines hosting engine
  92737. * @param reusable defines if the postprocess will be reused multiple times per frame
  92738. */
  92739. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  92740. }
  92741. }
  92742. declare module BABYLON {
  92743. /**
  92744. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  92745. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92746. */
  92747. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  92748. /**
  92749. * Creates a new AnaglyphArcRotateCamera
  92750. * @param name defines camera name
  92751. * @param alpha defines alpha angle (in radians)
  92752. * @param beta defines beta angle (in radians)
  92753. * @param radius defines radius
  92754. * @param target defines camera target
  92755. * @param interaxialDistance defines distance between each color axis
  92756. * @param scene defines the hosting scene
  92757. */
  92758. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  92759. /**
  92760. * Gets camera class name
  92761. * @returns AnaglyphArcRotateCamera
  92762. */
  92763. getClassName(): string;
  92764. }
  92765. }
  92766. declare module BABYLON {
  92767. /**
  92768. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  92769. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92770. */
  92771. export class AnaglyphFreeCamera extends FreeCamera {
  92772. /**
  92773. * Creates a new AnaglyphFreeCamera
  92774. * @param name defines camera name
  92775. * @param position defines initial position
  92776. * @param interaxialDistance defines distance between each color axis
  92777. * @param scene defines the hosting scene
  92778. */
  92779. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  92780. /**
  92781. * Gets camera class name
  92782. * @returns AnaglyphFreeCamera
  92783. */
  92784. getClassName(): string;
  92785. }
  92786. }
  92787. declare module BABYLON {
  92788. /**
  92789. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  92790. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92791. */
  92792. export class AnaglyphGamepadCamera extends GamepadCamera {
  92793. /**
  92794. * Creates a new AnaglyphGamepadCamera
  92795. * @param name defines camera name
  92796. * @param position defines initial position
  92797. * @param interaxialDistance defines distance between each color axis
  92798. * @param scene defines the hosting scene
  92799. */
  92800. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  92801. /**
  92802. * Gets camera class name
  92803. * @returns AnaglyphGamepadCamera
  92804. */
  92805. getClassName(): string;
  92806. }
  92807. }
  92808. declare module BABYLON {
  92809. /**
  92810. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  92811. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92812. */
  92813. export class AnaglyphUniversalCamera extends UniversalCamera {
  92814. /**
  92815. * Creates a new AnaglyphUniversalCamera
  92816. * @param name defines camera name
  92817. * @param position defines initial position
  92818. * @param interaxialDistance defines distance between each color axis
  92819. * @param scene defines the hosting scene
  92820. */
  92821. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  92822. /**
  92823. * Gets camera class name
  92824. * @returns AnaglyphUniversalCamera
  92825. */
  92826. getClassName(): string;
  92827. }
  92828. }
  92829. declare module BABYLON {
  92830. /** @hidden */
  92831. export var stereoscopicInterlacePixelShader: {
  92832. name: string;
  92833. shader: string;
  92834. };
  92835. }
  92836. declare module BABYLON {
  92837. /**
  92838. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  92839. */
  92840. export class StereoscopicInterlacePostProcess extends PostProcess {
  92841. private _stepSize;
  92842. private _passedProcess;
  92843. /**
  92844. * Initializes a StereoscopicInterlacePostProcess
  92845. * @param name The name of the effect.
  92846. * @param rigCameras The rig cameras to be appled to the post process
  92847. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  92848. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  92849. * @param engine The engine which the post process will be applied. (default: current engine)
  92850. * @param reusable If the post process can be reused on the same frame. (default: false)
  92851. */
  92852. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  92853. }
  92854. }
  92855. declare module BABYLON {
  92856. /**
  92857. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  92858. * @see http://doc.babylonjs.com/features/cameras
  92859. */
  92860. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  92861. /**
  92862. * Creates a new StereoscopicArcRotateCamera
  92863. * @param name defines camera name
  92864. * @param alpha defines alpha angle (in radians)
  92865. * @param beta defines beta angle (in radians)
  92866. * @param radius defines radius
  92867. * @param target defines camera target
  92868. * @param interaxialDistance defines distance between each color axis
  92869. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  92870. * @param scene defines the hosting scene
  92871. */
  92872. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  92873. /**
  92874. * Gets camera class name
  92875. * @returns StereoscopicArcRotateCamera
  92876. */
  92877. getClassName(): string;
  92878. }
  92879. }
  92880. declare module BABYLON {
  92881. /**
  92882. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  92883. * @see http://doc.babylonjs.com/features/cameras
  92884. */
  92885. export class StereoscopicFreeCamera extends FreeCamera {
  92886. /**
  92887. * Creates a new StereoscopicFreeCamera
  92888. * @param name defines camera name
  92889. * @param position defines initial position
  92890. * @param interaxialDistance defines distance between each color axis
  92891. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  92892. * @param scene defines the hosting scene
  92893. */
  92894. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  92895. /**
  92896. * Gets camera class name
  92897. * @returns StereoscopicFreeCamera
  92898. */
  92899. getClassName(): string;
  92900. }
  92901. }
  92902. declare module BABYLON {
  92903. /**
  92904. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  92905. * @see http://doc.babylonjs.com/features/cameras
  92906. */
  92907. export class StereoscopicGamepadCamera extends GamepadCamera {
  92908. /**
  92909. * Creates a new StereoscopicGamepadCamera
  92910. * @param name defines camera name
  92911. * @param position defines initial position
  92912. * @param interaxialDistance defines distance between each color axis
  92913. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  92914. * @param scene defines the hosting scene
  92915. */
  92916. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  92917. /**
  92918. * Gets camera class name
  92919. * @returns StereoscopicGamepadCamera
  92920. */
  92921. getClassName(): string;
  92922. }
  92923. }
  92924. declare module BABYLON {
  92925. /**
  92926. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  92927. * @see http://doc.babylonjs.com/features/cameras
  92928. */
  92929. export class StereoscopicUniversalCamera extends UniversalCamera {
  92930. /**
  92931. * Creates a new StereoscopicUniversalCamera
  92932. * @param name defines camera name
  92933. * @param position defines initial position
  92934. * @param interaxialDistance defines distance between each color axis
  92935. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  92936. * @param scene defines the hosting scene
  92937. */
  92938. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  92939. /**
  92940. * Gets camera class name
  92941. * @returns StereoscopicUniversalCamera
  92942. */
  92943. getClassName(): string;
  92944. }
  92945. }
  92946. declare module BABYLON {
  92947. /**
  92948. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  92949. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  92950. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  92951. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  92952. */
  92953. export class VirtualJoysticksCamera extends FreeCamera {
  92954. /**
  92955. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  92956. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  92957. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  92958. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  92959. * @param name Define the name of the camera in the scene
  92960. * @param position Define the start position of the camera in the scene
  92961. * @param scene Define the scene the camera belongs to
  92962. */
  92963. constructor(name: string, position: Vector3, scene: Scene);
  92964. /**
  92965. * Gets the current object class name.
  92966. * @return the class name
  92967. */
  92968. getClassName(): string;
  92969. }
  92970. }
  92971. declare module BABYLON {
  92972. /**
  92973. * This represents all the required metrics to create a VR camera.
  92974. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  92975. */
  92976. export class VRCameraMetrics {
  92977. /**
  92978. * Define the horizontal resolution off the screen.
  92979. */
  92980. hResolution: number;
  92981. /**
  92982. * Define the vertical resolution off the screen.
  92983. */
  92984. vResolution: number;
  92985. /**
  92986. * Define the horizontal screen size.
  92987. */
  92988. hScreenSize: number;
  92989. /**
  92990. * Define the vertical screen size.
  92991. */
  92992. vScreenSize: number;
  92993. /**
  92994. * Define the vertical screen center position.
  92995. */
  92996. vScreenCenter: number;
  92997. /**
  92998. * Define the distance of the eyes to the screen.
  92999. */
  93000. eyeToScreenDistance: number;
  93001. /**
  93002. * Define the distance between both lenses
  93003. */
  93004. lensSeparationDistance: number;
  93005. /**
  93006. * Define the distance between both viewer's eyes.
  93007. */
  93008. interpupillaryDistance: number;
  93009. /**
  93010. * Define the distortion factor of the VR postprocess.
  93011. * Please, touch with care.
  93012. */
  93013. distortionK: number[];
  93014. /**
  93015. * Define the chromatic aberration correction factors for the VR post process.
  93016. */
  93017. chromaAbCorrection: number[];
  93018. /**
  93019. * Define the scale factor of the post process.
  93020. * The smaller the better but the slower.
  93021. */
  93022. postProcessScaleFactor: number;
  93023. /**
  93024. * Define an offset for the lens center.
  93025. */
  93026. lensCenterOffset: number;
  93027. /**
  93028. * Define if the current vr camera should compensate the distortion of the lense or not.
  93029. */
  93030. compensateDistortion: boolean;
  93031. /**
  93032. * Gets the rendering aspect ratio based on the provided resolutions.
  93033. */
  93034. readonly aspectRatio: number;
  93035. /**
  93036. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  93037. */
  93038. readonly aspectRatioFov: number;
  93039. /**
  93040. * @hidden
  93041. */
  93042. readonly leftHMatrix: Matrix;
  93043. /**
  93044. * @hidden
  93045. */
  93046. readonly rightHMatrix: Matrix;
  93047. /**
  93048. * @hidden
  93049. */
  93050. readonly leftPreViewMatrix: Matrix;
  93051. /**
  93052. * @hidden
  93053. */
  93054. readonly rightPreViewMatrix: Matrix;
  93055. /**
  93056. * Get the default VRMetrics based on the most generic setup.
  93057. * @returns the default vr metrics
  93058. */
  93059. static GetDefault(): VRCameraMetrics;
  93060. }
  93061. }
  93062. declare module BABYLON {
  93063. /** @hidden */
  93064. export var vrDistortionCorrectionPixelShader: {
  93065. name: string;
  93066. shader: string;
  93067. };
  93068. }
  93069. declare module BABYLON {
  93070. /**
  93071. * VRDistortionCorrectionPostProcess used for mobile VR
  93072. */
  93073. export class VRDistortionCorrectionPostProcess extends PostProcess {
  93074. private _isRightEye;
  93075. private _distortionFactors;
  93076. private _postProcessScaleFactor;
  93077. private _lensCenterOffset;
  93078. private _scaleIn;
  93079. private _scaleFactor;
  93080. private _lensCenter;
  93081. /**
  93082. * Initializes the VRDistortionCorrectionPostProcess
  93083. * @param name The name of the effect.
  93084. * @param camera The camera to apply the render pass to.
  93085. * @param isRightEye If this is for the right eye distortion
  93086. * @param vrMetrics All the required metrics for the VR camera
  93087. */
  93088. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  93089. }
  93090. }
  93091. declare module BABYLON {
  93092. /**
  93093. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  93094. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93095. */
  93096. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  93097. /**
  93098. * Creates a new VRDeviceOrientationArcRotateCamera
  93099. * @param name defines camera name
  93100. * @param alpha defines the camera rotation along the logitudinal axis
  93101. * @param beta defines the camera rotation along the latitudinal axis
  93102. * @param radius defines the camera distance from its target
  93103. * @param target defines the camera target
  93104. * @param scene defines the scene the camera belongs to
  93105. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93106. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93107. */
  93108. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93109. /**
  93110. * Gets camera class name
  93111. * @returns VRDeviceOrientationArcRotateCamera
  93112. */
  93113. getClassName(): string;
  93114. }
  93115. }
  93116. declare module BABYLON {
  93117. /**
  93118. * Camera used to simulate VR rendering (based on FreeCamera)
  93119. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93120. */
  93121. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  93122. /**
  93123. * Creates a new VRDeviceOrientationFreeCamera
  93124. * @param name defines camera name
  93125. * @param position defines the start position of the camera
  93126. * @param scene defines the scene the camera belongs to
  93127. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93128. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93129. */
  93130. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93131. /**
  93132. * Gets camera class name
  93133. * @returns VRDeviceOrientationFreeCamera
  93134. */
  93135. getClassName(): string;
  93136. }
  93137. }
  93138. declare module BABYLON {
  93139. /**
  93140. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  93141. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93142. */
  93143. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  93144. /**
  93145. * Creates a new VRDeviceOrientationGamepadCamera
  93146. * @param name defines camera name
  93147. * @param position defines the start position of the camera
  93148. * @param scene defines the scene the camera belongs to
  93149. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93150. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93151. */
  93152. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93153. /**
  93154. * Gets camera class name
  93155. * @returns VRDeviceOrientationGamepadCamera
  93156. */
  93157. getClassName(): string;
  93158. }
  93159. }
  93160. declare module BABYLON {
  93161. /**
  93162. * Defines supported buttons for XBox360 compatible gamepads
  93163. */
  93164. export enum Xbox360Button {
  93165. /** A */
  93166. A = 0,
  93167. /** B */
  93168. B = 1,
  93169. /** X */
  93170. X = 2,
  93171. /** Y */
  93172. Y = 3,
  93173. /** Start */
  93174. Start = 4,
  93175. /** Back */
  93176. Back = 5,
  93177. /** Left button */
  93178. LB = 6,
  93179. /** Right button */
  93180. RB = 7,
  93181. /** Left stick */
  93182. LeftStick = 8,
  93183. /** Right stick */
  93184. RightStick = 9
  93185. }
  93186. /** Defines values for XBox360 DPad */
  93187. export enum Xbox360Dpad {
  93188. /** Up */
  93189. Up = 0,
  93190. /** Down */
  93191. Down = 1,
  93192. /** Left */
  93193. Left = 2,
  93194. /** Right */
  93195. Right = 3
  93196. }
  93197. /**
  93198. * Defines a XBox360 gamepad
  93199. */
  93200. export class Xbox360Pad extends Gamepad {
  93201. private _leftTrigger;
  93202. private _rightTrigger;
  93203. private _onlefttriggerchanged;
  93204. private _onrighttriggerchanged;
  93205. private _onbuttondown;
  93206. private _onbuttonup;
  93207. private _ondpaddown;
  93208. private _ondpadup;
  93209. /** Observable raised when a button is pressed */
  93210. onButtonDownObservable: Observable<Xbox360Button>;
  93211. /** Observable raised when a button is released */
  93212. onButtonUpObservable: Observable<Xbox360Button>;
  93213. /** Observable raised when a pad is pressed */
  93214. onPadDownObservable: Observable<Xbox360Dpad>;
  93215. /** Observable raised when a pad is released */
  93216. onPadUpObservable: Observable<Xbox360Dpad>;
  93217. private _buttonA;
  93218. private _buttonB;
  93219. private _buttonX;
  93220. private _buttonY;
  93221. private _buttonBack;
  93222. private _buttonStart;
  93223. private _buttonLB;
  93224. private _buttonRB;
  93225. private _buttonLeftStick;
  93226. private _buttonRightStick;
  93227. private _dPadUp;
  93228. private _dPadDown;
  93229. private _dPadLeft;
  93230. private _dPadRight;
  93231. private _isXboxOnePad;
  93232. /**
  93233. * Creates a new XBox360 gamepad object
  93234. * @param id defines the id of this gamepad
  93235. * @param index defines its index
  93236. * @param gamepad defines the internal HTML gamepad object
  93237. * @param xboxOne defines if it is a XBox One gamepad
  93238. */
  93239. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  93240. /**
  93241. * Defines the callback to call when left trigger is pressed
  93242. * @param callback defines the callback to use
  93243. */
  93244. onlefttriggerchanged(callback: (value: number) => void): void;
  93245. /**
  93246. * Defines the callback to call when right trigger is pressed
  93247. * @param callback defines the callback to use
  93248. */
  93249. onrighttriggerchanged(callback: (value: number) => void): void;
  93250. /**
  93251. * Gets the left trigger value
  93252. */
  93253. /**
  93254. * Sets the left trigger value
  93255. */
  93256. leftTrigger: number;
  93257. /**
  93258. * Gets the right trigger value
  93259. */
  93260. /**
  93261. * Sets the right trigger value
  93262. */
  93263. rightTrigger: number;
  93264. /**
  93265. * Defines the callback to call when a button is pressed
  93266. * @param callback defines the callback to use
  93267. */
  93268. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  93269. /**
  93270. * Defines the callback to call when a button is released
  93271. * @param callback defines the callback to use
  93272. */
  93273. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  93274. /**
  93275. * Defines the callback to call when a pad is pressed
  93276. * @param callback defines the callback to use
  93277. */
  93278. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  93279. /**
  93280. * Defines the callback to call when a pad is released
  93281. * @param callback defines the callback to use
  93282. */
  93283. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  93284. private _setButtonValue;
  93285. private _setDPadValue;
  93286. /**
  93287. * Gets the value of the `A` button
  93288. */
  93289. /**
  93290. * Sets the value of the `A` button
  93291. */
  93292. buttonA: number;
  93293. /**
  93294. * Gets the value of the `B` button
  93295. */
  93296. /**
  93297. * Sets the value of the `B` button
  93298. */
  93299. buttonB: number;
  93300. /**
  93301. * Gets the value of the `X` button
  93302. */
  93303. /**
  93304. * Sets the value of the `X` button
  93305. */
  93306. buttonX: number;
  93307. /**
  93308. * Gets the value of the `Y` button
  93309. */
  93310. /**
  93311. * Sets the value of the `Y` button
  93312. */
  93313. buttonY: number;
  93314. /**
  93315. * Gets the value of the `Start` button
  93316. */
  93317. /**
  93318. * Sets the value of the `Start` button
  93319. */
  93320. buttonStart: number;
  93321. /**
  93322. * Gets the value of the `Back` button
  93323. */
  93324. /**
  93325. * Sets the value of the `Back` button
  93326. */
  93327. buttonBack: number;
  93328. /**
  93329. * Gets the value of the `Left` button
  93330. */
  93331. /**
  93332. * Sets the value of the `Left` button
  93333. */
  93334. buttonLB: number;
  93335. /**
  93336. * Gets the value of the `Right` button
  93337. */
  93338. /**
  93339. * Sets the value of the `Right` button
  93340. */
  93341. buttonRB: number;
  93342. /**
  93343. * Gets the value of the Left joystick
  93344. */
  93345. /**
  93346. * Sets the value of the Left joystick
  93347. */
  93348. buttonLeftStick: number;
  93349. /**
  93350. * Gets the value of the Right joystick
  93351. */
  93352. /**
  93353. * Sets the value of the Right joystick
  93354. */
  93355. buttonRightStick: number;
  93356. /**
  93357. * Gets the value of D-pad up
  93358. */
  93359. /**
  93360. * Sets the value of D-pad up
  93361. */
  93362. dPadUp: number;
  93363. /**
  93364. * Gets the value of D-pad down
  93365. */
  93366. /**
  93367. * Sets the value of D-pad down
  93368. */
  93369. dPadDown: number;
  93370. /**
  93371. * Gets the value of D-pad left
  93372. */
  93373. /**
  93374. * Sets the value of D-pad left
  93375. */
  93376. dPadLeft: number;
  93377. /**
  93378. * Gets the value of D-pad right
  93379. */
  93380. /**
  93381. * Sets the value of D-pad right
  93382. */
  93383. dPadRight: number;
  93384. /**
  93385. * Force the gamepad to synchronize with device values
  93386. */
  93387. update(): void;
  93388. /**
  93389. * Disposes the gamepad
  93390. */
  93391. dispose(): void;
  93392. }
  93393. }
  93394. declare module BABYLON {
  93395. /**
  93396. * Base class of materials working in push mode in babylon JS
  93397. * @hidden
  93398. */
  93399. export class PushMaterial extends Material {
  93400. protected _activeEffect: Effect;
  93401. protected _normalMatrix: Matrix;
  93402. /**
  93403. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  93404. * This means that the material can keep using a previous shader while a new one is being compiled.
  93405. * This is mostly used when shader parallel compilation is supported (true by default)
  93406. */
  93407. allowShaderHotSwapping: boolean;
  93408. constructor(name: string, scene: Scene);
  93409. getEffect(): Effect;
  93410. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  93411. /**
  93412. * Binds the given world matrix to the active effect
  93413. *
  93414. * @param world the matrix to bind
  93415. */
  93416. bindOnlyWorldMatrix(world: Matrix): void;
  93417. /**
  93418. * Binds the given normal matrix to the active effect
  93419. *
  93420. * @param normalMatrix the matrix to bind
  93421. */
  93422. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  93423. bind(world: Matrix, mesh?: Mesh): void;
  93424. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  93425. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  93426. }
  93427. }
  93428. declare module BABYLON {
  93429. /**
  93430. * This groups all the flags used to control the materials channel.
  93431. */
  93432. export class MaterialFlags {
  93433. private static _DiffuseTextureEnabled;
  93434. /**
  93435. * Are diffuse textures enabled in the application.
  93436. */
  93437. static DiffuseTextureEnabled: boolean;
  93438. private static _AmbientTextureEnabled;
  93439. /**
  93440. * Are ambient textures enabled in the application.
  93441. */
  93442. static AmbientTextureEnabled: boolean;
  93443. private static _OpacityTextureEnabled;
  93444. /**
  93445. * Are opacity textures enabled in the application.
  93446. */
  93447. static OpacityTextureEnabled: boolean;
  93448. private static _ReflectionTextureEnabled;
  93449. /**
  93450. * Are reflection textures enabled in the application.
  93451. */
  93452. static ReflectionTextureEnabled: boolean;
  93453. private static _EmissiveTextureEnabled;
  93454. /**
  93455. * Are emissive textures enabled in the application.
  93456. */
  93457. static EmissiveTextureEnabled: boolean;
  93458. private static _SpecularTextureEnabled;
  93459. /**
  93460. * Are specular textures enabled in the application.
  93461. */
  93462. static SpecularTextureEnabled: boolean;
  93463. private static _BumpTextureEnabled;
  93464. /**
  93465. * Are bump textures enabled in the application.
  93466. */
  93467. static BumpTextureEnabled: boolean;
  93468. private static _LightmapTextureEnabled;
  93469. /**
  93470. * Are lightmap textures enabled in the application.
  93471. */
  93472. static LightmapTextureEnabled: boolean;
  93473. private static _RefractionTextureEnabled;
  93474. /**
  93475. * Are refraction textures enabled in the application.
  93476. */
  93477. static RefractionTextureEnabled: boolean;
  93478. private static _ColorGradingTextureEnabled;
  93479. /**
  93480. * Are color grading textures enabled in the application.
  93481. */
  93482. static ColorGradingTextureEnabled: boolean;
  93483. private static _FresnelEnabled;
  93484. /**
  93485. * Are fresnels enabled in the application.
  93486. */
  93487. static FresnelEnabled: boolean;
  93488. }
  93489. }
  93490. declare module BABYLON {
  93491. /** @hidden */
  93492. export var defaultFragmentDeclaration: {
  93493. name: string;
  93494. shader: string;
  93495. };
  93496. }
  93497. declare module BABYLON {
  93498. /** @hidden */
  93499. export var defaultUboDeclaration: {
  93500. name: string;
  93501. shader: string;
  93502. };
  93503. }
  93504. declare module BABYLON {
  93505. /** @hidden */
  93506. export var lightFragmentDeclaration: {
  93507. name: string;
  93508. shader: string;
  93509. };
  93510. }
  93511. declare module BABYLON {
  93512. /** @hidden */
  93513. export var lightUboDeclaration: {
  93514. name: string;
  93515. shader: string;
  93516. };
  93517. }
  93518. declare module BABYLON {
  93519. /** @hidden */
  93520. export var lightsFragmentFunctions: {
  93521. name: string;
  93522. shader: string;
  93523. };
  93524. }
  93525. declare module BABYLON {
  93526. /** @hidden */
  93527. export var shadowsFragmentFunctions: {
  93528. name: string;
  93529. shader: string;
  93530. };
  93531. }
  93532. declare module BABYLON {
  93533. /** @hidden */
  93534. export var fresnelFunction: {
  93535. name: string;
  93536. shader: string;
  93537. };
  93538. }
  93539. declare module BABYLON {
  93540. /** @hidden */
  93541. export var reflectionFunction: {
  93542. name: string;
  93543. shader: string;
  93544. };
  93545. }
  93546. declare module BABYLON {
  93547. /** @hidden */
  93548. export var bumpFragmentFunctions: {
  93549. name: string;
  93550. shader: string;
  93551. };
  93552. }
  93553. declare module BABYLON {
  93554. /** @hidden */
  93555. export var logDepthDeclaration: {
  93556. name: string;
  93557. shader: string;
  93558. };
  93559. }
  93560. declare module BABYLON {
  93561. /** @hidden */
  93562. export var bumpFragment: {
  93563. name: string;
  93564. shader: string;
  93565. };
  93566. }
  93567. declare module BABYLON {
  93568. /** @hidden */
  93569. export var depthPrePass: {
  93570. name: string;
  93571. shader: string;
  93572. };
  93573. }
  93574. declare module BABYLON {
  93575. /** @hidden */
  93576. export var lightFragment: {
  93577. name: string;
  93578. shader: string;
  93579. };
  93580. }
  93581. declare module BABYLON {
  93582. /** @hidden */
  93583. export var logDepthFragment: {
  93584. name: string;
  93585. shader: string;
  93586. };
  93587. }
  93588. declare module BABYLON {
  93589. /** @hidden */
  93590. export var defaultPixelShader: {
  93591. name: string;
  93592. shader: string;
  93593. };
  93594. }
  93595. declare module BABYLON {
  93596. /** @hidden */
  93597. export var defaultVertexDeclaration: {
  93598. name: string;
  93599. shader: string;
  93600. };
  93601. }
  93602. declare module BABYLON {
  93603. /** @hidden */
  93604. export var bumpVertexDeclaration: {
  93605. name: string;
  93606. shader: string;
  93607. };
  93608. }
  93609. declare module BABYLON {
  93610. /** @hidden */
  93611. export var bumpVertex: {
  93612. name: string;
  93613. shader: string;
  93614. };
  93615. }
  93616. declare module BABYLON {
  93617. /** @hidden */
  93618. export var fogVertex: {
  93619. name: string;
  93620. shader: string;
  93621. };
  93622. }
  93623. declare module BABYLON {
  93624. /** @hidden */
  93625. export var shadowsVertex: {
  93626. name: string;
  93627. shader: string;
  93628. };
  93629. }
  93630. declare module BABYLON {
  93631. /** @hidden */
  93632. export var pointCloudVertex: {
  93633. name: string;
  93634. shader: string;
  93635. };
  93636. }
  93637. declare module BABYLON {
  93638. /** @hidden */
  93639. export var logDepthVertex: {
  93640. name: string;
  93641. shader: string;
  93642. };
  93643. }
  93644. declare module BABYLON {
  93645. /** @hidden */
  93646. export var defaultVertexShader: {
  93647. name: string;
  93648. shader: string;
  93649. };
  93650. }
  93651. declare module BABYLON {
  93652. /** @hidden */
  93653. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  93654. MAINUV1: boolean;
  93655. MAINUV2: boolean;
  93656. DIFFUSE: boolean;
  93657. DIFFUSEDIRECTUV: number;
  93658. AMBIENT: boolean;
  93659. AMBIENTDIRECTUV: number;
  93660. OPACITY: boolean;
  93661. OPACITYDIRECTUV: number;
  93662. OPACITYRGB: boolean;
  93663. REFLECTION: boolean;
  93664. EMISSIVE: boolean;
  93665. EMISSIVEDIRECTUV: number;
  93666. SPECULAR: boolean;
  93667. SPECULARDIRECTUV: number;
  93668. BUMP: boolean;
  93669. BUMPDIRECTUV: number;
  93670. PARALLAX: boolean;
  93671. PARALLAXOCCLUSION: boolean;
  93672. SPECULAROVERALPHA: boolean;
  93673. CLIPPLANE: boolean;
  93674. CLIPPLANE2: boolean;
  93675. CLIPPLANE3: boolean;
  93676. CLIPPLANE4: boolean;
  93677. ALPHATEST: boolean;
  93678. DEPTHPREPASS: boolean;
  93679. ALPHAFROMDIFFUSE: boolean;
  93680. POINTSIZE: boolean;
  93681. FOG: boolean;
  93682. SPECULARTERM: boolean;
  93683. DIFFUSEFRESNEL: boolean;
  93684. OPACITYFRESNEL: boolean;
  93685. REFLECTIONFRESNEL: boolean;
  93686. REFRACTIONFRESNEL: boolean;
  93687. EMISSIVEFRESNEL: boolean;
  93688. FRESNEL: boolean;
  93689. NORMAL: boolean;
  93690. UV1: boolean;
  93691. UV2: boolean;
  93692. VERTEXCOLOR: boolean;
  93693. VERTEXALPHA: boolean;
  93694. NUM_BONE_INFLUENCERS: number;
  93695. BonesPerMesh: number;
  93696. BONETEXTURE: boolean;
  93697. INSTANCES: boolean;
  93698. GLOSSINESS: boolean;
  93699. ROUGHNESS: boolean;
  93700. EMISSIVEASILLUMINATION: boolean;
  93701. LINKEMISSIVEWITHDIFFUSE: boolean;
  93702. REFLECTIONFRESNELFROMSPECULAR: boolean;
  93703. LIGHTMAP: boolean;
  93704. LIGHTMAPDIRECTUV: number;
  93705. OBJECTSPACE_NORMALMAP: boolean;
  93706. USELIGHTMAPASSHADOWMAP: boolean;
  93707. REFLECTIONMAP_3D: boolean;
  93708. REFLECTIONMAP_SPHERICAL: boolean;
  93709. REFLECTIONMAP_PLANAR: boolean;
  93710. REFLECTIONMAP_CUBIC: boolean;
  93711. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  93712. REFLECTIONMAP_PROJECTION: boolean;
  93713. REFLECTIONMAP_SKYBOX: boolean;
  93714. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  93715. REFLECTIONMAP_EXPLICIT: boolean;
  93716. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  93717. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  93718. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  93719. INVERTCUBICMAP: boolean;
  93720. LOGARITHMICDEPTH: boolean;
  93721. REFRACTION: boolean;
  93722. REFRACTIONMAP_3D: boolean;
  93723. REFLECTIONOVERALPHA: boolean;
  93724. TWOSIDEDLIGHTING: boolean;
  93725. SHADOWFLOAT: boolean;
  93726. MORPHTARGETS: boolean;
  93727. MORPHTARGETS_NORMAL: boolean;
  93728. MORPHTARGETS_TANGENT: boolean;
  93729. NUM_MORPH_INFLUENCERS: number;
  93730. NONUNIFORMSCALING: boolean;
  93731. PREMULTIPLYALPHA: boolean;
  93732. IMAGEPROCESSING: boolean;
  93733. VIGNETTE: boolean;
  93734. VIGNETTEBLENDMODEMULTIPLY: boolean;
  93735. VIGNETTEBLENDMODEOPAQUE: boolean;
  93736. TONEMAPPING: boolean;
  93737. TONEMAPPING_ACES: boolean;
  93738. CONTRAST: boolean;
  93739. COLORCURVES: boolean;
  93740. COLORGRADING: boolean;
  93741. COLORGRADING3D: boolean;
  93742. SAMPLER3DGREENDEPTH: boolean;
  93743. SAMPLER3DBGRMAP: boolean;
  93744. IMAGEPROCESSINGPOSTPROCESS: boolean;
  93745. /**
  93746. * If the reflection texture on this material is in linear color space
  93747. * @hidden
  93748. */
  93749. IS_REFLECTION_LINEAR: boolean;
  93750. /**
  93751. * If the refraction texture on this material is in linear color space
  93752. * @hidden
  93753. */
  93754. IS_REFRACTION_LINEAR: boolean;
  93755. EXPOSURE: boolean;
  93756. constructor();
  93757. setReflectionMode(modeToEnable: string): void;
  93758. }
  93759. /**
  93760. * This is the default material used in Babylon. It is the best trade off between quality
  93761. * and performances.
  93762. * @see http://doc.babylonjs.com/babylon101/materials
  93763. */
  93764. export class StandardMaterial extends PushMaterial {
  93765. private _diffuseTexture;
  93766. /**
  93767. * The basic texture of the material as viewed under a light.
  93768. */
  93769. diffuseTexture: Nullable<BaseTexture>;
  93770. private _ambientTexture;
  93771. /**
  93772. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  93773. */
  93774. ambientTexture: Nullable<BaseTexture>;
  93775. private _opacityTexture;
  93776. /**
  93777. * Define the transparency of the material from a texture.
  93778. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  93779. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  93780. */
  93781. opacityTexture: Nullable<BaseTexture>;
  93782. private _reflectionTexture;
  93783. /**
  93784. * Define the texture used to display the reflection.
  93785. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  93786. */
  93787. reflectionTexture: Nullable<BaseTexture>;
  93788. private _emissiveTexture;
  93789. /**
  93790. * Define texture of the material as if self lit.
  93791. * This will be mixed in the final result even in the absence of light.
  93792. */
  93793. emissiveTexture: Nullable<BaseTexture>;
  93794. private _specularTexture;
  93795. /**
  93796. * Define how the color and intensity of the highlight given by the light in the material.
  93797. */
  93798. specularTexture: Nullable<BaseTexture>;
  93799. private _bumpTexture;
  93800. /**
  93801. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  93802. * 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.
  93803. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  93804. */
  93805. bumpTexture: Nullable<BaseTexture>;
  93806. private _lightmapTexture;
  93807. /**
  93808. * Complex lighting can be computationally expensive to compute at runtime.
  93809. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  93810. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  93811. */
  93812. lightmapTexture: Nullable<BaseTexture>;
  93813. private _refractionTexture;
  93814. /**
  93815. * Define the texture used to display the refraction.
  93816. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  93817. */
  93818. refractionTexture: Nullable<BaseTexture>;
  93819. /**
  93820. * The color of the material lit by the environmental background lighting.
  93821. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  93822. */
  93823. ambientColor: Color3;
  93824. /**
  93825. * The basic color of the material as viewed under a light.
  93826. */
  93827. diffuseColor: Color3;
  93828. /**
  93829. * Define how the color and intensity of the highlight given by the light in the material.
  93830. */
  93831. specularColor: Color3;
  93832. /**
  93833. * Define the color of the material as if self lit.
  93834. * This will be mixed in the final result even in the absence of light.
  93835. */
  93836. emissiveColor: Color3;
  93837. /**
  93838. * Defines how sharp are the highlights in the material.
  93839. * The bigger the value the sharper giving a more glossy feeling to the result.
  93840. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  93841. */
  93842. specularPower: number;
  93843. private _useAlphaFromDiffuseTexture;
  93844. /**
  93845. * Does the transparency come from the diffuse texture alpha channel.
  93846. */
  93847. useAlphaFromDiffuseTexture: boolean;
  93848. private _useEmissiveAsIllumination;
  93849. /**
  93850. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  93851. */
  93852. useEmissiveAsIllumination: boolean;
  93853. private _linkEmissiveWithDiffuse;
  93854. /**
  93855. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  93856. * the emissive level when the final color is close to one.
  93857. */
  93858. linkEmissiveWithDiffuse: boolean;
  93859. private _useSpecularOverAlpha;
  93860. /**
  93861. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  93862. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  93863. */
  93864. useSpecularOverAlpha: boolean;
  93865. private _useReflectionOverAlpha;
  93866. /**
  93867. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  93868. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  93869. */
  93870. useReflectionOverAlpha: boolean;
  93871. private _disableLighting;
  93872. /**
  93873. * Does lights from the scene impacts this material.
  93874. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  93875. */
  93876. disableLighting: boolean;
  93877. private _useObjectSpaceNormalMap;
  93878. /**
  93879. * Allows using an object space normal map (instead of tangent space).
  93880. */
  93881. useObjectSpaceNormalMap: boolean;
  93882. private _useParallax;
  93883. /**
  93884. * Is parallax enabled or not.
  93885. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  93886. */
  93887. useParallax: boolean;
  93888. private _useParallaxOcclusion;
  93889. /**
  93890. * Is parallax occlusion enabled or not.
  93891. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  93892. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  93893. */
  93894. useParallaxOcclusion: boolean;
  93895. /**
  93896. * 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.
  93897. */
  93898. parallaxScaleBias: number;
  93899. private _roughness;
  93900. /**
  93901. * Helps to define how blurry the reflections should appears in the material.
  93902. */
  93903. roughness: number;
  93904. /**
  93905. * In case of refraction, define the value of the indice of refraction.
  93906. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  93907. */
  93908. indexOfRefraction: number;
  93909. /**
  93910. * Invert the refraction texture alongside the y axis.
  93911. * It can be useful with procedural textures or probe for instance.
  93912. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  93913. */
  93914. invertRefractionY: boolean;
  93915. /**
  93916. * Defines the alpha limits in alpha test mode.
  93917. */
  93918. alphaCutOff: number;
  93919. private _useLightmapAsShadowmap;
  93920. /**
  93921. * In case of light mapping, define whether the map contains light or shadow informations.
  93922. */
  93923. useLightmapAsShadowmap: boolean;
  93924. private _diffuseFresnelParameters;
  93925. /**
  93926. * Define the diffuse fresnel parameters of the material.
  93927. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93928. */
  93929. diffuseFresnelParameters: FresnelParameters;
  93930. private _opacityFresnelParameters;
  93931. /**
  93932. * Define the opacity fresnel parameters of the material.
  93933. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93934. */
  93935. opacityFresnelParameters: FresnelParameters;
  93936. private _reflectionFresnelParameters;
  93937. /**
  93938. * Define the reflection fresnel parameters of the material.
  93939. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93940. */
  93941. reflectionFresnelParameters: FresnelParameters;
  93942. private _refractionFresnelParameters;
  93943. /**
  93944. * Define the refraction fresnel parameters of the material.
  93945. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93946. */
  93947. refractionFresnelParameters: FresnelParameters;
  93948. private _emissiveFresnelParameters;
  93949. /**
  93950. * Define the emissive fresnel parameters of the material.
  93951. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93952. */
  93953. emissiveFresnelParameters: FresnelParameters;
  93954. private _useReflectionFresnelFromSpecular;
  93955. /**
  93956. * If true automatically deducts the fresnels values from the material specularity.
  93957. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93958. */
  93959. useReflectionFresnelFromSpecular: boolean;
  93960. private _useGlossinessFromSpecularMapAlpha;
  93961. /**
  93962. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  93963. */
  93964. useGlossinessFromSpecularMapAlpha: boolean;
  93965. private _maxSimultaneousLights;
  93966. /**
  93967. * Defines the maximum number of lights that can be used in the material
  93968. */
  93969. maxSimultaneousLights: number;
  93970. private _invertNormalMapX;
  93971. /**
  93972. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  93973. */
  93974. invertNormalMapX: boolean;
  93975. private _invertNormalMapY;
  93976. /**
  93977. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  93978. */
  93979. invertNormalMapY: boolean;
  93980. private _twoSidedLighting;
  93981. /**
  93982. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  93983. */
  93984. twoSidedLighting: boolean;
  93985. /**
  93986. * Default configuration related to image processing available in the standard Material.
  93987. */
  93988. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  93989. /**
  93990. * Gets the image processing configuration used either in this material.
  93991. */
  93992. /**
  93993. * Sets the Default image processing configuration used either in the this material.
  93994. *
  93995. * If sets to null, the scene one is in use.
  93996. */
  93997. imageProcessingConfiguration: ImageProcessingConfiguration;
  93998. /**
  93999. * Keep track of the image processing observer to allow dispose and replace.
  94000. */
  94001. private _imageProcessingObserver;
  94002. /**
  94003. * Attaches a new image processing configuration to the Standard Material.
  94004. * @param configuration
  94005. */
  94006. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  94007. /**
  94008. * Gets wether the color curves effect is enabled.
  94009. */
  94010. /**
  94011. * Sets wether the color curves effect is enabled.
  94012. */
  94013. cameraColorCurvesEnabled: boolean;
  94014. /**
  94015. * Gets wether the color grading effect is enabled.
  94016. */
  94017. /**
  94018. * Gets wether the color grading effect is enabled.
  94019. */
  94020. cameraColorGradingEnabled: boolean;
  94021. /**
  94022. * Gets wether tonemapping is enabled or not.
  94023. */
  94024. /**
  94025. * Sets wether tonemapping is enabled or not
  94026. */
  94027. cameraToneMappingEnabled: boolean;
  94028. /**
  94029. * The camera exposure used on this material.
  94030. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  94031. * This corresponds to a photographic exposure.
  94032. */
  94033. /**
  94034. * The camera exposure used on this material.
  94035. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  94036. * This corresponds to a photographic exposure.
  94037. */
  94038. cameraExposure: number;
  94039. /**
  94040. * Gets The camera contrast used on this material.
  94041. */
  94042. /**
  94043. * Sets The camera contrast used on this material.
  94044. */
  94045. cameraContrast: number;
  94046. /**
  94047. * Gets the Color Grading 2D Lookup Texture.
  94048. */
  94049. /**
  94050. * Sets the Color Grading 2D Lookup Texture.
  94051. */
  94052. cameraColorGradingTexture: Nullable<BaseTexture>;
  94053. /**
  94054. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  94055. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  94056. * 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;
  94057. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  94058. */
  94059. /**
  94060. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  94061. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  94062. * 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;
  94063. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  94064. */
  94065. cameraColorCurves: Nullable<ColorCurves>;
  94066. /**
  94067. * Custom callback helping to override the default shader used in the material.
  94068. */
  94069. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  94070. protected _renderTargets: SmartArray<RenderTargetTexture>;
  94071. protected _worldViewProjectionMatrix: Matrix;
  94072. protected _globalAmbientColor: Color3;
  94073. protected _useLogarithmicDepth: boolean;
  94074. /**
  94075. * Instantiates a new standard material.
  94076. * This is the default material used in Babylon. It is the best trade off between quality
  94077. * and performances.
  94078. * @see http://doc.babylonjs.com/babylon101/materials
  94079. * @param name Define the name of the material in the scene
  94080. * @param scene Define the scene the material belong to
  94081. */
  94082. constructor(name: string, scene: Scene);
  94083. /**
  94084. * Gets a boolean indicating that current material needs to register RTT
  94085. */
  94086. readonly hasRenderTargetTextures: boolean;
  94087. /**
  94088. * Gets the current class name of the material e.g. "StandardMaterial"
  94089. * Mainly use in serialization.
  94090. * @returns the class name
  94091. */
  94092. getClassName(): string;
  94093. /**
  94094. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  94095. * You can try switching to logarithmic depth.
  94096. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  94097. */
  94098. useLogarithmicDepth: boolean;
  94099. /**
  94100. * Specifies if the material will require alpha blending
  94101. * @returns a boolean specifying if alpha blending is needed
  94102. */
  94103. needAlphaBlending(): boolean;
  94104. /**
  94105. * Specifies if this material should be rendered in alpha test mode
  94106. * @returns a boolean specifying if an alpha test is needed.
  94107. */
  94108. needAlphaTesting(): boolean;
  94109. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  94110. /**
  94111. * Get the texture used for alpha test purpose.
  94112. * @returns the diffuse texture in case of the standard material.
  94113. */
  94114. getAlphaTestTexture(): Nullable<BaseTexture>;
  94115. /**
  94116. * Get if the submesh is ready to be used and all its information available.
  94117. * Child classes can use it to update shaders
  94118. * @param mesh defines the mesh to check
  94119. * @param subMesh defines which submesh to check
  94120. * @param useInstances specifies that instances should be used
  94121. * @returns a boolean indicating that the submesh is ready or not
  94122. */
  94123. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  94124. /**
  94125. * Builds the material UBO layouts.
  94126. * Used internally during the effect preparation.
  94127. */
  94128. buildUniformLayout(): void;
  94129. /**
  94130. * Unbinds the material from the mesh
  94131. */
  94132. unbind(): void;
  94133. /**
  94134. * Binds the submesh to this material by preparing the effect and shader to draw
  94135. * @param world defines the world transformation matrix
  94136. * @param mesh defines the mesh containing the submesh
  94137. * @param subMesh defines the submesh to bind the material to
  94138. */
  94139. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94140. /**
  94141. * Get the list of animatables in the material.
  94142. * @returns the list of animatables object used in the material
  94143. */
  94144. getAnimatables(): IAnimatable[];
  94145. /**
  94146. * Gets the active textures from the material
  94147. * @returns an array of textures
  94148. */
  94149. getActiveTextures(): BaseTexture[];
  94150. /**
  94151. * Specifies if the material uses a texture
  94152. * @param texture defines the texture to check against the material
  94153. * @returns a boolean specifying if the material uses the texture
  94154. */
  94155. hasTexture(texture: BaseTexture): boolean;
  94156. /**
  94157. * Disposes the material
  94158. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94159. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94160. */
  94161. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  94162. /**
  94163. * Makes a duplicate of the material, and gives it a new name
  94164. * @param name defines the new name for the duplicated material
  94165. * @returns the cloned material
  94166. */
  94167. clone(name: string): StandardMaterial;
  94168. /**
  94169. * Serializes this material in a JSON representation
  94170. * @returns the serialized material object
  94171. */
  94172. serialize(): any;
  94173. /**
  94174. * Creates a standard material from parsed material data
  94175. * @param source defines the JSON representation of the material
  94176. * @param scene defines the hosting scene
  94177. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94178. * @returns a new standard material
  94179. */
  94180. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  94181. /**
  94182. * Are diffuse textures enabled in the application.
  94183. */
  94184. static DiffuseTextureEnabled: boolean;
  94185. /**
  94186. * Are ambient textures enabled in the application.
  94187. */
  94188. static AmbientTextureEnabled: boolean;
  94189. /**
  94190. * Are opacity textures enabled in the application.
  94191. */
  94192. static OpacityTextureEnabled: boolean;
  94193. /**
  94194. * Are reflection textures enabled in the application.
  94195. */
  94196. static ReflectionTextureEnabled: boolean;
  94197. /**
  94198. * Are emissive textures enabled in the application.
  94199. */
  94200. static EmissiveTextureEnabled: boolean;
  94201. /**
  94202. * Are specular textures enabled in the application.
  94203. */
  94204. static SpecularTextureEnabled: boolean;
  94205. /**
  94206. * Are bump textures enabled in the application.
  94207. */
  94208. static BumpTextureEnabled: boolean;
  94209. /**
  94210. * Are lightmap textures enabled in the application.
  94211. */
  94212. static LightmapTextureEnabled: boolean;
  94213. /**
  94214. * Are refraction textures enabled in the application.
  94215. */
  94216. static RefractionTextureEnabled: boolean;
  94217. /**
  94218. * Are color grading textures enabled in the application.
  94219. */
  94220. static ColorGradingTextureEnabled: boolean;
  94221. /**
  94222. * Are fresnels enabled in the application.
  94223. */
  94224. static FresnelEnabled: boolean;
  94225. }
  94226. }
  94227. declare module BABYLON {
  94228. /**
  94229. * A class extending Texture allowing drawing on a texture
  94230. * @see http://doc.babylonjs.com/how_to/dynamictexture
  94231. */
  94232. export class DynamicTexture extends Texture {
  94233. private _generateMipMaps;
  94234. private _canvas;
  94235. private _context;
  94236. private _engine;
  94237. /**
  94238. * Creates a DynamicTexture
  94239. * @param name defines the name of the texture
  94240. * @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
  94241. * @param scene defines the scene where you want the texture
  94242. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  94243. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  94244. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  94245. */
  94246. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  94247. /**
  94248. * Get the current class name of the texture useful for serialization or dynamic coding.
  94249. * @returns "DynamicTexture"
  94250. */
  94251. getClassName(): string;
  94252. /**
  94253. * Gets the current state of canRescale
  94254. */
  94255. readonly canRescale: boolean;
  94256. private _recreate;
  94257. /**
  94258. * Scales the texture
  94259. * @param ratio the scale factor to apply to both width and height
  94260. */
  94261. scale(ratio: number): void;
  94262. /**
  94263. * Resizes the texture
  94264. * @param width the new width
  94265. * @param height the new height
  94266. */
  94267. scaleTo(width: number, height: number): void;
  94268. /**
  94269. * Gets the context of the canvas used by the texture
  94270. * @returns the canvas context of the dynamic texture
  94271. */
  94272. getContext(): CanvasRenderingContext2D;
  94273. /**
  94274. * Clears the texture
  94275. */
  94276. clear(): void;
  94277. /**
  94278. * Updates the texture
  94279. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  94280. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  94281. */
  94282. update(invertY?: boolean, premulAlpha?: boolean): void;
  94283. /**
  94284. * Draws text onto the texture
  94285. * @param text defines the text to be drawn
  94286. * @param x defines the placement of the text from the left
  94287. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  94288. * @param font defines the font to be used with font-style, font-size, font-name
  94289. * @param color defines the color used for the text
  94290. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  94291. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  94292. * @param update defines whether texture is immediately update (default is true)
  94293. */
  94294. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  94295. /**
  94296. * Clones the texture
  94297. * @returns the clone of the texture.
  94298. */
  94299. clone(): DynamicTexture;
  94300. /**
  94301. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  94302. * @returns a serialized dynamic texture object
  94303. */
  94304. serialize(): any;
  94305. /** @hidden */
  94306. _rebuild(): void;
  94307. }
  94308. }
  94309. declare module BABYLON {
  94310. /** @hidden */
  94311. export var imageProcessingPixelShader: {
  94312. name: string;
  94313. shader: string;
  94314. };
  94315. }
  94316. declare module BABYLON {
  94317. /**
  94318. * ImageProcessingPostProcess
  94319. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  94320. */
  94321. export class ImageProcessingPostProcess extends PostProcess {
  94322. /**
  94323. * Default configuration related to image processing available in the PBR Material.
  94324. */
  94325. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94326. /**
  94327. * Gets the image processing configuration used either in this material.
  94328. */
  94329. /**
  94330. * Sets the Default image processing configuration used either in the this material.
  94331. *
  94332. * If sets to null, the scene one is in use.
  94333. */
  94334. imageProcessingConfiguration: ImageProcessingConfiguration;
  94335. /**
  94336. * Keep track of the image processing observer to allow dispose and replace.
  94337. */
  94338. private _imageProcessingObserver;
  94339. /**
  94340. * Attaches a new image processing configuration to the PBR Material.
  94341. * @param configuration
  94342. */
  94343. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  94344. /**
  94345. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  94346. */
  94347. /**
  94348. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  94349. */
  94350. colorCurves: Nullable<ColorCurves>;
  94351. /**
  94352. * Gets wether the color curves effect is enabled.
  94353. */
  94354. /**
  94355. * Sets wether the color curves effect is enabled.
  94356. */
  94357. colorCurvesEnabled: boolean;
  94358. /**
  94359. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  94360. */
  94361. /**
  94362. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  94363. */
  94364. colorGradingTexture: Nullable<BaseTexture>;
  94365. /**
  94366. * Gets wether the color grading effect is enabled.
  94367. */
  94368. /**
  94369. * Gets wether the color grading effect is enabled.
  94370. */
  94371. colorGradingEnabled: boolean;
  94372. /**
  94373. * Gets exposure used in the effect.
  94374. */
  94375. /**
  94376. * Sets exposure used in the effect.
  94377. */
  94378. exposure: number;
  94379. /**
  94380. * Gets wether tonemapping is enabled or not.
  94381. */
  94382. /**
  94383. * Sets wether tonemapping is enabled or not
  94384. */
  94385. toneMappingEnabled: boolean;
  94386. /**
  94387. * Gets contrast used in the effect.
  94388. */
  94389. /**
  94390. * Sets contrast used in the effect.
  94391. */
  94392. contrast: number;
  94393. /**
  94394. * Gets Vignette stretch size.
  94395. */
  94396. /**
  94397. * Sets Vignette stretch size.
  94398. */
  94399. vignetteStretch: number;
  94400. /**
  94401. * Gets Vignette centre X Offset.
  94402. */
  94403. /**
  94404. * Sets Vignette centre X Offset.
  94405. */
  94406. vignetteCentreX: number;
  94407. /**
  94408. * Gets Vignette centre Y Offset.
  94409. */
  94410. /**
  94411. * Sets Vignette centre Y Offset.
  94412. */
  94413. vignetteCentreY: number;
  94414. /**
  94415. * Gets Vignette weight or intensity of the vignette effect.
  94416. */
  94417. /**
  94418. * Sets Vignette weight or intensity of the vignette effect.
  94419. */
  94420. vignetteWeight: number;
  94421. /**
  94422. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  94423. * if vignetteEnabled is set to true.
  94424. */
  94425. /**
  94426. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  94427. * if vignetteEnabled is set to true.
  94428. */
  94429. vignetteColor: Color4;
  94430. /**
  94431. * Gets Camera field of view used by the Vignette effect.
  94432. */
  94433. /**
  94434. * Sets Camera field of view used by the Vignette effect.
  94435. */
  94436. vignetteCameraFov: number;
  94437. /**
  94438. * Gets the vignette blend mode allowing different kind of effect.
  94439. */
  94440. /**
  94441. * Sets the vignette blend mode allowing different kind of effect.
  94442. */
  94443. vignetteBlendMode: number;
  94444. /**
  94445. * Gets wether the vignette effect is enabled.
  94446. */
  94447. /**
  94448. * Sets wether the vignette effect is enabled.
  94449. */
  94450. vignetteEnabled: boolean;
  94451. private _fromLinearSpace;
  94452. /**
  94453. * Gets wether the input of the processing is in Gamma or Linear Space.
  94454. */
  94455. /**
  94456. * Sets wether the input of the processing is in Gamma or Linear Space.
  94457. */
  94458. fromLinearSpace: boolean;
  94459. /**
  94460. * Defines cache preventing GC.
  94461. */
  94462. private _defines;
  94463. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  94464. /**
  94465. * "ImageProcessingPostProcess"
  94466. * @returns "ImageProcessingPostProcess"
  94467. */
  94468. getClassName(): string;
  94469. protected _updateParameters(): void;
  94470. dispose(camera?: Camera): void;
  94471. }
  94472. }
  94473. declare module BABYLON {
  94474. /**
  94475. * Class containing static functions to help procedurally build meshes
  94476. */
  94477. export class GroundBuilder {
  94478. /**
  94479. * Creates a ground mesh
  94480. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  94481. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  94482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94483. * @param name defines the name of the mesh
  94484. * @param options defines the options used to create the mesh
  94485. * @param scene defines the hosting scene
  94486. * @returns the ground mesh
  94487. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  94488. */
  94489. static CreateGround(name: string, options: {
  94490. width?: number;
  94491. height?: number;
  94492. subdivisions?: number;
  94493. subdivisionsX?: number;
  94494. subdivisionsY?: number;
  94495. updatable?: boolean;
  94496. }, scene: any): Mesh;
  94497. /**
  94498. * Creates a tiled ground mesh
  94499. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  94500. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  94501. * * 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
  94502. * * 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
  94503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94504. * @param name defines the name of the mesh
  94505. * @param options defines the options used to create the mesh
  94506. * @param scene defines the hosting scene
  94507. * @returns the tiled ground mesh
  94508. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  94509. */
  94510. static CreateTiledGround(name: string, options: {
  94511. xmin: number;
  94512. zmin: number;
  94513. xmax: number;
  94514. zmax: number;
  94515. subdivisions?: {
  94516. w: number;
  94517. h: number;
  94518. };
  94519. precision?: {
  94520. w: number;
  94521. h: number;
  94522. };
  94523. updatable?: boolean;
  94524. }, scene: Scene): Mesh;
  94525. /**
  94526. * Creates a ground mesh from a height map
  94527. * * The parameter `url` sets the URL of the height map image resource.
  94528. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  94529. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  94530. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  94531. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  94532. * * 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.
  94533. * * 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).
  94534. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  94535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94536. * @param name defines the name of the mesh
  94537. * @param url defines the url to the height map
  94538. * @param options defines the options used to create the mesh
  94539. * @param scene defines the hosting scene
  94540. * @returns the ground mesh
  94541. * @see https://doc.babylonjs.com/babylon101/height_map
  94542. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  94543. */
  94544. static CreateGroundFromHeightMap(name: string, url: string, options: {
  94545. width?: number;
  94546. height?: number;
  94547. subdivisions?: number;
  94548. minHeight?: number;
  94549. maxHeight?: number;
  94550. colorFilter?: Color3;
  94551. alphaFilter?: number;
  94552. updatable?: boolean;
  94553. onReady?: (mesh: GroundMesh) => void;
  94554. }, scene: Scene): GroundMesh;
  94555. }
  94556. }
  94557. declare module BABYLON {
  94558. /**
  94559. * Class containing static functions to help procedurally build meshes
  94560. */
  94561. export class TorusBuilder {
  94562. /**
  94563. * Creates a torus mesh
  94564. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  94565. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  94566. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  94567. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94568. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94570. * @param name defines the name of the mesh
  94571. * @param options defines the options used to create the mesh
  94572. * @param scene defines the hosting scene
  94573. * @returns the torus mesh
  94574. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  94575. */
  94576. static CreateTorus(name: string, options: {
  94577. diameter?: number;
  94578. thickness?: number;
  94579. tessellation?: number;
  94580. updatable?: boolean;
  94581. sideOrientation?: number;
  94582. frontUVs?: Vector4;
  94583. backUVs?: Vector4;
  94584. }, scene: any): Mesh;
  94585. }
  94586. }
  94587. declare module BABYLON {
  94588. /**
  94589. * Class containing static functions to help procedurally build meshes
  94590. */
  94591. export class CylinderBuilder {
  94592. /**
  94593. * Creates a cylinder or a cone mesh
  94594. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  94595. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  94596. * * 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.
  94597. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  94598. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  94599. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  94600. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  94601. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  94602. * * 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).
  94603. * * 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
  94604. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  94605. * * 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
  94606. * * 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.
  94607. * * If `enclose` is false, a ring surface is one element.
  94608. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  94609. * * 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
  94610. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94611. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94613. * @param name defines the name of the mesh
  94614. * @param options defines the options used to create the mesh
  94615. * @param scene defines the hosting scene
  94616. * @returns the cylinder mesh
  94617. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  94618. */
  94619. static CreateCylinder(name: string, options: {
  94620. height?: number;
  94621. diameterTop?: number;
  94622. diameterBottom?: number;
  94623. diameter?: number;
  94624. tessellation?: number;
  94625. subdivisions?: number;
  94626. arc?: number;
  94627. faceColors?: Color4[];
  94628. faceUV?: Vector4[];
  94629. updatable?: boolean;
  94630. hasRings?: boolean;
  94631. enclose?: boolean;
  94632. sideOrientation?: number;
  94633. frontUVs?: Vector4;
  94634. backUVs?: Vector4;
  94635. }, scene: any): Mesh;
  94636. }
  94637. }
  94638. declare module BABYLON {
  94639. /**
  94640. * Manager for handling gamepads
  94641. */
  94642. export class GamepadManager {
  94643. private _scene?;
  94644. private _babylonGamepads;
  94645. private _oneGamepadConnected;
  94646. /** @hidden */
  94647. _isMonitoring: boolean;
  94648. private _gamepadEventSupported;
  94649. private _gamepadSupport;
  94650. /**
  94651. * observable to be triggered when the gamepad controller has been connected
  94652. */
  94653. onGamepadConnectedObservable: Observable<Gamepad>;
  94654. /**
  94655. * observable to be triggered when the gamepad controller has been disconnected
  94656. */
  94657. onGamepadDisconnectedObservable: Observable<Gamepad>;
  94658. private _onGamepadConnectedEvent;
  94659. private _onGamepadDisconnectedEvent;
  94660. /**
  94661. * Initializes the gamepad manager
  94662. * @param _scene BabylonJS scene
  94663. */
  94664. constructor(_scene?: Scene | undefined);
  94665. /**
  94666. * The gamepads in the game pad manager
  94667. */
  94668. readonly gamepads: Gamepad[];
  94669. /**
  94670. * Get the gamepad controllers based on type
  94671. * @param type The type of gamepad controller
  94672. * @returns Nullable gamepad
  94673. */
  94674. getGamepadByType(type?: number): Nullable<Gamepad>;
  94675. /**
  94676. * Disposes the gamepad manager
  94677. */
  94678. dispose(): void;
  94679. private _addNewGamepad;
  94680. private _startMonitoringGamepads;
  94681. private _stopMonitoringGamepads;
  94682. /** @hidden */
  94683. _checkGamepadsStatus(): void;
  94684. private _updateGamepadObjects;
  94685. }
  94686. }
  94687. declare module BABYLON {
  94688. interface Scene {
  94689. /** @hidden */
  94690. _gamepadManager: Nullable<GamepadManager>;
  94691. /**
  94692. * Gets the gamepad manager associated with the scene
  94693. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  94694. */
  94695. gamepadManager: GamepadManager;
  94696. }
  94697. /**
  94698. * Interface representing a free camera inputs manager
  94699. */
  94700. interface FreeCameraInputsManager {
  94701. /**
  94702. * Adds gamepad input support to the FreeCameraInputsManager.
  94703. * @returns the FreeCameraInputsManager
  94704. */
  94705. addGamepad(): FreeCameraInputsManager;
  94706. }
  94707. /**
  94708. * Interface representing an arc rotate camera inputs manager
  94709. */
  94710. interface ArcRotateCameraInputsManager {
  94711. /**
  94712. * Adds gamepad input support to the ArcRotateCamera InputManager.
  94713. * @returns the camera inputs manager
  94714. */
  94715. addGamepad(): ArcRotateCameraInputsManager;
  94716. }
  94717. /**
  94718. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  94719. */
  94720. export class GamepadSystemSceneComponent implements ISceneComponent {
  94721. /**
  94722. * The component name helpfull to identify the component in the list of scene components.
  94723. */
  94724. readonly name: string;
  94725. /**
  94726. * The scene the component belongs to.
  94727. */
  94728. scene: Scene;
  94729. /**
  94730. * Creates a new instance of the component for the given scene
  94731. * @param scene Defines the scene to register the component in
  94732. */
  94733. constructor(scene: Scene);
  94734. /**
  94735. * Registers the component in a given scene
  94736. */
  94737. register(): void;
  94738. /**
  94739. * Rebuilds the elements related to this component in case of
  94740. * context lost for instance.
  94741. */
  94742. rebuild(): void;
  94743. /**
  94744. * Disposes the component and the associated ressources
  94745. */
  94746. dispose(): void;
  94747. private _beforeCameraUpdate;
  94748. }
  94749. }
  94750. declare module BABYLON {
  94751. /**
  94752. * Options to modify the vr teleportation behavior.
  94753. */
  94754. export interface VRTeleportationOptions {
  94755. /**
  94756. * The name of the mesh which should be used as the teleportation floor. (default: null)
  94757. */
  94758. floorMeshName?: string;
  94759. /**
  94760. * A list of meshes to be used as the teleportation floor. (default: empty)
  94761. */
  94762. floorMeshes?: Mesh[];
  94763. }
  94764. /**
  94765. * Options to modify the vr experience helper's behavior.
  94766. */
  94767. export interface VRExperienceHelperOptions extends WebVROptions {
  94768. /**
  94769. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  94770. */
  94771. createDeviceOrientationCamera?: boolean;
  94772. /**
  94773. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  94774. */
  94775. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  94776. /**
  94777. * Uses the main button on the controller to toggle the laser casted. (default: true)
  94778. */
  94779. laserToggle?: boolean;
  94780. /**
  94781. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  94782. */
  94783. floorMeshes?: Mesh[];
  94784. /**
  94785. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  94786. */
  94787. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  94788. }
  94789. /**
  94790. * Helps to quickly add VR support to an existing scene.
  94791. * See http://doc.babylonjs.com/how_to/webvr_helper
  94792. */
  94793. export class VRExperienceHelper {
  94794. /** Options to modify the vr experience helper's behavior. */
  94795. webVROptions: VRExperienceHelperOptions;
  94796. private _scene;
  94797. private _position;
  94798. private _btnVR;
  94799. private _btnVRDisplayed;
  94800. private _webVRsupported;
  94801. private _webVRready;
  94802. private _webVRrequesting;
  94803. private _webVRpresenting;
  94804. private _hasEnteredVR;
  94805. private _fullscreenVRpresenting;
  94806. private _canvas;
  94807. private _webVRCamera;
  94808. private _vrDeviceOrientationCamera;
  94809. private _deviceOrientationCamera;
  94810. private _existingCamera;
  94811. private _onKeyDown;
  94812. private _onVrDisplayPresentChange;
  94813. private _onVRDisplayChanged;
  94814. private _onVRRequestPresentStart;
  94815. private _onVRRequestPresentComplete;
  94816. /**
  94817. * Observable raised when entering VR.
  94818. */
  94819. onEnteringVRObservable: Observable<VRExperienceHelper>;
  94820. /**
  94821. * Observable raised when exiting VR.
  94822. */
  94823. onExitingVRObservable: Observable<VRExperienceHelper>;
  94824. /**
  94825. * Observable raised when controller mesh is loaded.
  94826. */
  94827. onControllerMeshLoadedObservable: Observable<WebVRController>;
  94828. /** Return this.onEnteringVRObservable
  94829. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  94830. */
  94831. readonly onEnteringVR: Observable<VRExperienceHelper>;
  94832. /** Return this.onExitingVRObservable
  94833. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  94834. */
  94835. readonly onExitingVR: Observable<VRExperienceHelper>;
  94836. /** Return this.onControllerMeshLoadedObservable
  94837. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  94838. */
  94839. readonly onControllerMeshLoaded: Observable<WebVRController>;
  94840. private _rayLength;
  94841. private _useCustomVRButton;
  94842. private _teleportationRequested;
  94843. private _teleportActive;
  94844. private _floorMeshName;
  94845. private _floorMeshesCollection;
  94846. private _rotationAllowed;
  94847. private _teleportBackwardsVector;
  94848. private _teleportationTarget;
  94849. private _isDefaultTeleportationTarget;
  94850. private _postProcessMove;
  94851. private _teleportationFillColor;
  94852. private _teleportationBorderColor;
  94853. private _rotationAngle;
  94854. private _haloCenter;
  94855. private _cameraGazer;
  94856. private _padSensibilityUp;
  94857. private _padSensibilityDown;
  94858. private _leftController;
  94859. private _rightController;
  94860. /**
  94861. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  94862. */
  94863. onNewMeshSelected: Observable<AbstractMesh>;
  94864. /**
  94865. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  94866. */
  94867. onNewMeshPicked: Observable<PickingInfo>;
  94868. private _circleEase;
  94869. /**
  94870. * Observable raised before camera teleportation
  94871. */
  94872. onBeforeCameraTeleport: Observable<Vector3>;
  94873. /**
  94874. * Observable raised after camera teleportation
  94875. */
  94876. onAfterCameraTeleport: Observable<Vector3>;
  94877. /**
  94878. * Observable raised when current selected mesh gets unselected
  94879. */
  94880. onSelectedMeshUnselected: Observable<AbstractMesh>;
  94881. private _raySelectionPredicate;
  94882. /**
  94883. * To be optionaly changed by user to define custom ray selection
  94884. */
  94885. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  94886. /**
  94887. * To be optionaly changed by user to define custom selection logic (after ray selection)
  94888. */
  94889. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  94890. /**
  94891. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  94892. */
  94893. teleportationEnabled: boolean;
  94894. private _defaultHeight;
  94895. private _teleportationInitialized;
  94896. private _interactionsEnabled;
  94897. private _interactionsRequested;
  94898. private _displayGaze;
  94899. private _displayLaserPointer;
  94900. /**
  94901. * The mesh used to display where the user is going to teleport.
  94902. */
  94903. /**
  94904. * Sets the mesh to be used to display where the user is going to teleport.
  94905. */
  94906. teleportationTarget: Mesh;
  94907. /**
  94908. * 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
  94909. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  94910. * See http://doc.babylonjs.com/resources/baking_transformations
  94911. */
  94912. gazeTrackerMesh: Mesh;
  94913. /**
  94914. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  94915. */
  94916. updateGazeTrackerScale: boolean;
  94917. /**
  94918. * If the gaze trackers color should be updated when selecting meshes
  94919. */
  94920. updateGazeTrackerColor: boolean;
  94921. /**
  94922. * The gaze tracking mesh corresponding to the left controller
  94923. */
  94924. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  94925. /**
  94926. * The gaze tracking mesh corresponding to the right controller
  94927. */
  94928. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  94929. /**
  94930. * If the ray of the gaze should be displayed.
  94931. */
  94932. /**
  94933. * Sets if the ray of the gaze should be displayed.
  94934. */
  94935. displayGaze: boolean;
  94936. /**
  94937. * If the ray of the LaserPointer should be displayed.
  94938. */
  94939. /**
  94940. * Sets if the ray of the LaserPointer should be displayed.
  94941. */
  94942. displayLaserPointer: boolean;
  94943. /**
  94944. * The deviceOrientationCamera used as the camera when not in VR.
  94945. */
  94946. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  94947. /**
  94948. * Based on the current WebVR support, returns the current VR camera used.
  94949. */
  94950. readonly currentVRCamera: Nullable<Camera>;
  94951. /**
  94952. * The webVRCamera which is used when in VR.
  94953. */
  94954. readonly webVRCamera: WebVRFreeCamera;
  94955. /**
  94956. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  94957. */
  94958. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  94959. private readonly _teleportationRequestInitiated;
  94960. /**
  94961. * Instantiates a VRExperienceHelper.
  94962. * Helps to quickly add VR support to an existing scene.
  94963. * @param scene The scene the VRExperienceHelper belongs to.
  94964. * @param webVROptions Options to modify the vr experience helper's behavior.
  94965. */
  94966. constructor(scene: Scene,
  94967. /** Options to modify the vr experience helper's behavior. */
  94968. webVROptions?: VRExperienceHelperOptions);
  94969. private _onDefaultMeshLoaded;
  94970. private _onResize;
  94971. private _onFullscreenChange;
  94972. /**
  94973. * Gets a value indicating if we are currently in VR mode.
  94974. */
  94975. readonly isInVRMode: boolean;
  94976. private onVrDisplayPresentChange;
  94977. private onVRDisplayChanged;
  94978. private moveButtonToBottomRight;
  94979. private displayVRButton;
  94980. private updateButtonVisibility;
  94981. private _cachedAngularSensibility;
  94982. /**
  94983. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  94984. * Otherwise, will use the fullscreen API.
  94985. */
  94986. enterVR(): void;
  94987. /**
  94988. * Attempt to exit VR, or fullscreen.
  94989. */
  94990. exitVR(): void;
  94991. /**
  94992. * The position of the vr experience helper.
  94993. */
  94994. /**
  94995. * Sets the position of the vr experience helper.
  94996. */
  94997. position: Vector3;
  94998. /**
  94999. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  95000. */
  95001. enableInteractions(): void;
  95002. private readonly _noControllerIsActive;
  95003. private beforeRender;
  95004. private _isTeleportationFloor;
  95005. /**
  95006. * Adds a floor mesh to be used for teleportation.
  95007. * @param floorMesh the mesh to be used for teleportation.
  95008. */
  95009. addFloorMesh(floorMesh: Mesh): void;
  95010. /**
  95011. * Removes a floor mesh from being used for teleportation.
  95012. * @param floorMesh the mesh to be removed.
  95013. */
  95014. removeFloorMesh(floorMesh: Mesh): void;
  95015. /**
  95016. * Enables interactions and teleportation using the VR controllers and gaze.
  95017. * @param vrTeleportationOptions options to modify teleportation behavior.
  95018. */
  95019. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  95020. private _onNewGamepadConnected;
  95021. private _tryEnableInteractionOnController;
  95022. private _onNewGamepadDisconnected;
  95023. private _enableInteractionOnController;
  95024. private _checkTeleportWithRay;
  95025. private _checkRotate;
  95026. private _checkTeleportBackwards;
  95027. private _enableTeleportationOnController;
  95028. private _createTeleportationCircles;
  95029. private _displayTeleportationTarget;
  95030. private _hideTeleportationTarget;
  95031. private _rotateCamera;
  95032. private _moveTeleportationSelectorTo;
  95033. private _workingVector;
  95034. private _workingQuaternion;
  95035. private _workingMatrix;
  95036. /**
  95037. * Teleports the users feet to the desired location
  95038. * @param location The location where the user's feet should be placed
  95039. */
  95040. teleportCamera(location: Vector3): void;
  95041. private _convertNormalToDirectionOfRay;
  95042. private _castRayAndSelectObject;
  95043. private _notifySelectedMeshUnselected;
  95044. /**
  95045. * Sets the color of the laser ray from the vr controllers.
  95046. * @param color new color for the ray.
  95047. */
  95048. changeLaserColor(color: Color3): void;
  95049. /**
  95050. * Sets the color of the ray from the vr headsets gaze.
  95051. * @param color new color for the ray.
  95052. */
  95053. changeGazeColor(color: Color3): void;
  95054. /**
  95055. * Exits VR and disposes of the vr experience helper
  95056. */
  95057. dispose(): void;
  95058. /**
  95059. * Gets the name of the VRExperienceHelper class
  95060. * @returns "VRExperienceHelper"
  95061. */
  95062. getClassName(): string;
  95063. }
  95064. }
  95065. declare module BABYLON {
  95066. /**
  95067. * Manages an XRSession
  95068. * @see https://doc.babylonjs.com/how_to/webxr
  95069. */
  95070. export class WebXRSessionManager implements IDisposable {
  95071. private scene;
  95072. /**
  95073. * Fires every time a new xrFrame arrives which can be used to update the camera
  95074. */
  95075. onXRFrameObservable: Observable<any>;
  95076. /**
  95077. * Fires when the xr session is ended either by the device or manually done
  95078. */
  95079. onXRSessionEnded: Observable<any>;
  95080. /** @hidden */
  95081. _xrSession: XRSession;
  95082. /** @hidden */
  95083. _frameOfReference: XRFrameOfReference;
  95084. /** @hidden */
  95085. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  95086. /** @hidden */
  95087. _currentXRFrame: Nullable<XRFrame>;
  95088. private _xrNavigator;
  95089. private _xrDevice;
  95090. private _tmpMatrix;
  95091. /**
  95092. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  95093. * @param scene The scene which the session should be created for
  95094. */
  95095. constructor(scene: Scene);
  95096. /**
  95097. * Initializes the manager
  95098. * After initialization enterXR can be called to start an XR session
  95099. * @returns Promise which resolves after it is initialized
  95100. */
  95101. initializeAsync(): Promise<void>;
  95102. /**
  95103. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  95104. * @param sessionCreationOptions xr options to create the session with
  95105. * @param frameOfReferenceType option to configure how the xr pose is expressed
  95106. * @returns Promise which resolves after it enters XR
  95107. */
  95108. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  95109. /**
  95110. * Stops the xrSession and restores the renderloop
  95111. * @returns Promise which resolves after it exits XR
  95112. */
  95113. exitXRAsync(): Promise<void>;
  95114. /**
  95115. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  95116. * @param ray ray to cast into the environment
  95117. * @returns Promise which resolves with a collision point in the environment if it exists
  95118. */
  95119. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  95120. /**
  95121. * Checks if a session would be supported for the creation options specified
  95122. * @param options creation options to check if they are supported
  95123. * @returns true if supported
  95124. */
  95125. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  95126. /**
  95127. * @hidden
  95128. * Converts the render layer of xrSession to a render target
  95129. * @param session session to create render target for
  95130. * @param scene scene the new render target should be created for
  95131. */
  95132. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  95133. /**
  95134. * Disposes of the session manager
  95135. */
  95136. dispose(): void;
  95137. }
  95138. }
  95139. declare module BABYLON {
  95140. /**
  95141. * WebXR Camera which holds the views for the xrSession
  95142. * @see https://doc.babylonjs.com/how_to/webxr
  95143. */
  95144. export class WebXRCamera extends FreeCamera {
  95145. private static _TmpMatrix;
  95146. /**
  95147. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  95148. * @param name the name of the camera
  95149. * @param scene the scene to add the camera to
  95150. */
  95151. constructor(name: string, scene: Scene);
  95152. private _updateNumberOfRigCameras;
  95153. /** @hidden */
  95154. _updateForDualEyeDebugging(pupilDistance?: number): void;
  95155. /**
  95156. * Updates the cameras position from the current pose information of the XR session
  95157. * @param xrSessionManager the session containing pose information
  95158. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  95159. */
  95160. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  95161. }
  95162. }
  95163. declare module BABYLON {
  95164. /**
  95165. * States of the webXR experience
  95166. */
  95167. export enum WebXRState {
  95168. /**
  95169. * Transitioning to being in XR mode
  95170. */
  95171. ENTERING_XR = 0,
  95172. /**
  95173. * Transitioning to non XR mode
  95174. */
  95175. EXITING_XR = 1,
  95176. /**
  95177. * In XR mode and presenting
  95178. */
  95179. IN_XR = 2,
  95180. /**
  95181. * Not entered XR mode
  95182. */
  95183. NOT_IN_XR = 3
  95184. }
  95185. /**
  95186. * Helper class used to enable XR
  95187. * @see https://doc.babylonjs.com/how_to/webxr
  95188. */
  95189. export class WebXRExperienceHelper implements IDisposable {
  95190. private scene;
  95191. /**
  95192. * 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
  95193. */
  95194. container: AbstractMesh;
  95195. /**
  95196. * Camera used to render xr content
  95197. */
  95198. camera: WebXRCamera;
  95199. /**
  95200. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  95201. */
  95202. state: WebXRState;
  95203. private _setState;
  95204. private static _TmpVector;
  95205. /**
  95206. * Fires when the state of the experience helper has changed
  95207. */
  95208. onStateChangedObservable: Observable<WebXRState>;
  95209. /** @hidden */
  95210. _sessionManager: WebXRSessionManager;
  95211. private _nonVRCamera;
  95212. private _originalSceneAutoClear;
  95213. private _supported;
  95214. /**
  95215. * Creates the experience helper
  95216. * @param scene the scene to attach the experience helper to
  95217. * @returns a promise for the experience helper
  95218. */
  95219. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  95220. /**
  95221. * Creates a WebXRExperienceHelper
  95222. * @param scene The scene the helper should be created in
  95223. */
  95224. private constructor();
  95225. /**
  95226. * Exits XR mode and returns the scene to its original state
  95227. * @returns promise that resolves after xr mode has exited
  95228. */
  95229. exitXRAsync(): Promise<void>;
  95230. /**
  95231. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  95232. * @param sessionCreationOptions options for the XR session
  95233. * @param frameOfReference frame of reference of the XR session
  95234. * @returns promise that resolves after xr mode has entered
  95235. */
  95236. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  95237. /**
  95238. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  95239. * @param ray ray to cast into the environment
  95240. * @returns Promise which resolves with a collision point in the environment if it exists
  95241. */
  95242. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  95243. /**
  95244. * Updates the global position of the camera by moving the camera's container
  95245. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  95246. * @param position The desired global position of the camera
  95247. */
  95248. setPositionOfCameraUsingContainer(position: Vector3): void;
  95249. /**
  95250. * Rotates the xr camera by rotating the camera's container around the camera's position
  95251. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  95252. * @param rotation the desired quaternion rotation to apply to the camera
  95253. */
  95254. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  95255. /**
  95256. * Checks if the creation options are supported by the xr session
  95257. * @param options creation options
  95258. * @returns true if supported
  95259. */
  95260. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  95261. /**
  95262. * Disposes of the experience helper
  95263. */
  95264. dispose(): void;
  95265. }
  95266. }
  95267. declare module BABYLON {
  95268. /**
  95269. * Button which can be used to enter a different mode of XR
  95270. */
  95271. export class WebXREnterExitUIButton {
  95272. /** button element */
  95273. element: HTMLElement;
  95274. /** XR initialization options for the button */
  95275. initializationOptions: XRSessionCreationOptions;
  95276. /**
  95277. * Creates a WebXREnterExitUIButton
  95278. * @param element button element
  95279. * @param initializationOptions XR initialization options for the button
  95280. */
  95281. constructor(
  95282. /** button element */
  95283. element: HTMLElement,
  95284. /** XR initialization options for the button */
  95285. initializationOptions: XRSessionCreationOptions);
  95286. /**
  95287. * Overwritable function which can be used to update the button's visuals when the state changes
  95288. * @param activeButton the current active button in the UI
  95289. */
  95290. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  95291. }
  95292. /**
  95293. * Options to create the webXR UI
  95294. */
  95295. export class WebXREnterExitUIOptions {
  95296. /**
  95297. * Context to enter xr with
  95298. */
  95299. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  95300. /**
  95301. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  95302. */
  95303. customButtons?: Array<WebXREnterExitUIButton>;
  95304. }
  95305. /**
  95306. * UI to allow the user to enter/exit XR mode
  95307. */
  95308. export class WebXREnterExitUI implements IDisposable {
  95309. private scene;
  95310. private _overlay;
  95311. private _buttons;
  95312. private _activeButton;
  95313. /**
  95314. * Fired every time the active button is changed.
  95315. *
  95316. * When xr is entered via a button that launches xr that button will be the callback parameter
  95317. *
  95318. * When exiting xr the callback parameter will be null)
  95319. */
  95320. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  95321. /**
  95322. * Creates UI to allow the user to enter/exit XR mode
  95323. * @param scene the scene to add the ui to
  95324. * @param helper the xr experience helper to enter/exit xr with
  95325. * @param options options to configure the UI
  95326. * @returns the created ui
  95327. */
  95328. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  95329. private constructor();
  95330. private _updateButtons;
  95331. /**
  95332. * Disposes of the object
  95333. */
  95334. dispose(): void;
  95335. }
  95336. }
  95337. declare module BABYLON {
  95338. /**
  95339. * Represents an XR input
  95340. */
  95341. export class WebXRController {
  95342. /**
  95343. * 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
  95344. */
  95345. grip?: AbstractMesh;
  95346. /**
  95347. * Pointer which can be used to select objects or attach a visible laser to
  95348. */
  95349. pointer: AbstractMesh;
  95350. /**
  95351. * Creates the controller
  95352. * @see https://doc.babylonjs.com/how_to/webxr
  95353. * @param scene the scene which the controller should be associated to
  95354. */
  95355. constructor(scene: Scene);
  95356. /**
  95357. * Disposes of the object
  95358. */
  95359. dispose(): void;
  95360. }
  95361. /**
  95362. * XR input used to track XR inputs such as controllers/rays
  95363. */
  95364. export class WebXRInput implements IDisposable {
  95365. private helper;
  95366. /**
  95367. * XR controllers being tracked
  95368. */
  95369. controllers: Array<WebXRController>;
  95370. private _tmpMatrix;
  95371. private _frameObserver;
  95372. /**
  95373. * Initializes the WebXRInput
  95374. * @param helper experience helper which the input should be created for
  95375. */
  95376. constructor(helper: WebXRExperienceHelper);
  95377. /**
  95378. * Disposes of the object
  95379. */
  95380. dispose(): void;
  95381. }
  95382. }
  95383. declare module BABYLON {
  95384. /**
  95385. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  95386. */
  95387. export class WebXRManagedOutputCanvas implements IDisposable {
  95388. private _canvas;
  95389. /**
  95390. * xrpresent context of the canvas which can be used to display/mirror xr content
  95391. */
  95392. canvasContext: Nullable<WebGLRenderingContext>;
  95393. /**
  95394. * Initializes the canvas to be added/removed upon entering/exiting xr
  95395. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  95396. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  95397. */
  95398. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  95399. /**
  95400. * Disposes of the object
  95401. */
  95402. dispose(): void;
  95403. private _setManagedOutputCanvas;
  95404. private _addCanvas;
  95405. private _removeCanvas;
  95406. }
  95407. }
  95408. declare module BABYLON {
  95409. /**
  95410. * Contains an array of blocks representing the octree
  95411. */
  95412. export interface IOctreeContainer<T> {
  95413. /**
  95414. * Blocks within the octree
  95415. */
  95416. blocks: Array<OctreeBlock<T>>;
  95417. }
  95418. /**
  95419. * Class used to store a cell in an octree
  95420. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95421. */
  95422. export class OctreeBlock<T> {
  95423. /**
  95424. * Gets the content of the current block
  95425. */
  95426. entries: T[];
  95427. /**
  95428. * Gets the list of block children
  95429. */
  95430. blocks: Array<OctreeBlock<T>>;
  95431. private _depth;
  95432. private _maxDepth;
  95433. private _capacity;
  95434. private _minPoint;
  95435. private _maxPoint;
  95436. private _boundingVectors;
  95437. private _creationFunc;
  95438. /**
  95439. * Creates a new block
  95440. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  95441. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  95442. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  95443. * @param depth defines the current depth of this block in the octree
  95444. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  95445. * @param creationFunc defines a callback to call when an element is added to the block
  95446. */
  95447. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  95448. /**
  95449. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  95450. */
  95451. readonly capacity: number;
  95452. /**
  95453. * Gets the minimum vector (in world space) of the block's bounding box
  95454. */
  95455. readonly minPoint: Vector3;
  95456. /**
  95457. * Gets the maximum vector (in world space) of the block's bounding box
  95458. */
  95459. readonly maxPoint: Vector3;
  95460. /**
  95461. * Add a new element to this block
  95462. * @param entry defines the element to add
  95463. */
  95464. addEntry(entry: T): void;
  95465. /**
  95466. * Remove an element from this block
  95467. * @param entry defines the element to remove
  95468. */
  95469. removeEntry(entry: T): void;
  95470. /**
  95471. * Add an array of elements to this block
  95472. * @param entries defines the array of elements to add
  95473. */
  95474. addEntries(entries: T[]): void;
  95475. /**
  95476. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  95477. * @param frustumPlanes defines the frustum planes to test
  95478. * @param selection defines the array to store current content if selection is positive
  95479. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95480. */
  95481. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  95482. /**
  95483. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  95484. * @param sphereCenter defines the bounding sphere center
  95485. * @param sphereRadius defines the bounding sphere radius
  95486. * @param selection defines the array to store current content if selection is positive
  95487. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95488. */
  95489. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  95490. /**
  95491. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  95492. * @param ray defines the ray to test with
  95493. * @param selection defines the array to store current content if selection is positive
  95494. */
  95495. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  95496. /**
  95497. * Subdivide the content into child blocks (this block will then be empty)
  95498. */
  95499. createInnerBlocks(): void;
  95500. /**
  95501. * @hidden
  95502. */
  95503. 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;
  95504. }
  95505. }
  95506. declare module BABYLON {
  95507. /**
  95508. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  95509. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95510. */
  95511. export class Octree<T> {
  95512. /** 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.) */
  95513. maxDepth: number;
  95514. /**
  95515. * Blocks within the octree containing objects
  95516. */
  95517. blocks: Array<OctreeBlock<T>>;
  95518. /**
  95519. * Content stored in the octree
  95520. */
  95521. dynamicContent: T[];
  95522. private _maxBlockCapacity;
  95523. private _selectionContent;
  95524. private _creationFunc;
  95525. /**
  95526. * Creates a octree
  95527. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95528. * @param creationFunc function to be used to instatiate the octree
  95529. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  95530. * @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.)
  95531. */
  95532. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  95533. /** 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.) */
  95534. maxDepth?: number);
  95535. /**
  95536. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  95537. * @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);
  95538. * @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);
  95539. * @param entries meshes to be added to the octree blocks
  95540. */
  95541. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  95542. /**
  95543. * Adds a mesh to the octree
  95544. * @param entry Mesh to add to the octree
  95545. */
  95546. addMesh(entry: T): void;
  95547. /**
  95548. * Remove an element from the octree
  95549. * @param entry defines the element to remove
  95550. */
  95551. removeMesh(entry: T): void;
  95552. /**
  95553. * Selects an array of meshes within the frustum
  95554. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  95555. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  95556. * @returns array of meshes within the frustum
  95557. */
  95558. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  95559. /**
  95560. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  95561. * @param sphereCenter defines the bounding sphere center
  95562. * @param sphereRadius defines the bounding sphere radius
  95563. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95564. * @returns an array of objects that intersect the sphere
  95565. */
  95566. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  95567. /**
  95568. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  95569. * @param ray defines the ray to test with
  95570. * @returns array of intersected objects
  95571. */
  95572. intersectsRay(ray: Ray): SmartArray<T>;
  95573. /**
  95574. * Adds a mesh into the octree block if it intersects the block
  95575. */
  95576. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  95577. /**
  95578. * Adds a submesh into the octree block if it intersects the block
  95579. */
  95580. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  95581. }
  95582. }
  95583. declare module BABYLON {
  95584. interface Scene {
  95585. /**
  95586. * @hidden
  95587. * Backing Filed
  95588. */
  95589. _selectionOctree: Octree<AbstractMesh>;
  95590. /**
  95591. * Gets the octree used to boost mesh selection (picking)
  95592. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95593. */
  95594. selectionOctree: Octree<AbstractMesh>;
  95595. /**
  95596. * Creates or updates the octree used to boost selection (picking)
  95597. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95598. * @param maxCapacity defines the maximum capacity per leaf
  95599. * @param maxDepth defines the maximum depth of the octree
  95600. * @returns an octree of AbstractMesh
  95601. */
  95602. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  95603. }
  95604. interface AbstractMesh {
  95605. /**
  95606. * @hidden
  95607. * Backing Field
  95608. */
  95609. _submeshesOctree: Octree<SubMesh>;
  95610. /**
  95611. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  95612. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  95613. * @param maxCapacity defines the maximum size of each block (64 by default)
  95614. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  95615. * @returns the new octree
  95616. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  95617. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95618. */
  95619. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  95620. }
  95621. /**
  95622. * Defines the octree scene component responsible to manage any octrees
  95623. * in a given scene.
  95624. */
  95625. export class OctreeSceneComponent {
  95626. /**
  95627. * The component name helpfull to identify the component in the list of scene components.
  95628. */
  95629. readonly name: string;
  95630. /**
  95631. * The scene the component belongs to.
  95632. */
  95633. scene: Scene;
  95634. /**
  95635. * Indicates if the meshes have been checked to make sure they are isEnabled()
  95636. */
  95637. readonly checksIsEnabled: boolean;
  95638. /**
  95639. * Creates a new instance of the component for the given scene
  95640. * @param scene Defines the scene to register the component in
  95641. */
  95642. constructor(scene: Scene);
  95643. /**
  95644. * Registers the component in a given scene
  95645. */
  95646. register(): void;
  95647. /**
  95648. * Return the list of active meshes
  95649. * @returns the list of active meshes
  95650. */
  95651. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  95652. /**
  95653. * Return the list of active sub meshes
  95654. * @param mesh The mesh to get the candidates sub meshes from
  95655. * @returns the list of active sub meshes
  95656. */
  95657. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  95658. private _tempRay;
  95659. /**
  95660. * Return the list of sub meshes intersecting with a given local ray
  95661. * @param mesh defines the mesh to find the submesh for
  95662. * @param localRay defines the ray in local space
  95663. * @returns the list of intersecting sub meshes
  95664. */
  95665. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  95666. /**
  95667. * Return the list of sub meshes colliding with a collider
  95668. * @param mesh defines the mesh to find the submesh for
  95669. * @param collider defines the collider to evaluate the collision against
  95670. * @returns the list of colliding sub meshes
  95671. */
  95672. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  95673. /**
  95674. * Rebuilds the elements related to this component in case of
  95675. * context lost for instance.
  95676. */
  95677. rebuild(): void;
  95678. /**
  95679. * Disposes the component and the associated ressources.
  95680. */
  95681. dispose(): void;
  95682. }
  95683. }
  95684. declare module BABYLON {
  95685. /**
  95686. * Class containing static functions to help procedurally build meshes
  95687. */
  95688. export class LinesBuilder {
  95689. /**
  95690. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  95691. * * 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
  95692. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  95693. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  95694. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  95695. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  95696. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  95697. * * 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
  95698. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  95699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95700. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  95701. * @param name defines the name of the new line system
  95702. * @param options defines the options used to create the line system
  95703. * @param scene defines the hosting scene
  95704. * @returns a new line system mesh
  95705. */
  95706. static CreateLineSystem(name: string, options: {
  95707. lines: Vector3[][];
  95708. updatable?: boolean;
  95709. instance?: Nullable<LinesMesh>;
  95710. colors?: Nullable<Color4[][]>;
  95711. useVertexAlpha?: boolean;
  95712. }, scene: Nullable<Scene>): LinesMesh;
  95713. /**
  95714. * Creates a line mesh
  95715. * 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
  95716. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  95717. * * The parameter `points` is an array successive Vector3
  95718. * * 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
  95719. * * The optional parameter `colors` is an array of successive Color4, one per line point
  95720. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  95721. * * When updating an instance, remember that only point positions can change, not the number of points
  95722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95723. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  95724. * @param name defines the name of the new line system
  95725. * @param options defines the options used to create the line system
  95726. * @param scene defines the hosting scene
  95727. * @returns a new line mesh
  95728. */
  95729. static CreateLines(name: string, options: {
  95730. points: Vector3[];
  95731. updatable?: boolean;
  95732. instance?: Nullable<LinesMesh>;
  95733. colors?: Color4[];
  95734. useVertexAlpha?: boolean;
  95735. }, scene?: Nullable<Scene>): LinesMesh;
  95736. /**
  95737. * Creates a dashed line mesh
  95738. * * 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
  95739. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  95740. * * The parameter `points` is an array successive Vector3
  95741. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  95742. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  95743. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  95744. * * 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
  95745. * * When updating an instance, remember that only point positions can change, not the number of points
  95746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95747. * @param name defines the name of the mesh
  95748. * @param options defines the options used to create the mesh
  95749. * @param scene defines the hosting scene
  95750. * @returns the dashed line mesh
  95751. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  95752. */
  95753. static CreateDashedLines(name: string, options: {
  95754. points: Vector3[];
  95755. dashSize?: number;
  95756. gapSize?: number;
  95757. dashNb?: number;
  95758. updatable?: boolean;
  95759. instance?: LinesMesh;
  95760. }, scene?: Nullable<Scene>): LinesMesh;
  95761. }
  95762. }
  95763. declare module BABYLON {
  95764. /**
  95765. * Renders a layer on top of an existing scene
  95766. */
  95767. export class UtilityLayerRenderer implements IDisposable {
  95768. /** the original scene that will be rendered on top of */
  95769. originalScene: Scene;
  95770. private _pointerCaptures;
  95771. private _lastPointerEvents;
  95772. private static _DefaultUtilityLayer;
  95773. private static _DefaultKeepDepthUtilityLayer;
  95774. /**
  95775. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  95776. */
  95777. pickUtilitySceneFirst: boolean;
  95778. /**
  95779. * 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)
  95780. */
  95781. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  95782. /**
  95783. * 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)
  95784. */
  95785. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  95786. /**
  95787. * The scene that is rendered on top of the original scene
  95788. */
  95789. utilityLayerScene: Scene;
  95790. /**
  95791. * If the utility layer should automatically be rendered on top of existing scene
  95792. */
  95793. shouldRender: boolean;
  95794. /**
  95795. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  95796. */
  95797. onlyCheckPointerDownEvents: boolean;
  95798. /**
  95799. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  95800. */
  95801. processAllEvents: boolean;
  95802. /**
  95803. * Observable raised when the pointer move from the utility layer scene to the main scene
  95804. */
  95805. onPointerOutObservable: Observable<number>;
  95806. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  95807. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  95808. private _afterRenderObserver;
  95809. private _sceneDisposeObserver;
  95810. private _originalPointerObserver;
  95811. /**
  95812. * Instantiates a UtilityLayerRenderer
  95813. * @param originalScene the original scene that will be rendered on top of
  95814. * @param handleEvents boolean indicating if the utility layer should handle events
  95815. */
  95816. constructor(
  95817. /** the original scene that will be rendered on top of */
  95818. originalScene: Scene, handleEvents?: boolean);
  95819. private _notifyObservers;
  95820. /**
  95821. * Renders the utility layers scene on top of the original scene
  95822. */
  95823. render(): void;
  95824. /**
  95825. * Disposes of the renderer
  95826. */
  95827. dispose(): void;
  95828. private _updateCamera;
  95829. }
  95830. }
  95831. declare module BABYLON {
  95832. /**
  95833. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  95834. */
  95835. export class Gizmo implements IDisposable {
  95836. /** The utility layer the gizmo will be added to */
  95837. gizmoLayer: UtilityLayerRenderer;
  95838. /**
  95839. * The root mesh of the gizmo
  95840. */
  95841. protected _rootMesh: Mesh;
  95842. private _attachedMesh;
  95843. /**
  95844. * Ratio for the scale of the gizmo (Default: 1)
  95845. */
  95846. scaleRatio: number;
  95847. private _tmpMatrix;
  95848. /**
  95849. * If a custom mesh has been set (Default: false)
  95850. */
  95851. protected _customMeshSet: boolean;
  95852. /**
  95853. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  95854. * * When set, interactions will be enabled
  95855. */
  95856. attachedMesh: Nullable<AbstractMesh>;
  95857. /**
  95858. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  95859. * @param mesh The mesh to replace the default mesh of the gizmo
  95860. */
  95861. setCustomMesh(mesh: Mesh): void;
  95862. /**
  95863. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  95864. */
  95865. updateGizmoRotationToMatchAttachedMesh: boolean;
  95866. /**
  95867. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  95868. */
  95869. updateGizmoPositionToMatchAttachedMesh: boolean;
  95870. /**
  95871. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  95872. */
  95873. protected _updateScale: boolean;
  95874. protected _interactionsEnabled: boolean;
  95875. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  95876. private _beforeRenderObserver;
  95877. /**
  95878. * Creates a gizmo
  95879. * @param gizmoLayer The utility layer the gizmo will be added to
  95880. */
  95881. constructor(
  95882. /** The utility layer the gizmo will be added to */
  95883. gizmoLayer?: UtilityLayerRenderer);
  95884. private _tempVector;
  95885. /**
  95886. * @hidden
  95887. * Updates the gizmo to match the attached mesh's position/rotation
  95888. */
  95889. protected _update(): void;
  95890. /**
  95891. * Disposes of the gizmo
  95892. */
  95893. dispose(): void;
  95894. }
  95895. }
  95896. declare module BABYLON {
  95897. /**
  95898. * Single axis drag gizmo
  95899. */
  95900. export class AxisDragGizmo extends Gizmo {
  95901. /**
  95902. * Drag behavior responsible for the gizmos dragging interactions
  95903. */
  95904. dragBehavior: PointerDragBehavior;
  95905. private _pointerObserver;
  95906. /**
  95907. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  95908. */
  95909. snapDistance: number;
  95910. /**
  95911. * Event that fires each time the gizmo snaps to a new location.
  95912. * * snapDistance is the the change in distance
  95913. */
  95914. onSnapObservable: Observable<{
  95915. snapDistance: number;
  95916. }>;
  95917. /** @hidden */
  95918. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  95919. /** @hidden */
  95920. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  95921. /**
  95922. * Creates an AxisDragGizmo
  95923. * @param gizmoLayer The utility layer the gizmo will be added to
  95924. * @param dragAxis The axis which the gizmo will be able to drag on
  95925. * @param color The color of the gizmo
  95926. */
  95927. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  95928. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  95929. /**
  95930. * Disposes of the gizmo
  95931. */
  95932. dispose(): void;
  95933. }
  95934. }
  95935. declare module BABYLON.Debug {
  95936. /**
  95937. * The Axes viewer will show 3 axes in a specific point in space
  95938. */
  95939. export class AxesViewer {
  95940. private _xAxis;
  95941. private _yAxis;
  95942. private _zAxis;
  95943. private _scaleLinesFactor;
  95944. private _instanced;
  95945. /**
  95946. * Gets the hosting scene
  95947. */
  95948. scene: Scene;
  95949. /**
  95950. * Gets or sets a number used to scale line length
  95951. */
  95952. scaleLines: number;
  95953. /** Gets the node hierarchy used to render x-axis */
  95954. readonly xAxis: TransformNode;
  95955. /** Gets the node hierarchy used to render y-axis */
  95956. readonly yAxis: TransformNode;
  95957. /** Gets the node hierarchy used to render z-axis */
  95958. readonly zAxis: TransformNode;
  95959. /**
  95960. * Creates a new AxesViewer
  95961. * @param scene defines the hosting scene
  95962. * @param scaleLines defines a number used to scale line length (1 by default)
  95963. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  95964. * @param xAxis defines the node hierarchy used to render the x-axis
  95965. * @param yAxis defines the node hierarchy used to render the y-axis
  95966. * @param zAxis defines the node hierarchy used to render the z-axis
  95967. */
  95968. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  95969. /**
  95970. * Force the viewer to update
  95971. * @param position defines the position of the viewer
  95972. * @param xaxis defines the x axis of the viewer
  95973. * @param yaxis defines the y axis of the viewer
  95974. * @param zaxis defines the z axis of the viewer
  95975. */
  95976. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  95977. /**
  95978. * Creates an instance of this axes viewer.
  95979. * @returns a new axes viewer with instanced meshes
  95980. */
  95981. createInstance(): AxesViewer;
  95982. /** Releases resources */
  95983. dispose(): void;
  95984. private static _SetRenderingGroupId;
  95985. }
  95986. }
  95987. declare module BABYLON.Debug {
  95988. /**
  95989. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  95990. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  95991. */
  95992. export class BoneAxesViewer extends AxesViewer {
  95993. /**
  95994. * Gets or sets the target mesh where to display the axes viewer
  95995. */
  95996. mesh: Nullable<Mesh>;
  95997. /**
  95998. * Gets or sets the target bone where to display the axes viewer
  95999. */
  96000. bone: Nullable<Bone>;
  96001. /** Gets current position */
  96002. pos: Vector3;
  96003. /** Gets direction of X axis */
  96004. xaxis: Vector3;
  96005. /** Gets direction of Y axis */
  96006. yaxis: Vector3;
  96007. /** Gets direction of Z axis */
  96008. zaxis: Vector3;
  96009. /**
  96010. * Creates a new BoneAxesViewer
  96011. * @param scene defines the hosting scene
  96012. * @param bone defines the target bone
  96013. * @param mesh defines the target mesh
  96014. * @param scaleLines defines a scaling factor for line length (1 by default)
  96015. */
  96016. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  96017. /**
  96018. * Force the viewer to update
  96019. */
  96020. update(): void;
  96021. /** Releases resources */
  96022. dispose(): void;
  96023. }
  96024. }
  96025. declare module BABYLON {
  96026. /**
  96027. * Interface used to define scene explorer extensibility option
  96028. */
  96029. export interface IExplorerExtensibilityOption {
  96030. /**
  96031. * Define the option label
  96032. */
  96033. label: string;
  96034. /**
  96035. * Defines the action to execute on click
  96036. */
  96037. action: (entity: any) => void;
  96038. }
  96039. /**
  96040. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  96041. */
  96042. export interface IExplorerExtensibilityGroup {
  96043. /**
  96044. * Defines a predicate to test if a given type mut be extended
  96045. */
  96046. predicate: (entity: any) => boolean;
  96047. /**
  96048. * Gets the list of options added to a type
  96049. */
  96050. entries: IExplorerExtensibilityOption[];
  96051. }
  96052. /**
  96053. * Interface used to define the options to use to create the Inspector
  96054. */
  96055. export interface IInspectorOptions {
  96056. /**
  96057. * Display in overlay mode (default: false)
  96058. */
  96059. overlay?: boolean;
  96060. /**
  96061. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  96062. */
  96063. globalRoot?: HTMLElement;
  96064. /**
  96065. * Display the Scene explorer
  96066. */
  96067. showExplorer?: boolean;
  96068. /**
  96069. * Display the property inspector
  96070. */
  96071. showInspector?: boolean;
  96072. /**
  96073. * Display in embed mode (both panes on the right)
  96074. */
  96075. embedMode?: boolean;
  96076. /**
  96077. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  96078. */
  96079. handleResize?: boolean;
  96080. /**
  96081. * Allow the panes to popup (default: true)
  96082. */
  96083. enablePopup?: boolean;
  96084. /**
  96085. * Allow the panes to be closed by users (default: true)
  96086. */
  96087. enableClose?: boolean;
  96088. /**
  96089. * Optional list of extensibility entries
  96090. */
  96091. explorerExtensibility?: IExplorerExtensibilityGroup[];
  96092. }
  96093. interface Scene {
  96094. /**
  96095. * @hidden
  96096. * Backing field
  96097. */
  96098. _debugLayer: DebugLayer;
  96099. /**
  96100. * Gets the debug layer (aka Inspector) associated with the scene
  96101. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96102. */
  96103. debugLayer: DebugLayer;
  96104. }
  96105. /**
  96106. * The debug layer (aka Inspector) is the go to tool in order to better understand
  96107. * what is happening in your scene
  96108. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96109. */
  96110. export class DebugLayer {
  96111. /**
  96112. * Define the url to get the inspector script from.
  96113. * By default it uses the babylonjs CDN.
  96114. * @ignoreNaming
  96115. */
  96116. static InspectorURL: string;
  96117. private _scene;
  96118. private BJSINSPECTOR;
  96119. /**
  96120. * Observable triggered when a property is changed through the inspector.
  96121. */
  96122. onPropertyChangedObservable: Observable<{
  96123. object: any;
  96124. property: string;
  96125. value: any;
  96126. initialValue: any;
  96127. }>;
  96128. /**
  96129. * Instantiates a new debug layer.
  96130. * The debug layer (aka Inspector) is the go to tool in order to better understand
  96131. * what is happening in your scene
  96132. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96133. * @param scene Defines the scene to inspect
  96134. */
  96135. constructor(scene: Scene);
  96136. /** Creates the inspector window. */
  96137. private _createInspector;
  96138. /** Get the inspector from bundle or global */
  96139. private _getGlobalInspector;
  96140. /**
  96141. * Get if the inspector is visible or not.
  96142. * @returns true if visible otherwise, false
  96143. */
  96144. isVisible(): boolean;
  96145. /**
  96146. * Hide the inspector and close its window.
  96147. */
  96148. hide(): void;
  96149. /**
  96150. * Launch the debugLayer.
  96151. * @param config Define the configuration of the inspector
  96152. */
  96153. show(config?: IInspectorOptions): void;
  96154. }
  96155. }
  96156. declare module BABYLON {
  96157. /**
  96158. * Class containing static functions to help procedurally build meshes
  96159. */
  96160. export class BoxBuilder {
  96161. /**
  96162. * Creates a box mesh
  96163. * * The parameter `size` sets the size (float) of each box side (default 1)
  96164. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  96165. * * 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)
  96166. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  96167. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96168. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96170. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  96171. * @param name defines the name of the mesh
  96172. * @param options defines the options used to create the mesh
  96173. * @param scene defines the hosting scene
  96174. * @returns the box mesh
  96175. */
  96176. static CreateBox(name: string, options: {
  96177. size?: number;
  96178. width?: number;
  96179. height?: number;
  96180. depth?: number;
  96181. faceUV?: Vector4[];
  96182. faceColors?: Color4[];
  96183. sideOrientation?: number;
  96184. frontUVs?: Vector4;
  96185. backUVs?: Vector4;
  96186. updatable?: boolean;
  96187. }, scene?: Nullable<Scene>): Mesh;
  96188. }
  96189. }
  96190. declare module BABYLON {
  96191. /**
  96192. * Class containing static functions to help procedurally build meshes
  96193. */
  96194. export class SphereBuilder {
  96195. /**
  96196. * Creates a sphere mesh
  96197. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  96198. * * 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`)
  96199. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  96200. * * 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
  96201. * * 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)
  96202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96205. * @param name defines the name of the mesh
  96206. * @param options defines the options used to create the mesh
  96207. * @param scene defines the hosting scene
  96208. * @returns the sphere mesh
  96209. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  96210. */
  96211. static CreateSphere(name: string, options: {
  96212. segments?: number;
  96213. diameter?: number;
  96214. diameterX?: number;
  96215. diameterY?: number;
  96216. diameterZ?: number;
  96217. arc?: number;
  96218. slice?: number;
  96219. sideOrientation?: number;
  96220. frontUVs?: Vector4;
  96221. backUVs?: Vector4;
  96222. updatable?: boolean;
  96223. }, scene: any): Mesh;
  96224. }
  96225. }
  96226. declare module BABYLON.Debug {
  96227. /**
  96228. * Used to show the physics impostor around the specific mesh
  96229. */
  96230. export class PhysicsViewer {
  96231. /** @hidden */
  96232. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  96233. /** @hidden */
  96234. protected _meshes: Array<Nullable<AbstractMesh>>;
  96235. /** @hidden */
  96236. protected _scene: Nullable<Scene>;
  96237. /** @hidden */
  96238. protected _numMeshes: number;
  96239. /** @hidden */
  96240. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  96241. private _renderFunction;
  96242. private _utilityLayer;
  96243. private _debugBoxMesh;
  96244. private _debugSphereMesh;
  96245. private _debugMaterial;
  96246. /**
  96247. * Creates a new PhysicsViewer
  96248. * @param scene defines the hosting scene
  96249. */
  96250. constructor(scene: Scene);
  96251. /** @hidden */
  96252. protected _updateDebugMeshes(): void;
  96253. /**
  96254. * Renders a specified physic impostor
  96255. * @param impostor defines the impostor to render
  96256. * @returns the new debug mesh used to render the impostor
  96257. */
  96258. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  96259. /**
  96260. * Hides a specified physic impostor
  96261. * @param impostor defines the impostor to hide
  96262. */
  96263. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  96264. private _getDebugMaterial;
  96265. private _getDebugBoxMesh;
  96266. private _getDebugSphereMesh;
  96267. private _getDebugMesh;
  96268. /** Releases all resources */
  96269. dispose(): void;
  96270. }
  96271. }
  96272. declare module BABYLON {
  96273. /**
  96274. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  96275. * in order to better appreciate the issue one might have.
  96276. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  96277. */
  96278. export class RayHelper {
  96279. /**
  96280. * Defines the ray we are currently tryin to visualize.
  96281. */
  96282. ray: Nullable<Ray>;
  96283. private _renderPoints;
  96284. private _renderLine;
  96285. private _renderFunction;
  96286. private _scene;
  96287. private _updateToMeshFunction;
  96288. private _attachedToMesh;
  96289. private _meshSpaceDirection;
  96290. private _meshSpaceOrigin;
  96291. /**
  96292. * Helper function to create a colored helper in a scene in one line.
  96293. * @param ray Defines the ray we are currently tryin to visualize
  96294. * @param scene Defines the scene the ray is used in
  96295. * @param color Defines the color we want to see the ray in
  96296. * @returns The newly created ray helper.
  96297. */
  96298. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  96299. /**
  96300. * Instantiate a new ray helper.
  96301. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  96302. * in order to better appreciate the issue one might have.
  96303. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  96304. * @param ray Defines the ray we are currently tryin to visualize
  96305. */
  96306. constructor(ray: Ray);
  96307. /**
  96308. * Shows the ray we are willing to debug.
  96309. * @param scene Defines the scene the ray needs to be rendered in
  96310. * @param color Defines the color the ray needs to be rendered in
  96311. */
  96312. show(scene: Scene, color?: Color3): void;
  96313. /**
  96314. * Hides the ray we are debugging.
  96315. */
  96316. hide(): void;
  96317. private _render;
  96318. /**
  96319. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  96320. * @param mesh Defines the mesh we want the helper attached to
  96321. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  96322. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  96323. * @param length Defines the length of the ray
  96324. */
  96325. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  96326. /**
  96327. * Detach the ray helper from the mesh it has previously been attached to.
  96328. */
  96329. detachFromMesh(): void;
  96330. private _updateToMesh;
  96331. /**
  96332. * Dispose the helper and release its associated resources.
  96333. */
  96334. dispose(): void;
  96335. }
  96336. }
  96337. declare module BABYLON.Debug {
  96338. /**
  96339. * Class used to render a debug view of a given skeleton
  96340. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  96341. */
  96342. export class SkeletonViewer {
  96343. /** defines the skeleton to render */
  96344. skeleton: Skeleton;
  96345. /** defines the mesh attached to the skeleton */
  96346. mesh: AbstractMesh;
  96347. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  96348. autoUpdateBonesMatrices: boolean;
  96349. /** defines the rendering group id to use with the viewer */
  96350. renderingGroupId: number;
  96351. /** Gets or sets the color used to render the skeleton */
  96352. color: Color3;
  96353. private _scene;
  96354. private _debugLines;
  96355. private _debugMesh;
  96356. private _isEnabled;
  96357. private _renderFunction;
  96358. private _utilityLayer;
  96359. /**
  96360. * Returns the mesh used to render the bones
  96361. */
  96362. readonly debugMesh: Nullable<LinesMesh>;
  96363. /**
  96364. * Creates a new SkeletonViewer
  96365. * @param skeleton defines the skeleton to render
  96366. * @param mesh defines the mesh attached to the skeleton
  96367. * @param scene defines the hosting scene
  96368. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  96369. * @param renderingGroupId defines the rendering group id to use with the viewer
  96370. */
  96371. constructor(
  96372. /** defines the skeleton to render */
  96373. skeleton: Skeleton,
  96374. /** defines the mesh attached to the skeleton */
  96375. mesh: AbstractMesh, scene: Scene,
  96376. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  96377. autoUpdateBonesMatrices?: boolean,
  96378. /** defines the rendering group id to use with the viewer */
  96379. renderingGroupId?: number);
  96380. /** Gets or sets a boolean indicating if the viewer is enabled */
  96381. isEnabled: boolean;
  96382. private _getBonePosition;
  96383. private _getLinesForBonesWithLength;
  96384. private _getLinesForBonesNoLength;
  96385. /** Update the viewer to sync with current skeleton state */
  96386. update(): void;
  96387. /** Release associated resources */
  96388. dispose(): void;
  96389. }
  96390. }
  96391. declare module BABYLON {
  96392. /**
  96393. * Options to create the null engine
  96394. */
  96395. export class NullEngineOptions {
  96396. /**
  96397. * Render width (Default: 512)
  96398. */
  96399. renderWidth: number;
  96400. /**
  96401. * Render height (Default: 256)
  96402. */
  96403. renderHeight: number;
  96404. /**
  96405. * Texture size (Default: 512)
  96406. */
  96407. textureSize: number;
  96408. /**
  96409. * If delta time between frames should be constant
  96410. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96411. */
  96412. deterministicLockstep: boolean;
  96413. /**
  96414. * Maximum about of steps between frames (Default: 4)
  96415. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96416. */
  96417. lockstepMaxSteps: number;
  96418. }
  96419. /**
  96420. * The null engine class provides support for headless version of babylon.js.
  96421. * This can be used in server side scenario or for testing purposes
  96422. */
  96423. export class NullEngine extends Engine {
  96424. private _options;
  96425. /**
  96426. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96427. */
  96428. isDeterministicLockStep(): boolean;
  96429. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  96430. getLockstepMaxSteps(): number;
  96431. /**
  96432. * Sets hardware scaling, used to save performance if needed
  96433. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96434. */
  96435. getHardwareScalingLevel(): number;
  96436. constructor(options?: NullEngineOptions);
  96437. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  96438. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  96439. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96440. getRenderWidth(useScreen?: boolean): number;
  96441. getRenderHeight(useScreen?: boolean): number;
  96442. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  96443. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  96444. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  96445. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  96446. bindSamplers(effect: Effect): void;
  96447. enableEffect(effect: Effect): void;
  96448. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  96449. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  96450. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  96451. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  96452. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  96453. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  96454. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  96455. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  96456. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  96457. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  96458. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  96459. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  96460. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  96461. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  96462. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  96463. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  96464. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  96465. setFloat(uniform: WebGLUniformLocation, value: number): void;
  96466. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  96467. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  96468. setBool(uniform: WebGLUniformLocation, bool: number): void;
  96469. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  96470. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  96471. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  96472. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  96473. bindBuffers(vertexBuffers: {
  96474. [key: string]: VertexBuffer;
  96475. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  96476. wipeCaches(bruteForce?: boolean): void;
  96477. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96478. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96479. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96480. /** @hidden */
  96481. _createTexture(): WebGLTexture;
  96482. /** @hidden */
  96483. _releaseTexture(texture: InternalTexture): void;
  96484. 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;
  96485. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  96486. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96487. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  96488. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96489. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  96490. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  96491. areAllEffectsReady(): boolean;
  96492. /**
  96493. * @hidden
  96494. * Get the current error code of the webGL context
  96495. * @returns the error code
  96496. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96497. */
  96498. getError(): number;
  96499. /** @hidden */
  96500. _getUnpackAlignement(): number;
  96501. /** @hidden */
  96502. _unpackFlipY(value: boolean): void;
  96503. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  96504. /**
  96505. * Updates a dynamic vertex buffer.
  96506. * @param vertexBuffer the vertex buffer to update
  96507. * @param data the data used to update the vertex buffer
  96508. * @param byteOffset the byte offset of the data (optional)
  96509. * @param byteLength the byte length of the data (optional)
  96510. */
  96511. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  96512. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  96513. /** @hidden */
  96514. _bindTexture(channel: number, texture: InternalTexture): void;
  96515. /** @hidden */
  96516. _releaseBuffer(buffer: WebGLBuffer): boolean;
  96517. releaseEffects(): void;
  96518. displayLoadingUI(): void;
  96519. hideLoadingUI(): void;
  96520. /** @hidden */
  96521. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96522. /** @hidden */
  96523. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96524. /** @hidden */
  96525. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96526. /** @hidden */
  96527. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96528. }
  96529. }
  96530. declare module BABYLON {
  96531. /** @hidden */
  96532. export class _OcclusionDataStorage {
  96533. /** @hidden */
  96534. occlusionInternalRetryCounter: number;
  96535. /** @hidden */
  96536. isOcclusionQueryInProgress: boolean;
  96537. /** @hidden */
  96538. isOccluded: boolean;
  96539. /** @hidden */
  96540. occlusionRetryCount: number;
  96541. /** @hidden */
  96542. occlusionType: number;
  96543. /** @hidden */
  96544. occlusionQueryAlgorithmType: number;
  96545. }
  96546. interface Engine {
  96547. /**
  96548. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  96549. * @return the new query
  96550. */
  96551. createQuery(): WebGLQuery;
  96552. /**
  96553. * Delete and release a webGL query
  96554. * @param query defines the query to delete
  96555. * @return the current engine
  96556. */
  96557. deleteQuery(query: WebGLQuery): Engine;
  96558. /**
  96559. * Check if a given query has resolved and got its value
  96560. * @param query defines the query to check
  96561. * @returns true if the query got its value
  96562. */
  96563. isQueryResultAvailable(query: WebGLQuery): boolean;
  96564. /**
  96565. * Gets the value of a given query
  96566. * @param query defines the query to check
  96567. * @returns the value of the query
  96568. */
  96569. getQueryResult(query: WebGLQuery): number;
  96570. /**
  96571. * Initiates an occlusion query
  96572. * @param algorithmType defines the algorithm to use
  96573. * @param query defines the query to use
  96574. * @returns the current engine
  96575. * @see http://doc.babylonjs.com/features/occlusionquery
  96576. */
  96577. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  96578. /**
  96579. * Ends an occlusion query
  96580. * @see http://doc.babylonjs.com/features/occlusionquery
  96581. * @param algorithmType defines the algorithm to use
  96582. * @returns the current engine
  96583. */
  96584. endOcclusionQuery(algorithmType: number): Engine;
  96585. /**
  96586. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  96587. * Please note that only one query can be issued at a time
  96588. * @returns a time token used to track the time span
  96589. */
  96590. startTimeQuery(): Nullable<_TimeToken>;
  96591. /**
  96592. * Ends a time query
  96593. * @param token defines the token used to measure the time span
  96594. * @returns the time spent (in ns)
  96595. */
  96596. endTimeQuery(token: _TimeToken): int;
  96597. /** @hidden */
  96598. _currentNonTimestampToken: Nullable<_TimeToken>;
  96599. /** @hidden */
  96600. _createTimeQuery(): WebGLQuery;
  96601. /** @hidden */
  96602. _deleteTimeQuery(query: WebGLQuery): void;
  96603. /** @hidden */
  96604. _getGlAlgorithmType(algorithmType: number): number;
  96605. /** @hidden */
  96606. _getTimeQueryResult(query: WebGLQuery): any;
  96607. /** @hidden */
  96608. _getTimeQueryAvailability(query: WebGLQuery): any;
  96609. }
  96610. interface AbstractMesh {
  96611. /**
  96612. * Backing filed
  96613. * @hidden
  96614. */
  96615. __occlusionDataStorage: _OcclusionDataStorage;
  96616. /**
  96617. * Access property
  96618. * @hidden
  96619. */
  96620. _occlusionDataStorage: _OcclusionDataStorage;
  96621. /**
  96622. * 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.
  96623. * The default value is -1 which means don't break the query and wait till the result
  96624. * @see http://doc.babylonjs.com/features/occlusionquery
  96625. */
  96626. occlusionRetryCount: number;
  96627. /**
  96628. * 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:
  96629. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  96630. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  96631. * * 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.
  96632. * @see http://doc.babylonjs.com/features/occlusionquery
  96633. */
  96634. occlusionType: number;
  96635. /**
  96636. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  96637. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  96638. * * 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.
  96639. * @see http://doc.babylonjs.com/features/occlusionquery
  96640. */
  96641. occlusionQueryAlgorithmType: number;
  96642. /**
  96643. * 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
  96644. * @see http://doc.babylonjs.com/features/occlusionquery
  96645. */
  96646. isOccluded: boolean;
  96647. /**
  96648. * Flag to check the progress status of the query
  96649. * @see http://doc.babylonjs.com/features/occlusionquery
  96650. */
  96651. isOcclusionQueryInProgress: boolean;
  96652. }
  96653. }
  96654. declare module BABYLON {
  96655. /** @hidden */
  96656. export var _forceTransformFeedbackToBundle: boolean;
  96657. interface Engine {
  96658. /**
  96659. * Creates a webGL transform feedback object
  96660. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  96661. * @returns the webGL transform feedback object
  96662. */
  96663. createTransformFeedback(): WebGLTransformFeedback;
  96664. /**
  96665. * Delete a webGL transform feedback object
  96666. * @param value defines the webGL transform feedback object to delete
  96667. */
  96668. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  96669. /**
  96670. * Bind a webGL transform feedback object to the webgl context
  96671. * @param value defines the webGL transform feedback object to bind
  96672. */
  96673. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  96674. /**
  96675. * Begins a transform feedback operation
  96676. * @param usePoints defines if points or triangles must be used
  96677. */
  96678. beginTransformFeedback(usePoints: boolean): void;
  96679. /**
  96680. * Ends a transform feedback operation
  96681. */
  96682. endTransformFeedback(): void;
  96683. /**
  96684. * Specify the varyings to use with transform feedback
  96685. * @param program defines the associated webGL program
  96686. * @param value defines the list of strings representing the varying names
  96687. */
  96688. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  96689. /**
  96690. * Bind a webGL buffer for a transform feedback operation
  96691. * @param value defines the webGL buffer to bind
  96692. */
  96693. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  96694. }
  96695. }
  96696. declare module BABYLON {
  96697. /**
  96698. * Gather the list of clipboard event types as constants.
  96699. */
  96700. export class ClipboardEventTypes {
  96701. /**
  96702. * The clipboard event is fired when a copy command is active (pressed).
  96703. */
  96704. static readonly COPY: number;
  96705. /**
  96706. * The clipboard event is fired when a cut command is active (pressed).
  96707. */
  96708. static readonly CUT: number;
  96709. /**
  96710. * The clipboard event is fired when a paste command is active (pressed).
  96711. */
  96712. static readonly PASTE: number;
  96713. }
  96714. /**
  96715. * This class is used to store clipboard related info for the onClipboardObservable event.
  96716. */
  96717. export class ClipboardInfo {
  96718. /**
  96719. * Defines the type of event (BABYLON.ClipboardEventTypes)
  96720. */
  96721. type: number;
  96722. /**
  96723. * Defines the related dom event
  96724. */
  96725. event: ClipboardEvent;
  96726. /**
  96727. *Creates an instance of ClipboardInfo.
  96728. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  96729. * @param event Defines the related dom event
  96730. */
  96731. constructor(
  96732. /**
  96733. * Defines the type of event (BABYLON.ClipboardEventTypes)
  96734. */
  96735. type: number,
  96736. /**
  96737. * Defines the related dom event
  96738. */
  96739. event: ClipboardEvent);
  96740. /**
  96741. * Get the clipboard event's type from the keycode.
  96742. * @param keyCode Defines the keyCode for the current keyboard event.
  96743. * @return {number}
  96744. */
  96745. static GetTypeFromCharacter(keyCode: number): number;
  96746. }
  96747. }
  96748. declare module BABYLON {
  96749. /**
  96750. * Class used to represent data loading progression
  96751. */
  96752. export class SceneLoaderProgressEvent {
  96753. /** defines if data length to load can be evaluated */
  96754. readonly lengthComputable: boolean;
  96755. /** defines the loaded data length */
  96756. readonly loaded: number;
  96757. /** defines the data length to load */
  96758. readonly total: number;
  96759. /**
  96760. * Create a new progress event
  96761. * @param lengthComputable defines if data length to load can be evaluated
  96762. * @param loaded defines the loaded data length
  96763. * @param total defines the data length to load
  96764. */
  96765. constructor(
  96766. /** defines if data length to load can be evaluated */
  96767. lengthComputable: boolean,
  96768. /** defines the loaded data length */
  96769. loaded: number,
  96770. /** defines the data length to load */
  96771. total: number);
  96772. /**
  96773. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  96774. * @param event defines the source event
  96775. * @returns a new SceneLoaderProgressEvent
  96776. */
  96777. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  96778. }
  96779. /**
  96780. * Interface used by SceneLoader plugins to define supported file extensions
  96781. */
  96782. export interface ISceneLoaderPluginExtensions {
  96783. /**
  96784. * Defines the list of supported extensions
  96785. */
  96786. [extension: string]: {
  96787. isBinary: boolean;
  96788. };
  96789. }
  96790. /**
  96791. * Interface used by SceneLoader plugin factory
  96792. */
  96793. export interface ISceneLoaderPluginFactory {
  96794. /**
  96795. * Defines the name of the factory
  96796. */
  96797. name: string;
  96798. /**
  96799. * Function called to create a new plugin
  96800. * @return the new plugin
  96801. */
  96802. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  96803. /**
  96804. * Boolean indicating if the plugin can direct load specific data
  96805. */
  96806. canDirectLoad?: (data: string) => boolean;
  96807. }
  96808. /**
  96809. * Interface used to define a SceneLoader plugin
  96810. */
  96811. export interface ISceneLoaderPlugin {
  96812. /**
  96813. * The friendly name of this plugin.
  96814. */
  96815. name: string;
  96816. /**
  96817. * The file extensions supported by this plugin.
  96818. */
  96819. extensions: string | ISceneLoaderPluginExtensions;
  96820. /**
  96821. * Import meshes into a scene.
  96822. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  96823. * @param scene The scene to import into
  96824. * @param data The data to import
  96825. * @param rootUrl The root url for scene and resources
  96826. * @param meshes The meshes array to import into
  96827. * @param particleSystems The particle systems array to import into
  96828. * @param skeletons The skeletons array to import into
  96829. * @param onError The callback when import fails
  96830. * @returns True if successful or false otherwise
  96831. */
  96832. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  96833. /**
  96834. * Load into a scene.
  96835. * @param scene The scene to load into
  96836. * @param data The data to import
  96837. * @param rootUrl The root url for scene and resources
  96838. * @param onError The callback when import fails
  96839. * @returns true if successful or false otherwise
  96840. */
  96841. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  96842. /**
  96843. * The callback that returns true if the data can be directly loaded.
  96844. */
  96845. canDirectLoad?: (data: string) => boolean;
  96846. /**
  96847. * The callback that allows custom handling of the root url based on the response url.
  96848. */
  96849. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  96850. /**
  96851. * Load into an asset container.
  96852. * @param scene The scene to load into
  96853. * @param data The data to import
  96854. * @param rootUrl The root url for scene and resources
  96855. * @param onError The callback when import fails
  96856. * @returns The loaded asset container
  96857. */
  96858. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  96859. }
  96860. /**
  96861. * Interface used to define an async SceneLoader plugin
  96862. */
  96863. export interface ISceneLoaderPluginAsync {
  96864. /**
  96865. * The friendly name of this plugin.
  96866. */
  96867. name: string;
  96868. /**
  96869. * The file extensions supported by this plugin.
  96870. */
  96871. extensions: string | ISceneLoaderPluginExtensions;
  96872. /**
  96873. * Import meshes into a scene.
  96874. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  96875. * @param scene The scene to import into
  96876. * @param data The data to import
  96877. * @param rootUrl The root url for scene and resources
  96878. * @param onProgress The callback when the load progresses
  96879. * @param fileName Defines the name of the file to load
  96880. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  96881. */
  96882. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  96883. meshes: AbstractMesh[];
  96884. particleSystems: IParticleSystem[];
  96885. skeletons: Skeleton[];
  96886. animationGroups: AnimationGroup[];
  96887. }>;
  96888. /**
  96889. * Load into a scene.
  96890. * @param scene The scene to load into
  96891. * @param data The data to import
  96892. * @param rootUrl The root url for scene and resources
  96893. * @param onProgress The callback when the load progresses
  96894. * @param fileName Defines the name of the file to load
  96895. * @returns Nothing
  96896. */
  96897. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  96898. /**
  96899. * The callback that returns true if the data can be directly loaded.
  96900. */
  96901. canDirectLoad?: (data: string) => boolean;
  96902. /**
  96903. * The callback that allows custom handling of the root url based on the response url.
  96904. */
  96905. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  96906. /**
  96907. * Load into an asset container.
  96908. * @param scene The scene to load into
  96909. * @param data The data to import
  96910. * @param rootUrl The root url for scene and resources
  96911. * @param onProgress The callback when the load progresses
  96912. * @param fileName Defines the name of the file to load
  96913. * @returns The loaded asset container
  96914. */
  96915. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  96916. }
  96917. /**
  96918. * Class used to load scene from various file formats using registered plugins
  96919. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  96920. */
  96921. export class SceneLoader {
  96922. /**
  96923. * No logging while loading
  96924. */
  96925. static readonly NO_LOGGING: number;
  96926. /**
  96927. * Minimal logging while loading
  96928. */
  96929. static readonly MINIMAL_LOGGING: number;
  96930. /**
  96931. * Summary logging while loading
  96932. */
  96933. static readonly SUMMARY_LOGGING: number;
  96934. /**
  96935. * Detailled logging while loading
  96936. */
  96937. static readonly DETAILED_LOGGING: number;
  96938. /**
  96939. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  96940. */
  96941. static ForceFullSceneLoadingForIncremental: boolean;
  96942. /**
  96943. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  96944. */
  96945. static ShowLoadingScreen: boolean;
  96946. /**
  96947. * Defines the current logging level (while loading the scene)
  96948. * @ignorenaming
  96949. */
  96950. static loggingLevel: number;
  96951. /**
  96952. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  96953. */
  96954. static CleanBoneMatrixWeights: boolean;
  96955. /**
  96956. * Event raised when a plugin is used to load a scene
  96957. */
  96958. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  96959. private static _registeredPlugins;
  96960. private static _getDefaultPlugin;
  96961. private static _getPluginForExtension;
  96962. private static _getPluginForDirectLoad;
  96963. private static _getPluginForFilename;
  96964. private static _getDirectLoad;
  96965. private static _loadData;
  96966. private static _getFileInfo;
  96967. /**
  96968. * Gets a plugin that can load the given extension
  96969. * @param extension defines the extension to load
  96970. * @returns a plugin or null if none works
  96971. */
  96972. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  96973. /**
  96974. * Gets a boolean indicating that the given extension can be loaded
  96975. * @param extension defines the extension to load
  96976. * @returns true if the extension is supported
  96977. */
  96978. static IsPluginForExtensionAvailable(extension: string): boolean;
  96979. /**
  96980. * Adds a new plugin to the list of registered plugins
  96981. * @param plugin defines the plugin to add
  96982. */
  96983. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  96984. /**
  96985. * Import meshes into a scene
  96986. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  96987. * @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)
  96988. * @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)
  96989. * @param scene the instance of BABYLON.Scene to append to
  96990. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  96991. * @param onProgress a callback with a progress event for each file being loaded
  96992. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  96993. * @param pluginExtension the extension used to determine the plugin
  96994. * @returns The loaded plugin
  96995. */
  96996. 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>;
  96997. /**
  96998. * Import meshes into a scene
  96999. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  97000. * @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)
  97001. * @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)
  97002. * @param scene the instance of BABYLON.Scene to append to
  97003. * @param onProgress a callback with a progress event for each file being loaded
  97004. * @param pluginExtension the extension used to determine the plugin
  97005. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  97006. */
  97007. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  97008. meshes: AbstractMesh[];
  97009. particleSystems: IParticleSystem[];
  97010. skeletons: Skeleton[];
  97011. animationGroups: AnimationGroup[];
  97012. }>;
  97013. /**
  97014. * Load a scene
  97015. * @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)
  97016. * @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)
  97017. * @param engine is the instance of BABYLON.Engine to use to create the scene
  97018. * @param onSuccess a callback with the scene when import succeeds
  97019. * @param onProgress a callback with a progress event for each file being loaded
  97020. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97021. * @param pluginExtension the extension used to determine the plugin
  97022. * @returns The loaded plugin
  97023. */
  97024. 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>;
  97025. /**
  97026. * Load a scene
  97027. * @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)
  97028. * @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)
  97029. * @param engine is the instance of BABYLON.Engine to use to create the scene
  97030. * @param onProgress a callback with a progress event for each file being loaded
  97031. * @param pluginExtension the extension used to determine the plugin
  97032. * @returns The loaded scene
  97033. */
  97034. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  97035. /**
  97036. * Append a scene
  97037. * @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)
  97038. * @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)
  97039. * @param scene is the instance of BABYLON.Scene to append to
  97040. * @param onSuccess a callback with the scene when import succeeds
  97041. * @param onProgress a callback with a progress event for each file being loaded
  97042. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97043. * @param pluginExtension the extension used to determine the plugin
  97044. * @returns The loaded plugin
  97045. */
  97046. 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>;
  97047. /**
  97048. * Append a scene
  97049. * @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)
  97050. * @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)
  97051. * @param scene is the instance of BABYLON.Scene to append to
  97052. * @param onProgress a callback with a progress event for each file being loaded
  97053. * @param pluginExtension the extension used to determine the plugin
  97054. * @returns The given scene
  97055. */
  97056. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  97057. /**
  97058. * Load a scene into an asset container
  97059. * @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)
  97060. * @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)
  97061. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  97062. * @param onSuccess a callback with the scene when import succeeds
  97063. * @param onProgress a callback with a progress event for each file being loaded
  97064. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97065. * @param pluginExtension the extension used to determine the plugin
  97066. * @returns The loaded plugin
  97067. */
  97068. 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>;
  97069. /**
  97070. * Load a scene into an asset container
  97071. * @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)
  97072. * @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)
  97073. * @param scene is the instance of Scene to append to
  97074. * @param onProgress a callback with a progress event for each file being loaded
  97075. * @param pluginExtension the extension used to determine the plugin
  97076. * @returns The loaded asset container
  97077. */
  97078. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  97079. }
  97080. }
  97081. declare module BABYLON {
  97082. /**
  97083. * Google Daydream controller
  97084. */
  97085. export class DaydreamController extends WebVRController {
  97086. /**
  97087. * Base Url for the controller model.
  97088. */
  97089. static MODEL_BASE_URL: string;
  97090. /**
  97091. * File name for the controller model.
  97092. */
  97093. static MODEL_FILENAME: string;
  97094. /**
  97095. * Gamepad Id prefix used to identify Daydream Controller.
  97096. */
  97097. static readonly GAMEPAD_ID_PREFIX: string;
  97098. /**
  97099. * Creates a new DaydreamController from a gamepad
  97100. * @param vrGamepad the gamepad that the controller should be created from
  97101. */
  97102. constructor(vrGamepad: any);
  97103. /**
  97104. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97105. * @param scene scene in which to add meshes
  97106. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97107. */
  97108. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97109. /**
  97110. * Called once for each button that changed state since the last frame
  97111. * @param buttonIdx Which button index changed
  97112. * @param state New state of the button
  97113. * @param changes Which properties on the state changed since last frame
  97114. */
  97115. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97116. }
  97117. }
  97118. declare module BABYLON {
  97119. /**
  97120. * Gear VR Controller
  97121. */
  97122. export class GearVRController extends WebVRController {
  97123. /**
  97124. * Base Url for the controller model.
  97125. */
  97126. static MODEL_BASE_URL: string;
  97127. /**
  97128. * File name for the controller model.
  97129. */
  97130. static MODEL_FILENAME: string;
  97131. /**
  97132. * Gamepad Id prefix used to identify this controller.
  97133. */
  97134. static readonly GAMEPAD_ID_PREFIX: string;
  97135. private readonly _buttonIndexToObservableNameMap;
  97136. /**
  97137. * Creates a new GearVRController from a gamepad
  97138. * @param vrGamepad the gamepad that the controller should be created from
  97139. */
  97140. constructor(vrGamepad: any);
  97141. /**
  97142. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97143. * @param scene scene in which to add meshes
  97144. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97145. */
  97146. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97147. /**
  97148. * Called once for each button that changed state since the last frame
  97149. * @param buttonIdx Which button index changed
  97150. * @param state New state of the button
  97151. * @param changes Which properties on the state changed since last frame
  97152. */
  97153. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97154. }
  97155. }
  97156. declare module BABYLON {
  97157. /**
  97158. * Generic Controller
  97159. */
  97160. export class GenericController extends WebVRController {
  97161. /**
  97162. * Base Url for the controller model.
  97163. */
  97164. static readonly MODEL_BASE_URL: string;
  97165. /**
  97166. * File name for the controller model.
  97167. */
  97168. static readonly MODEL_FILENAME: string;
  97169. /**
  97170. * Creates a new GenericController from a gamepad
  97171. * @param vrGamepad the gamepad that the controller should be created from
  97172. */
  97173. constructor(vrGamepad: any);
  97174. /**
  97175. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97176. * @param scene scene in which to add meshes
  97177. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97178. */
  97179. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97180. /**
  97181. * Called once for each button that changed state since the last frame
  97182. * @param buttonIdx Which button index changed
  97183. * @param state New state of the button
  97184. * @param changes Which properties on the state changed since last frame
  97185. */
  97186. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97187. }
  97188. }
  97189. declare module BABYLON {
  97190. /**
  97191. * Oculus Touch Controller
  97192. */
  97193. export class OculusTouchController extends WebVRController {
  97194. /**
  97195. * Base Url for the controller model.
  97196. */
  97197. static MODEL_BASE_URL: string;
  97198. /**
  97199. * File name for the left controller model.
  97200. */
  97201. static MODEL_LEFT_FILENAME: string;
  97202. /**
  97203. * File name for the right controller model.
  97204. */
  97205. static MODEL_RIGHT_FILENAME: string;
  97206. /**
  97207. * Fired when the secondary trigger on this controller is modified
  97208. */
  97209. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  97210. /**
  97211. * Fired when the thumb rest on this controller is modified
  97212. */
  97213. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  97214. /**
  97215. * Creates a new OculusTouchController from a gamepad
  97216. * @param vrGamepad the gamepad that the controller should be created from
  97217. */
  97218. constructor(vrGamepad: any);
  97219. /**
  97220. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97221. * @param scene scene in which to add meshes
  97222. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97223. */
  97224. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97225. /**
  97226. * Fired when the A button on this controller is modified
  97227. */
  97228. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97229. /**
  97230. * Fired when the B button on this controller is modified
  97231. */
  97232. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97233. /**
  97234. * Fired when the X button on this controller is modified
  97235. */
  97236. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97237. /**
  97238. * Fired when the Y button on this controller is modified
  97239. */
  97240. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97241. /**
  97242. * Called once for each button that changed state since the last frame
  97243. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  97244. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  97245. * 2) secondary trigger (same)
  97246. * 3) A (right) X (left), touch, pressed = value
  97247. * 4) B / Y
  97248. * 5) thumb rest
  97249. * @param buttonIdx Which button index changed
  97250. * @param state New state of the button
  97251. * @param changes Which properties on the state changed since last frame
  97252. */
  97253. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97254. }
  97255. }
  97256. declare module BABYLON {
  97257. /**
  97258. * Vive Controller
  97259. */
  97260. export class ViveController extends WebVRController {
  97261. /**
  97262. * Base Url for the controller model.
  97263. */
  97264. static MODEL_BASE_URL: string;
  97265. /**
  97266. * File name for the controller model.
  97267. */
  97268. static MODEL_FILENAME: string;
  97269. /**
  97270. * Creates a new ViveController from a gamepad
  97271. * @param vrGamepad the gamepad that the controller should be created from
  97272. */
  97273. constructor(vrGamepad: any);
  97274. /**
  97275. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97276. * @param scene scene in which to add meshes
  97277. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97278. */
  97279. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97280. /**
  97281. * Fired when the left button on this controller is modified
  97282. */
  97283. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97284. /**
  97285. * Fired when the right button on this controller is modified
  97286. */
  97287. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97288. /**
  97289. * Fired when the menu button on this controller is modified
  97290. */
  97291. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97292. /**
  97293. * Called once for each button that changed state since the last frame
  97294. * Vive mapping:
  97295. * 0: touchpad
  97296. * 1: trigger
  97297. * 2: left AND right buttons
  97298. * 3: menu button
  97299. * @param buttonIdx Which button index changed
  97300. * @param state New state of the button
  97301. * @param changes Which properties on the state changed since last frame
  97302. */
  97303. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97304. }
  97305. }
  97306. declare module BABYLON {
  97307. /**
  97308. * Defines the WindowsMotionController object that the state of the windows motion controller
  97309. */
  97310. export class WindowsMotionController extends WebVRController {
  97311. /**
  97312. * The base url used to load the left and right controller models
  97313. */
  97314. static MODEL_BASE_URL: string;
  97315. /**
  97316. * The name of the left controller model file
  97317. */
  97318. static MODEL_LEFT_FILENAME: string;
  97319. /**
  97320. * The name of the right controller model file
  97321. */
  97322. static MODEL_RIGHT_FILENAME: string;
  97323. /**
  97324. * The controller name prefix for this controller type
  97325. */
  97326. static readonly GAMEPAD_ID_PREFIX: string;
  97327. /**
  97328. * The controller id pattern for this controller type
  97329. */
  97330. private static readonly GAMEPAD_ID_PATTERN;
  97331. private _loadedMeshInfo;
  97332. private readonly _mapping;
  97333. /**
  97334. * Fired when the trackpad on this controller is clicked
  97335. */
  97336. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  97337. /**
  97338. * Fired when the trackpad on this controller is modified
  97339. */
  97340. onTrackpadValuesChangedObservable: Observable<StickValues>;
  97341. /**
  97342. * The current x and y values of this controller's trackpad
  97343. */
  97344. trackpad: StickValues;
  97345. /**
  97346. * Creates a new WindowsMotionController from a gamepad
  97347. * @param vrGamepad the gamepad that the controller should be created from
  97348. */
  97349. constructor(vrGamepad: any);
  97350. /**
  97351. * Fired when the trigger on this controller is modified
  97352. */
  97353. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97354. /**
  97355. * Fired when the menu button on this controller is modified
  97356. */
  97357. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97358. /**
  97359. * Fired when the grip button on this controller is modified
  97360. */
  97361. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97362. /**
  97363. * Fired when the thumbstick button on this controller is modified
  97364. */
  97365. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97366. /**
  97367. * Fired when the touchpad button on this controller is modified
  97368. */
  97369. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97370. /**
  97371. * Fired when the touchpad values on this controller are modified
  97372. */
  97373. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  97374. private _updateTrackpad;
  97375. /**
  97376. * Called once per frame by the engine.
  97377. */
  97378. update(): void;
  97379. /**
  97380. * Called once for each button that changed state since the last frame
  97381. * @param buttonIdx Which button index changed
  97382. * @param state New state of the button
  97383. * @param changes Which properties on the state changed since last frame
  97384. */
  97385. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97386. /**
  97387. * Moves the buttons on the controller mesh based on their current state
  97388. * @param buttonName the name of the button to move
  97389. * @param buttonValue the value of the button which determines the buttons new position
  97390. */
  97391. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  97392. /**
  97393. * Moves the axis on the controller mesh based on its current state
  97394. * @param axis the index of the axis
  97395. * @param axisValue the value of the axis which determines the meshes new position
  97396. * @hidden
  97397. */
  97398. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  97399. /**
  97400. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97401. * @param scene scene in which to add meshes
  97402. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97403. */
  97404. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  97405. /**
  97406. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  97407. * can be transformed by button presses and axes values, based on this._mapping.
  97408. *
  97409. * @param scene scene in which the meshes exist
  97410. * @param meshes list of meshes that make up the controller model to process
  97411. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  97412. */
  97413. private processModel;
  97414. private createMeshInfo;
  97415. /**
  97416. * Gets the ray of the controller in the direction the controller is pointing
  97417. * @param length the length the resulting ray should be
  97418. * @returns a ray in the direction the controller is pointing
  97419. */
  97420. getForwardRay(length?: number): Ray;
  97421. /**
  97422. * Disposes of the controller
  97423. */
  97424. dispose(): void;
  97425. }
  97426. }
  97427. declare module BABYLON {
  97428. /**
  97429. * Single axis scale gizmo
  97430. */
  97431. export class AxisScaleGizmo extends Gizmo {
  97432. private _coloredMaterial;
  97433. /**
  97434. * Drag behavior responsible for the gizmos dragging interactions
  97435. */
  97436. dragBehavior: PointerDragBehavior;
  97437. private _pointerObserver;
  97438. /**
  97439. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97440. */
  97441. snapDistance: number;
  97442. /**
  97443. * Event that fires each time the gizmo snaps to a new location.
  97444. * * snapDistance is the the change in distance
  97445. */
  97446. onSnapObservable: Observable<{
  97447. snapDistance: number;
  97448. }>;
  97449. /**
  97450. * If the scaling operation should be done on all axis (default: false)
  97451. */
  97452. uniformScaling: boolean;
  97453. /**
  97454. * Creates an AxisScaleGizmo
  97455. * @param gizmoLayer The utility layer the gizmo will be added to
  97456. * @param dragAxis The axis which the gizmo will be able to scale on
  97457. * @param color The color of the gizmo
  97458. */
  97459. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97460. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97461. /**
  97462. * Disposes of the gizmo
  97463. */
  97464. dispose(): void;
  97465. /**
  97466. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  97467. * @param mesh The mesh to replace the default mesh of the gizmo
  97468. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  97469. */
  97470. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  97471. }
  97472. }
  97473. declare module BABYLON {
  97474. /**
  97475. * Bounding box gizmo
  97476. */
  97477. export class BoundingBoxGizmo extends Gizmo {
  97478. private _lineBoundingBox;
  97479. private _rotateSpheresParent;
  97480. private _scaleBoxesParent;
  97481. private _boundingDimensions;
  97482. private _renderObserver;
  97483. private _pointerObserver;
  97484. private _scaleDragSpeed;
  97485. private _tmpQuaternion;
  97486. private _tmpVector;
  97487. private _tmpRotationMatrix;
  97488. /**
  97489. * 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)
  97490. */
  97491. ignoreChildren: boolean;
  97492. /**
  97493. * 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)
  97494. */
  97495. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  97496. /**
  97497. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  97498. */
  97499. rotationSphereSize: number;
  97500. /**
  97501. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  97502. */
  97503. scaleBoxSize: number;
  97504. /**
  97505. * 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)
  97506. */
  97507. fixedDragMeshScreenSize: boolean;
  97508. /**
  97509. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  97510. */
  97511. fixedDragMeshScreenSizeDistanceFactor: number;
  97512. /**
  97513. * Fired when a rotation sphere or scale box is dragged
  97514. */
  97515. onDragStartObservable: Observable<{}>;
  97516. /**
  97517. * Fired when a scale box is dragged
  97518. */
  97519. onScaleBoxDragObservable: Observable<{}>;
  97520. /**
  97521. * Fired when a scale box drag is ended
  97522. */
  97523. onScaleBoxDragEndObservable: Observable<{}>;
  97524. /**
  97525. * Fired when a rotation sphere is dragged
  97526. */
  97527. onRotationSphereDragObservable: Observable<{}>;
  97528. /**
  97529. * Fired when a rotation sphere drag is ended
  97530. */
  97531. onRotationSphereDragEndObservable: Observable<{}>;
  97532. /**
  97533. * 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)
  97534. */
  97535. scalePivot: Nullable<Vector3>;
  97536. private _anchorMesh;
  97537. private _existingMeshScale;
  97538. private _dragMesh;
  97539. private pointerDragBehavior;
  97540. /**
  97541. * Creates an BoundingBoxGizmo
  97542. * @param gizmoLayer The utility layer the gizmo will be added to
  97543. * @param color The color of the gizmo
  97544. */
  97545. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97546. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97547. private _selectNode;
  97548. /**
  97549. * Updates the bounding box information for the Gizmo
  97550. */
  97551. updateBoundingBox(): void;
  97552. private _updateRotationSpheres;
  97553. private _updateScaleBoxes;
  97554. /**
  97555. * Enables rotation on the specified axis and disables rotation on the others
  97556. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  97557. */
  97558. setEnabledRotationAxis(axis: string): void;
  97559. /**
  97560. * Enables/disables scaling
  97561. * @param enable if scaling should be enabled
  97562. */
  97563. setEnabledScaling(enable: boolean): void;
  97564. private _updateDummy;
  97565. /**
  97566. * Enables a pointer drag behavior on the bounding box of the gizmo
  97567. */
  97568. enableDragBehavior(): void;
  97569. /**
  97570. * Disposes of the gizmo
  97571. */
  97572. dispose(): void;
  97573. /**
  97574. * 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)
  97575. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  97576. * @returns the bounding box mesh with the passed in mesh as a child
  97577. */
  97578. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  97579. /**
  97580. * CustomMeshes are not supported by this gizmo
  97581. * @param mesh The mesh to replace the default mesh of the gizmo
  97582. */
  97583. setCustomMesh(mesh: Mesh): void;
  97584. }
  97585. }
  97586. declare module BABYLON {
  97587. /**
  97588. * Single plane rotation gizmo
  97589. */
  97590. export class PlaneRotationGizmo extends Gizmo {
  97591. /**
  97592. * Drag behavior responsible for the gizmos dragging interactions
  97593. */
  97594. dragBehavior: PointerDragBehavior;
  97595. private _pointerObserver;
  97596. /**
  97597. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  97598. */
  97599. snapDistance: number;
  97600. /**
  97601. * Event that fires each time the gizmo snaps to a new location.
  97602. * * snapDistance is the the change in distance
  97603. */
  97604. onSnapObservable: Observable<{
  97605. snapDistance: number;
  97606. }>;
  97607. /**
  97608. * Creates a PlaneRotationGizmo
  97609. * @param gizmoLayer The utility layer the gizmo will be added to
  97610. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  97611. * @param color The color of the gizmo
  97612. * @param tessellation Amount of tessellation to be used when creating rotation circles
  97613. */
  97614. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  97615. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97616. /**
  97617. * Disposes of the gizmo
  97618. */
  97619. dispose(): void;
  97620. }
  97621. }
  97622. declare module BABYLON {
  97623. /**
  97624. * Gizmo that enables rotating a mesh along 3 axis
  97625. */
  97626. export class RotationGizmo extends Gizmo {
  97627. /**
  97628. * Internal gizmo used for interactions on the x axis
  97629. */
  97630. xGizmo: PlaneRotationGizmo;
  97631. /**
  97632. * Internal gizmo used for interactions on the y axis
  97633. */
  97634. yGizmo: PlaneRotationGizmo;
  97635. /**
  97636. * Internal gizmo used for interactions on the z axis
  97637. */
  97638. zGizmo: PlaneRotationGizmo;
  97639. /** Fires an event when any of it's sub gizmos are dragged */
  97640. onDragStartObservable: Observable<{}>;
  97641. /** Fires an event when any of it's sub gizmos are released from dragging */
  97642. onDragEndObservable: Observable<{}>;
  97643. attachedMesh: Nullable<AbstractMesh>;
  97644. /**
  97645. * Creates a RotationGizmo
  97646. * @param gizmoLayer The utility layer the gizmo will be added to
  97647. * @param tessellation Amount of tessellation to be used when creating rotation circles
  97648. */
  97649. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  97650. updateGizmoRotationToMatchAttachedMesh: boolean;
  97651. /**
  97652. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97653. */
  97654. snapDistance: number;
  97655. /**
  97656. * Ratio for the scale of the gizmo (Default: 1)
  97657. */
  97658. scaleRatio: number;
  97659. /**
  97660. * Disposes of the gizmo
  97661. */
  97662. dispose(): void;
  97663. /**
  97664. * CustomMeshes are not supported by this gizmo
  97665. * @param mesh The mesh to replace the default mesh of the gizmo
  97666. */
  97667. setCustomMesh(mesh: Mesh): void;
  97668. }
  97669. }
  97670. declare module BABYLON {
  97671. /**
  97672. * Gizmo that enables dragging a mesh along 3 axis
  97673. */
  97674. export class PositionGizmo extends Gizmo {
  97675. /**
  97676. * Internal gizmo used for interactions on the x axis
  97677. */
  97678. xGizmo: AxisDragGizmo;
  97679. /**
  97680. * Internal gizmo used for interactions on the y axis
  97681. */
  97682. yGizmo: AxisDragGizmo;
  97683. /**
  97684. * Internal gizmo used for interactions on the z axis
  97685. */
  97686. zGizmo: AxisDragGizmo;
  97687. /** Fires an event when any of it's sub gizmos are dragged */
  97688. onDragStartObservable: Observable<{}>;
  97689. /** Fires an event when any of it's sub gizmos are released from dragging */
  97690. onDragEndObservable: Observable<{}>;
  97691. attachedMesh: Nullable<AbstractMesh>;
  97692. /**
  97693. * Creates a PositionGizmo
  97694. * @param gizmoLayer The utility layer the gizmo will be added to
  97695. */
  97696. constructor(gizmoLayer?: UtilityLayerRenderer);
  97697. updateGizmoRotationToMatchAttachedMesh: boolean;
  97698. /**
  97699. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97700. */
  97701. snapDistance: number;
  97702. /**
  97703. * Ratio for the scale of the gizmo (Default: 1)
  97704. */
  97705. scaleRatio: number;
  97706. /**
  97707. * Disposes of the gizmo
  97708. */
  97709. dispose(): void;
  97710. /**
  97711. * CustomMeshes are not supported by this gizmo
  97712. * @param mesh The mesh to replace the default mesh of the gizmo
  97713. */
  97714. setCustomMesh(mesh: Mesh): void;
  97715. }
  97716. }
  97717. declare module BABYLON {
  97718. /**
  97719. * Class containing static functions to help procedurally build meshes
  97720. */
  97721. export class PolyhedronBuilder {
  97722. /**
  97723. * Creates a polyhedron mesh
  97724. * * 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
  97725. * * The parameter `size` (positive float, default 1) sets the polygon size
  97726. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  97727. * * 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`
  97728. * * 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
  97729. * * 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)`)
  97730. * * 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
  97731. * * 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
  97732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97735. * @param name defines the name of the mesh
  97736. * @param options defines the options used to create the mesh
  97737. * @param scene defines the hosting scene
  97738. * @returns the polyhedron mesh
  97739. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  97740. */
  97741. static CreatePolyhedron(name: string, options: {
  97742. type?: number;
  97743. size?: number;
  97744. sizeX?: number;
  97745. sizeY?: number;
  97746. sizeZ?: number;
  97747. custom?: any;
  97748. faceUV?: Vector4[];
  97749. faceColors?: Color4[];
  97750. flat?: boolean;
  97751. updatable?: boolean;
  97752. sideOrientation?: number;
  97753. frontUVs?: Vector4;
  97754. backUVs?: Vector4;
  97755. }, scene: Scene): Mesh;
  97756. }
  97757. }
  97758. declare module BABYLON {
  97759. /**
  97760. * Gizmo that enables scaling a mesh along 3 axis
  97761. */
  97762. export class ScaleGizmo extends Gizmo {
  97763. /**
  97764. * Internal gizmo used for interactions on the x axis
  97765. */
  97766. xGizmo: AxisScaleGizmo;
  97767. /**
  97768. * Internal gizmo used for interactions on the y axis
  97769. */
  97770. yGizmo: AxisScaleGizmo;
  97771. /**
  97772. * Internal gizmo used for interactions on the z axis
  97773. */
  97774. zGizmo: AxisScaleGizmo;
  97775. /**
  97776. * Internal gizmo used to scale all axis equally
  97777. */
  97778. uniformScaleGizmo: AxisScaleGizmo;
  97779. /** Fires an event when any of it's sub gizmos are dragged */
  97780. onDragStartObservable: Observable<{}>;
  97781. /** Fires an event when any of it's sub gizmos are released from dragging */
  97782. onDragEndObservable: Observable<{}>;
  97783. attachedMesh: Nullable<AbstractMesh>;
  97784. /**
  97785. * Creates a ScaleGizmo
  97786. * @param gizmoLayer The utility layer the gizmo will be added to
  97787. */
  97788. constructor(gizmoLayer?: UtilityLayerRenderer);
  97789. updateGizmoRotationToMatchAttachedMesh: boolean;
  97790. /**
  97791. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97792. */
  97793. snapDistance: number;
  97794. /**
  97795. * Ratio for the scale of the gizmo (Default: 1)
  97796. */
  97797. scaleRatio: number;
  97798. /**
  97799. * Disposes of the gizmo
  97800. */
  97801. dispose(): void;
  97802. }
  97803. }
  97804. declare module BABYLON {
  97805. /**
  97806. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  97807. */
  97808. export class GizmoManager implements IDisposable {
  97809. private scene;
  97810. /**
  97811. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  97812. */
  97813. gizmos: {
  97814. positionGizmo: Nullable<PositionGizmo>;
  97815. rotationGizmo: Nullable<RotationGizmo>;
  97816. scaleGizmo: Nullable<ScaleGizmo>;
  97817. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  97818. };
  97819. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  97820. clearGizmoOnEmptyPointerEvent: boolean;
  97821. /** Fires an event when the manager is attached to a mesh */
  97822. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  97823. private _gizmosEnabled;
  97824. private _pointerObserver;
  97825. private _attachedMesh;
  97826. private _boundingBoxColor;
  97827. private _defaultUtilityLayer;
  97828. private _defaultKeepDepthUtilityLayer;
  97829. /**
  97830. * When bounding box gizmo is enabled, this can be used to track drag/end events
  97831. */
  97832. boundingBoxDragBehavior: SixDofDragBehavior;
  97833. /**
  97834. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  97835. */
  97836. attachableMeshes: Nullable<Array<AbstractMesh>>;
  97837. /**
  97838. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  97839. */
  97840. usePointerToAttachGizmos: boolean;
  97841. /**
  97842. * Instatiates a gizmo manager
  97843. * @param scene the scene to overlay the gizmos on top of
  97844. */
  97845. constructor(scene: Scene);
  97846. /**
  97847. * Attaches a set of gizmos to the specified mesh
  97848. * @param mesh The mesh the gizmo's should be attached to
  97849. */
  97850. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  97851. /**
  97852. * If the position gizmo is enabled
  97853. */
  97854. positionGizmoEnabled: boolean;
  97855. /**
  97856. * If the rotation gizmo is enabled
  97857. */
  97858. rotationGizmoEnabled: boolean;
  97859. /**
  97860. * If the scale gizmo is enabled
  97861. */
  97862. scaleGizmoEnabled: boolean;
  97863. /**
  97864. * If the boundingBox gizmo is enabled
  97865. */
  97866. boundingBoxGizmoEnabled: boolean;
  97867. /**
  97868. * Disposes of the gizmo manager
  97869. */
  97870. dispose(): void;
  97871. }
  97872. }
  97873. declare module BABYLON {
  97874. /** @hidden */
  97875. export var backgroundFragmentDeclaration: {
  97876. name: string;
  97877. shader: string;
  97878. };
  97879. }
  97880. declare module BABYLON {
  97881. /** @hidden */
  97882. export var backgroundUboDeclaration: {
  97883. name: string;
  97884. shader: string;
  97885. };
  97886. }
  97887. declare module BABYLON {
  97888. /** @hidden */
  97889. export var backgroundPixelShader: {
  97890. name: string;
  97891. shader: string;
  97892. };
  97893. }
  97894. declare module BABYLON {
  97895. /** @hidden */
  97896. export var backgroundVertexDeclaration: {
  97897. name: string;
  97898. shader: string;
  97899. };
  97900. }
  97901. declare module BABYLON {
  97902. /** @hidden */
  97903. export var backgroundVertexShader: {
  97904. name: string;
  97905. shader: string;
  97906. };
  97907. }
  97908. declare module BABYLON {
  97909. /**
  97910. * Background material used to create an efficient environement around your scene.
  97911. */
  97912. export class BackgroundMaterial extends PushMaterial {
  97913. /**
  97914. * Standard reflectance value at parallel view angle.
  97915. */
  97916. static StandardReflectance0: number;
  97917. /**
  97918. * Standard reflectance value at grazing angle.
  97919. */
  97920. static StandardReflectance90: number;
  97921. protected _primaryColor: Color3;
  97922. /**
  97923. * Key light Color (multiply against the environement texture)
  97924. */
  97925. primaryColor: Color3;
  97926. protected __perceptualColor: Nullable<Color3>;
  97927. /**
  97928. * Experimental Internal Use Only.
  97929. *
  97930. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  97931. * This acts as a helper to set the primary color to a more "human friendly" value.
  97932. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  97933. * output color as close as possible from the chosen value.
  97934. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  97935. * part of lighting setup.)
  97936. */
  97937. _perceptualColor: Nullable<Color3>;
  97938. protected _primaryColorShadowLevel: float;
  97939. /**
  97940. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  97941. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  97942. */
  97943. primaryColorShadowLevel: float;
  97944. protected _primaryColorHighlightLevel: float;
  97945. /**
  97946. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  97947. * The primary color is used at the level chosen to define what the white area would look.
  97948. */
  97949. primaryColorHighlightLevel: float;
  97950. protected _reflectionTexture: Nullable<BaseTexture>;
  97951. /**
  97952. * Reflection Texture used in the material.
  97953. * Should be author in a specific way for the best result (refer to the documentation).
  97954. */
  97955. reflectionTexture: Nullable<BaseTexture>;
  97956. protected _reflectionBlur: float;
  97957. /**
  97958. * Reflection Texture level of blur.
  97959. *
  97960. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  97961. * texture twice.
  97962. */
  97963. reflectionBlur: float;
  97964. protected _diffuseTexture: Nullable<BaseTexture>;
  97965. /**
  97966. * Diffuse Texture used in the material.
  97967. * Should be author in a specific way for the best result (refer to the documentation).
  97968. */
  97969. diffuseTexture: Nullable<BaseTexture>;
  97970. protected _shadowLights: Nullable<IShadowLight[]>;
  97971. /**
  97972. * Specify the list of lights casting shadow on the material.
  97973. * All scene shadow lights will be included if null.
  97974. */
  97975. shadowLights: Nullable<IShadowLight[]>;
  97976. protected _shadowLevel: float;
  97977. /**
  97978. * Helps adjusting the shadow to a softer level if required.
  97979. * 0 means black shadows and 1 means no shadows.
  97980. */
  97981. shadowLevel: float;
  97982. protected _sceneCenter: Vector3;
  97983. /**
  97984. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  97985. * It is usually zero but might be interesting to modify according to your setup.
  97986. */
  97987. sceneCenter: Vector3;
  97988. protected _opacityFresnel: boolean;
  97989. /**
  97990. * This helps specifying that the material is falling off to the sky box at grazing angle.
  97991. * This helps ensuring a nice transition when the camera goes under the ground.
  97992. */
  97993. opacityFresnel: boolean;
  97994. protected _reflectionFresnel: boolean;
  97995. /**
  97996. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  97997. * This helps adding a mirror texture on the ground.
  97998. */
  97999. reflectionFresnel: boolean;
  98000. protected _reflectionFalloffDistance: number;
  98001. /**
  98002. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  98003. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  98004. */
  98005. reflectionFalloffDistance: number;
  98006. protected _reflectionAmount: number;
  98007. /**
  98008. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  98009. */
  98010. reflectionAmount: number;
  98011. protected _reflectionReflectance0: number;
  98012. /**
  98013. * This specifies the weight of the reflection at grazing angle.
  98014. */
  98015. reflectionReflectance0: number;
  98016. protected _reflectionReflectance90: number;
  98017. /**
  98018. * This specifies the weight of the reflection at a perpendicular point of view.
  98019. */
  98020. reflectionReflectance90: number;
  98021. /**
  98022. * Sets the reflection reflectance fresnel values according to the default standard
  98023. * empirically know to work well :-)
  98024. */
  98025. reflectionStandardFresnelWeight: number;
  98026. protected _useRGBColor: boolean;
  98027. /**
  98028. * Helps to directly use the maps channels instead of their level.
  98029. */
  98030. useRGBColor: boolean;
  98031. protected _enableNoise: boolean;
  98032. /**
  98033. * This helps reducing the banding effect that could occur on the background.
  98034. */
  98035. enableNoise: boolean;
  98036. /**
  98037. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  98038. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  98039. * Recommended to be keep at 1.0 except for special cases.
  98040. */
  98041. fovMultiplier: number;
  98042. private _fovMultiplier;
  98043. /**
  98044. * Enable the FOV adjustment feature controlled by fovMultiplier.
  98045. */
  98046. useEquirectangularFOV: boolean;
  98047. private _maxSimultaneousLights;
  98048. /**
  98049. * Number of Simultaneous lights allowed on the material.
  98050. */
  98051. maxSimultaneousLights: int;
  98052. /**
  98053. * Default configuration related to image processing available in the Background Material.
  98054. */
  98055. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98056. /**
  98057. * Keep track of the image processing observer to allow dispose and replace.
  98058. */
  98059. private _imageProcessingObserver;
  98060. /**
  98061. * Attaches a new image processing configuration to the PBR Material.
  98062. * @param configuration (if null the scene configuration will be use)
  98063. */
  98064. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98065. /**
  98066. * Gets the image processing configuration used either in this material.
  98067. */
  98068. /**
  98069. * Sets the Default image processing configuration used either in the this material.
  98070. *
  98071. * If sets to null, the scene one is in use.
  98072. */
  98073. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  98074. /**
  98075. * Gets wether the color curves effect is enabled.
  98076. */
  98077. /**
  98078. * Sets wether the color curves effect is enabled.
  98079. */
  98080. cameraColorCurvesEnabled: boolean;
  98081. /**
  98082. * Gets wether the color grading effect is enabled.
  98083. */
  98084. /**
  98085. * Gets wether the color grading effect is enabled.
  98086. */
  98087. cameraColorGradingEnabled: boolean;
  98088. /**
  98089. * Gets wether tonemapping is enabled or not.
  98090. */
  98091. /**
  98092. * Sets wether tonemapping is enabled or not
  98093. */
  98094. cameraToneMappingEnabled: boolean;
  98095. /**
  98096. * The camera exposure used on this material.
  98097. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98098. * This corresponds to a photographic exposure.
  98099. */
  98100. /**
  98101. * The camera exposure used on this material.
  98102. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98103. * This corresponds to a photographic exposure.
  98104. */
  98105. cameraExposure: float;
  98106. /**
  98107. * Gets The camera contrast used on this material.
  98108. */
  98109. /**
  98110. * Sets The camera contrast used on this material.
  98111. */
  98112. cameraContrast: float;
  98113. /**
  98114. * Gets the Color Grading 2D Lookup Texture.
  98115. */
  98116. /**
  98117. * Sets the Color Grading 2D Lookup Texture.
  98118. */
  98119. cameraColorGradingTexture: Nullable<BaseTexture>;
  98120. /**
  98121. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98122. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98123. * 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;
  98124. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98125. */
  98126. /**
  98127. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98128. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98129. * 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;
  98130. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98131. */
  98132. cameraColorCurves: Nullable<ColorCurves>;
  98133. /**
  98134. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  98135. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  98136. */
  98137. switchToBGR: boolean;
  98138. private _renderTargets;
  98139. private _reflectionControls;
  98140. private _white;
  98141. private _primaryShadowColor;
  98142. private _primaryHighlightColor;
  98143. /**
  98144. * Instantiates a Background Material in the given scene
  98145. * @param name The friendly name of the material
  98146. * @param scene The scene to add the material to
  98147. */
  98148. constructor(name: string, scene: Scene);
  98149. /**
  98150. * Gets a boolean indicating that current material needs to register RTT
  98151. */
  98152. readonly hasRenderTargetTextures: boolean;
  98153. /**
  98154. * The entire material has been created in order to prevent overdraw.
  98155. * @returns false
  98156. */
  98157. needAlphaTesting(): boolean;
  98158. /**
  98159. * The entire material has been created in order to prevent overdraw.
  98160. * @returns true if blending is enable
  98161. */
  98162. needAlphaBlending(): boolean;
  98163. /**
  98164. * Checks wether the material is ready to be rendered for a given mesh.
  98165. * @param mesh The mesh to render
  98166. * @param subMesh The submesh to check against
  98167. * @param useInstances Specify wether or not the material is used with instances
  98168. * @returns true if all the dependencies are ready (Textures, Effects...)
  98169. */
  98170. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98171. /**
  98172. * Compute the primary color according to the chosen perceptual color.
  98173. */
  98174. private _computePrimaryColorFromPerceptualColor;
  98175. /**
  98176. * Compute the highlights and shadow colors according to their chosen levels.
  98177. */
  98178. private _computePrimaryColors;
  98179. /**
  98180. * Build the uniform buffer used in the material.
  98181. */
  98182. buildUniformLayout(): void;
  98183. /**
  98184. * Unbind the material.
  98185. */
  98186. unbind(): void;
  98187. /**
  98188. * Bind only the world matrix to the material.
  98189. * @param world The world matrix to bind.
  98190. */
  98191. bindOnlyWorldMatrix(world: Matrix): void;
  98192. /**
  98193. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  98194. * @param world The world matrix to bind.
  98195. * @param subMesh The submesh to bind for.
  98196. */
  98197. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98198. /**
  98199. * Dispose the material.
  98200. * @param forceDisposeEffect Force disposal of the associated effect.
  98201. * @param forceDisposeTextures Force disposal of the associated textures.
  98202. */
  98203. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98204. /**
  98205. * Clones the material.
  98206. * @param name The cloned name.
  98207. * @returns The cloned material.
  98208. */
  98209. clone(name: string): BackgroundMaterial;
  98210. /**
  98211. * Serializes the current material to its JSON representation.
  98212. * @returns The JSON representation.
  98213. */
  98214. serialize(): any;
  98215. /**
  98216. * Gets the class name of the material
  98217. * @returns "BackgroundMaterial"
  98218. */
  98219. getClassName(): string;
  98220. /**
  98221. * Parse a JSON input to create back a background material.
  98222. * @param source The JSON data to parse
  98223. * @param scene The scene to create the parsed material in
  98224. * @param rootUrl The root url of the assets the material depends upon
  98225. * @returns the instantiated BackgroundMaterial.
  98226. */
  98227. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  98228. }
  98229. }
  98230. declare module BABYLON {
  98231. /**
  98232. * Represents the different options available during the creation of
  98233. * a Environment helper.
  98234. *
  98235. * This can control the default ground, skybox and image processing setup of your scene.
  98236. */
  98237. export interface IEnvironmentHelperOptions {
  98238. /**
  98239. * Specifies wether or not to create a ground.
  98240. * True by default.
  98241. */
  98242. createGround: boolean;
  98243. /**
  98244. * Specifies the ground size.
  98245. * 15 by default.
  98246. */
  98247. groundSize: number;
  98248. /**
  98249. * The texture used on the ground for the main color.
  98250. * Comes from the BabylonJS CDN by default.
  98251. *
  98252. * Remarks: Can be either a texture or a url.
  98253. */
  98254. groundTexture: string | BaseTexture;
  98255. /**
  98256. * The color mixed in the ground texture by default.
  98257. * BabylonJS clearColor by default.
  98258. */
  98259. groundColor: Color3;
  98260. /**
  98261. * Specifies the ground opacity.
  98262. * 1 by default.
  98263. */
  98264. groundOpacity: number;
  98265. /**
  98266. * Enables the ground to receive shadows.
  98267. * True by default.
  98268. */
  98269. enableGroundShadow: boolean;
  98270. /**
  98271. * Helps preventing the shadow to be fully black on the ground.
  98272. * 0.5 by default.
  98273. */
  98274. groundShadowLevel: number;
  98275. /**
  98276. * Creates a mirror texture attach to the ground.
  98277. * false by default.
  98278. */
  98279. enableGroundMirror: boolean;
  98280. /**
  98281. * Specifies the ground mirror size ratio.
  98282. * 0.3 by default as the default kernel is 64.
  98283. */
  98284. groundMirrorSizeRatio: number;
  98285. /**
  98286. * Specifies the ground mirror blur kernel size.
  98287. * 64 by default.
  98288. */
  98289. groundMirrorBlurKernel: number;
  98290. /**
  98291. * Specifies the ground mirror visibility amount.
  98292. * 1 by default
  98293. */
  98294. groundMirrorAmount: number;
  98295. /**
  98296. * Specifies the ground mirror reflectance weight.
  98297. * This uses the standard weight of the background material to setup the fresnel effect
  98298. * of the mirror.
  98299. * 1 by default.
  98300. */
  98301. groundMirrorFresnelWeight: number;
  98302. /**
  98303. * Specifies the ground mirror Falloff distance.
  98304. * This can helps reducing the size of the reflection.
  98305. * 0 by Default.
  98306. */
  98307. groundMirrorFallOffDistance: number;
  98308. /**
  98309. * Specifies the ground mirror texture type.
  98310. * Unsigned Int by Default.
  98311. */
  98312. groundMirrorTextureType: number;
  98313. /**
  98314. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  98315. * the shown objects.
  98316. */
  98317. groundYBias: number;
  98318. /**
  98319. * Specifies wether or not to create a skybox.
  98320. * True by default.
  98321. */
  98322. createSkybox: boolean;
  98323. /**
  98324. * Specifies the skybox size.
  98325. * 20 by default.
  98326. */
  98327. skyboxSize: number;
  98328. /**
  98329. * The texture used on the skybox for the main color.
  98330. * Comes from the BabylonJS CDN by default.
  98331. *
  98332. * Remarks: Can be either a texture or a url.
  98333. */
  98334. skyboxTexture: string | BaseTexture;
  98335. /**
  98336. * The color mixed in the skybox texture by default.
  98337. * BabylonJS clearColor by default.
  98338. */
  98339. skyboxColor: Color3;
  98340. /**
  98341. * The background rotation around the Y axis of the scene.
  98342. * This helps aligning the key lights of your scene with the background.
  98343. * 0 by default.
  98344. */
  98345. backgroundYRotation: number;
  98346. /**
  98347. * Compute automatically the size of the elements to best fit with the scene.
  98348. */
  98349. sizeAuto: boolean;
  98350. /**
  98351. * Default position of the rootMesh if autoSize is not true.
  98352. */
  98353. rootPosition: Vector3;
  98354. /**
  98355. * Sets up the image processing in the scene.
  98356. * true by default.
  98357. */
  98358. setupImageProcessing: boolean;
  98359. /**
  98360. * The texture used as your environment texture in the scene.
  98361. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  98362. *
  98363. * Remarks: Can be either a texture or a url.
  98364. */
  98365. environmentTexture: string | BaseTexture;
  98366. /**
  98367. * The value of the exposure to apply to the scene.
  98368. * 0.6 by default if setupImageProcessing is true.
  98369. */
  98370. cameraExposure: number;
  98371. /**
  98372. * The value of the contrast to apply to the scene.
  98373. * 1.6 by default if setupImageProcessing is true.
  98374. */
  98375. cameraContrast: number;
  98376. /**
  98377. * Specifies wether or not tonemapping should be enabled in the scene.
  98378. * true by default if setupImageProcessing is true.
  98379. */
  98380. toneMappingEnabled: boolean;
  98381. }
  98382. /**
  98383. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  98384. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  98385. * It also helps with the default setup of your imageProcessing configuration.
  98386. */
  98387. export class EnvironmentHelper {
  98388. /**
  98389. * Default ground texture URL.
  98390. */
  98391. private static _groundTextureCDNUrl;
  98392. /**
  98393. * Default skybox texture URL.
  98394. */
  98395. private static _skyboxTextureCDNUrl;
  98396. /**
  98397. * Default environment texture URL.
  98398. */
  98399. private static _environmentTextureCDNUrl;
  98400. /**
  98401. * Creates the default options for the helper.
  98402. */
  98403. private static _getDefaultOptions;
  98404. private _rootMesh;
  98405. /**
  98406. * Gets the root mesh created by the helper.
  98407. */
  98408. readonly rootMesh: Mesh;
  98409. private _skybox;
  98410. /**
  98411. * Gets the skybox created by the helper.
  98412. */
  98413. readonly skybox: Nullable<Mesh>;
  98414. private _skyboxTexture;
  98415. /**
  98416. * Gets the skybox texture created by the helper.
  98417. */
  98418. readonly skyboxTexture: Nullable<BaseTexture>;
  98419. private _skyboxMaterial;
  98420. /**
  98421. * Gets the skybox material created by the helper.
  98422. */
  98423. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  98424. private _ground;
  98425. /**
  98426. * Gets the ground mesh created by the helper.
  98427. */
  98428. readonly ground: Nullable<Mesh>;
  98429. private _groundTexture;
  98430. /**
  98431. * Gets the ground texture created by the helper.
  98432. */
  98433. readonly groundTexture: Nullable<BaseTexture>;
  98434. private _groundMirror;
  98435. /**
  98436. * Gets the ground mirror created by the helper.
  98437. */
  98438. readonly groundMirror: Nullable<MirrorTexture>;
  98439. /**
  98440. * Gets the ground mirror render list to helps pushing the meshes
  98441. * you wish in the ground reflection.
  98442. */
  98443. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  98444. private _groundMaterial;
  98445. /**
  98446. * Gets the ground material created by the helper.
  98447. */
  98448. readonly groundMaterial: Nullable<BackgroundMaterial>;
  98449. /**
  98450. * Stores the creation options.
  98451. */
  98452. private readonly _scene;
  98453. private _options;
  98454. /**
  98455. * This observable will be notified with any error during the creation of the environment,
  98456. * mainly texture creation errors.
  98457. */
  98458. onErrorObservable: Observable<{
  98459. message?: string;
  98460. exception?: any;
  98461. }>;
  98462. /**
  98463. * constructor
  98464. * @param options Defines the options we want to customize the helper
  98465. * @param scene The scene to add the material to
  98466. */
  98467. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  98468. /**
  98469. * Updates the background according to the new options
  98470. * @param options
  98471. */
  98472. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  98473. /**
  98474. * Sets the primary color of all the available elements.
  98475. * @param color the main color to affect to the ground and the background
  98476. */
  98477. setMainColor(color: Color3): void;
  98478. /**
  98479. * Setup the image processing according to the specified options.
  98480. */
  98481. private _setupImageProcessing;
  98482. /**
  98483. * Setup the environment texture according to the specified options.
  98484. */
  98485. private _setupEnvironmentTexture;
  98486. /**
  98487. * Setup the background according to the specified options.
  98488. */
  98489. private _setupBackground;
  98490. /**
  98491. * Get the scene sizes according to the setup.
  98492. */
  98493. private _getSceneSize;
  98494. /**
  98495. * Setup the ground according to the specified options.
  98496. */
  98497. private _setupGround;
  98498. /**
  98499. * Setup the ground material according to the specified options.
  98500. */
  98501. private _setupGroundMaterial;
  98502. /**
  98503. * Setup the ground diffuse texture according to the specified options.
  98504. */
  98505. private _setupGroundDiffuseTexture;
  98506. /**
  98507. * Setup the ground mirror texture according to the specified options.
  98508. */
  98509. private _setupGroundMirrorTexture;
  98510. /**
  98511. * Setup the ground to receive the mirror texture.
  98512. */
  98513. private _setupMirrorInGroundMaterial;
  98514. /**
  98515. * Setup the skybox according to the specified options.
  98516. */
  98517. private _setupSkybox;
  98518. /**
  98519. * Setup the skybox material according to the specified options.
  98520. */
  98521. private _setupSkyboxMaterial;
  98522. /**
  98523. * Setup the skybox reflection texture according to the specified options.
  98524. */
  98525. private _setupSkyboxReflectionTexture;
  98526. private _errorHandler;
  98527. /**
  98528. * Dispose all the elements created by the Helper.
  98529. */
  98530. dispose(): void;
  98531. }
  98532. }
  98533. declare module BABYLON {
  98534. /**
  98535. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  98536. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  98537. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  98538. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  98539. */
  98540. export class PhotoDome extends TransformNode {
  98541. private _useDirectMapping;
  98542. /**
  98543. * The texture being displayed on the sphere
  98544. */
  98545. protected _photoTexture: Texture;
  98546. /**
  98547. * Gets or sets the texture being displayed on the sphere
  98548. */
  98549. photoTexture: Texture;
  98550. /**
  98551. * Observable raised when an error occured while loading the 360 image
  98552. */
  98553. onLoadErrorObservable: Observable<string>;
  98554. /**
  98555. * The skybox material
  98556. */
  98557. protected _material: BackgroundMaterial;
  98558. /**
  98559. * The surface used for the skybox
  98560. */
  98561. protected _mesh: Mesh;
  98562. /**
  98563. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  98564. * Also see the options.resolution property.
  98565. */
  98566. fovMultiplier: number;
  98567. /**
  98568. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  98569. * @param name Element's name, child elements will append suffixes for their own names.
  98570. * @param urlsOfPhoto defines the url of the photo to display
  98571. * @param options defines an object containing optional or exposed sub element properties
  98572. * @param onError defines a callback called when an error occured while loading the texture
  98573. */
  98574. constructor(name: string, urlOfPhoto: string, options: {
  98575. resolution?: number;
  98576. size?: number;
  98577. useDirectMapping?: boolean;
  98578. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  98579. /**
  98580. * Releases resources associated with this node.
  98581. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98582. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98583. */
  98584. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98585. }
  98586. }
  98587. declare module BABYLON {
  98588. /**
  98589. * Class used to host texture specific utilities
  98590. */
  98591. export class TextureTools {
  98592. /**
  98593. * Uses the GPU to create a copy texture rescaled at a given size
  98594. * @param texture Texture to copy from
  98595. * @param width defines the desired width
  98596. * @param height defines the desired height
  98597. * @param useBilinearMode defines if bilinear mode has to be used
  98598. * @return the generated texture
  98599. */
  98600. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  98601. /**
  98602. * Gets an environment BRDF texture for a given scene
  98603. * @param scene defines the hosting scene
  98604. * @returns the environment BRDF texture
  98605. */
  98606. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  98607. private static _environmentBRDFBase64Texture;
  98608. }
  98609. }
  98610. declare module BABYLON {
  98611. /** @hidden */
  98612. export var pbrFragmentDeclaration: {
  98613. name: string;
  98614. shader: string;
  98615. };
  98616. }
  98617. declare module BABYLON {
  98618. /** @hidden */
  98619. export var pbrUboDeclaration: {
  98620. name: string;
  98621. shader: string;
  98622. };
  98623. }
  98624. declare module BABYLON {
  98625. /** @hidden */
  98626. export var pbrFunctions: {
  98627. name: string;
  98628. shader: string;
  98629. };
  98630. }
  98631. declare module BABYLON {
  98632. /** @hidden */
  98633. export var harmonicsFunctions: {
  98634. name: string;
  98635. shader: string;
  98636. };
  98637. }
  98638. declare module BABYLON {
  98639. /** @hidden */
  98640. export var pbrLightFunctions: {
  98641. name: string;
  98642. shader: string;
  98643. };
  98644. }
  98645. declare module BABYLON {
  98646. /** @hidden */
  98647. export var pbrPixelShader: {
  98648. name: string;
  98649. shader: string;
  98650. };
  98651. }
  98652. declare module BABYLON {
  98653. /** @hidden */
  98654. export var pbrVertexDeclaration: {
  98655. name: string;
  98656. shader: string;
  98657. };
  98658. }
  98659. declare module BABYLON {
  98660. /** @hidden */
  98661. export var pbrVertexShader: {
  98662. name: string;
  98663. shader: string;
  98664. };
  98665. }
  98666. declare module BABYLON {
  98667. /**
  98668. * The Physically based material base class of BJS.
  98669. *
  98670. * This offers the main features of a standard PBR material.
  98671. * For more information, please refer to the documentation :
  98672. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  98673. */
  98674. export abstract class PBRBaseMaterial extends PushMaterial {
  98675. /**
  98676. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  98677. */
  98678. static readonly PBRMATERIAL_OPAQUE: number;
  98679. /**
  98680. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  98681. */
  98682. static readonly PBRMATERIAL_ALPHATEST: number;
  98683. /**
  98684. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  98685. */
  98686. static readonly PBRMATERIAL_ALPHABLEND: number;
  98687. /**
  98688. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  98689. * They are also discarded below the alpha cutoff threshold to improve performances.
  98690. */
  98691. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  98692. /**
  98693. * Defines the default value of how much AO map is occluding the analytical lights
  98694. * (point spot...).
  98695. */
  98696. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  98697. /**
  98698. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  98699. */
  98700. static readonly LIGHTFALLOFF_PHYSICAL: number;
  98701. /**
  98702. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  98703. * to enhance interoperability with other engines.
  98704. */
  98705. static readonly LIGHTFALLOFF_GLTF: number;
  98706. /**
  98707. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  98708. * to enhance interoperability with other materials.
  98709. */
  98710. static readonly LIGHTFALLOFF_STANDARD: number;
  98711. /**
  98712. * Intensity of the direct lights e.g. the four lights available in your scene.
  98713. * This impacts both the direct diffuse and specular highlights.
  98714. */
  98715. protected _directIntensity: number;
  98716. /**
  98717. * Intensity of the emissive part of the material.
  98718. * This helps controlling the emissive effect without modifying the emissive color.
  98719. */
  98720. protected _emissiveIntensity: number;
  98721. /**
  98722. * Intensity of the environment e.g. how much the environment will light the object
  98723. * either through harmonics for rough material or through the refelction for shiny ones.
  98724. */
  98725. protected _environmentIntensity: number;
  98726. /**
  98727. * This is a special control allowing the reduction of the specular highlights coming from the
  98728. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  98729. */
  98730. protected _specularIntensity: number;
  98731. /**
  98732. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  98733. */
  98734. private _lightingInfos;
  98735. /**
  98736. * Debug Control allowing disabling the bump map on this material.
  98737. */
  98738. protected _disableBumpMap: boolean;
  98739. /**
  98740. * AKA Diffuse Texture in standard nomenclature.
  98741. */
  98742. protected _albedoTexture: BaseTexture;
  98743. /**
  98744. * AKA Occlusion Texture in other nomenclature.
  98745. */
  98746. protected _ambientTexture: BaseTexture;
  98747. /**
  98748. * AKA Occlusion Texture Intensity in other nomenclature.
  98749. */
  98750. protected _ambientTextureStrength: number;
  98751. /**
  98752. * Defines how much the AO map is occluding the analytical lights (point spot...).
  98753. * 1 means it completely occludes it
  98754. * 0 mean it has no impact
  98755. */
  98756. protected _ambientTextureImpactOnAnalyticalLights: number;
  98757. /**
  98758. * Stores the alpha values in a texture.
  98759. */
  98760. protected _opacityTexture: BaseTexture;
  98761. /**
  98762. * Stores the reflection values in a texture.
  98763. */
  98764. protected _reflectionTexture: BaseTexture;
  98765. /**
  98766. * Stores the refraction values in a texture.
  98767. */
  98768. protected _refractionTexture: BaseTexture;
  98769. /**
  98770. * Stores the emissive values in a texture.
  98771. */
  98772. protected _emissiveTexture: BaseTexture;
  98773. /**
  98774. * AKA Specular texture in other nomenclature.
  98775. */
  98776. protected _reflectivityTexture: BaseTexture;
  98777. /**
  98778. * Used to switch from specular/glossiness to metallic/roughness workflow.
  98779. */
  98780. protected _metallicTexture: BaseTexture;
  98781. /**
  98782. * Specifies the metallic scalar of the metallic/roughness workflow.
  98783. * Can also be used to scale the metalness values of the metallic texture.
  98784. */
  98785. protected _metallic: Nullable<number>;
  98786. /**
  98787. * Specifies the roughness scalar of the metallic/roughness workflow.
  98788. * Can also be used to scale the roughness values of the metallic texture.
  98789. */
  98790. protected _roughness: Nullable<number>;
  98791. /**
  98792. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  98793. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  98794. */
  98795. protected _microSurfaceTexture: BaseTexture;
  98796. /**
  98797. * Stores surface normal data used to displace a mesh in a texture.
  98798. */
  98799. protected _bumpTexture: BaseTexture;
  98800. /**
  98801. * Stores the pre-calculated light information of a mesh in a texture.
  98802. */
  98803. protected _lightmapTexture: BaseTexture;
  98804. /**
  98805. * The color of a material in ambient lighting.
  98806. */
  98807. protected _ambientColor: Color3;
  98808. /**
  98809. * AKA Diffuse Color in other nomenclature.
  98810. */
  98811. protected _albedoColor: Color3;
  98812. /**
  98813. * AKA Specular Color in other nomenclature.
  98814. */
  98815. protected _reflectivityColor: Color3;
  98816. /**
  98817. * The color applied when light is reflected from a material.
  98818. */
  98819. protected _reflectionColor: Color3;
  98820. /**
  98821. * The color applied when light is emitted from a material.
  98822. */
  98823. protected _emissiveColor: Color3;
  98824. /**
  98825. * AKA Glossiness in other nomenclature.
  98826. */
  98827. protected _microSurface: number;
  98828. /**
  98829. * source material index of refraction (IOR)' / 'destination material IOR.
  98830. */
  98831. protected _indexOfRefraction: number;
  98832. /**
  98833. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  98834. */
  98835. protected _invertRefractionY: boolean;
  98836. /**
  98837. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  98838. * Materials half opaque for instance using refraction could benefit from this control.
  98839. */
  98840. protected _linkRefractionWithTransparency: boolean;
  98841. /**
  98842. * Specifies that the material will use the light map as a show map.
  98843. */
  98844. protected _useLightmapAsShadowmap: boolean;
  98845. /**
  98846. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  98847. * makes the reflect vector face the model (under horizon).
  98848. */
  98849. protected _useHorizonOcclusion: boolean;
  98850. /**
  98851. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  98852. * too much the area relying on ambient texture to define their ambient occlusion.
  98853. */
  98854. protected _useRadianceOcclusion: boolean;
  98855. /**
  98856. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  98857. */
  98858. protected _useAlphaFromAlbedoTexture: boolean;
  98859. /**
  98860. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  98861. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98862. */
  98863. protected _useSpecularOverAlpha: boolean;
  98864. /**
  98865. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  98866. */
  98867. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  98868. /**
  98869. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  98870. */
  98871. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  98872. /**
  98873. * Specifies if the metallic texture contains the roughness information in its green channel.
  98874. */
  98875. protected _useRoughnessFromMetallicTextureGreen: boolean;
  98876. /**
  98877. * Specifies if the metallic texture contains the metallness information in its blue channel.
  98878. */
  98879. protected _useMetallnessFromMetallicTextureBlue: boolean;
  98880. /**
  98881. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  98882. */
  98883. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  98884. /**
  98885. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  98886. */
  98887. protected _useAmbientInGrayScale: boolean;
  98888. /**
  98889. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  98890. * The material will try to infer what glossiness each pixel should be.
  98891. */
  98892. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  98893. /**
  98894. * Defines the falloff type used in this material.
  98895. * It by default is Physical.
  98896. */
  98897. protected _lightFalloff: number;
  98898. /**
  98899. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  98900. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  98901. */
  98902. protected _useRadianceOverAlpha: boolean;
  98903. /**
  98904. * Allows using an object space normal map (instead of tangent space).
  98905. */
  98906. protected _useObjectSpaceNormalMap: boolean;
  98907. /**
  98908. * Allows using the bump map in parallax mode.
  98909. */
  98910. protected _useParallax: boolean;
  98911. /**
  98912. * Allows using the bump map in parallax occlusion mode.
  98913. */
  98914. protected _useParallaxOcclusion: boolean;
  98915. /**
  98916. * Controls the scale bias of the parallax mode.
  98917. */
  98918. protected _parallaxScaleBias: number;
  98919. /**
  98920. * If sets to true, disables all the lights affecting the material.
  98921. */
  98922. protected _disableLighting: boolean;
  98923. /**
  98924. * Number of Simultaneous lights allowed on the material.
  98925. */
  98926. protected _maxSimultaneousLights: number;
  98927. /**
  98928. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  98929. */
  98930. protected _invertNormalMapX: boolean;
  98931. /**
  98932. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  98933. */
  98934. protected _invertNormalMapY: boolean;
  98935. /**
  98936. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98937. */
  98938. protected _twoSidedLighting: boolean;
  98939. /**
  98940. * Defines the alpha limits in alpha test mode.
  98941. */
  98942. protected _alphaCutOff: number;
  98943. /**
  98944. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  98945. */
  98946. protected _forceAlphaTest: boolean;
  98947. /**
  98948. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  98949. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  98950. */
  98951. protected _useAlphaFresnel: boolean;
  98952. /**
  98953. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  98954. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  98955. */
  98956. protected _useLinearAlphaFresnel: boolean;
  98957. /**
  98958. * The transparency mode of the material.
  98959. */
  98960. protected _transparencyMode: Nullable<number>;
  98961. /**
  98962. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  98963. * from cos thetav and roughness:
  98964. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  98965. */
  98966. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  98967. /**
  98968. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  98969. */
  98970. protected _forceIrradianceInFragment: boolean;
  98971. /**
  98972. * Force normal to face away from face.
  98973. */
  98974. protected _forceNormalForward: boolean;
  98975. /**
  98976. * Enables specular anti aliasing in the PBR shader.
  98977. * It will both interacts on the Geometry for analytical and IBL lighting.
  98978. * It also prefilter the roughness map based on the bump values.
  98979. */
  98980. protected _enableSpecularAntiAliasing: boolean;
  98981. /**
  98982. * Default configuration related to image processing available in the PBR Material.
  98983. */
  98984. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98985. /**
  98986. * Keep track of the image processing observer to allow dispose and replace.
  98987. */
  98988. private _imageProcessingObserver;
  98989. /**
  98990. * Attaches a new image processing configuration to the PBR Material.
  98991. * @param configuration
  98992. */
  98993. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98994. /**
  98995. * Stores the available render targets.
  98996. */
  98997. private _renderTargets;
  98998. /**
  98999. * Sets the global ambient color for the material used in lighting calculations.
  99000. */
  99001. private _globalAmbientColor;
  99002. /**
  99003. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  99004. */
  99005. private _useLogarithmicDepth;
  99006. /**
  99007. * If set to true, no lighting calculations will be applied.
  99008. */
  99009. private _unlit;
  99010. /**
  99011. * Instantiates a new PBRMaterial instance.
  99012. *
  99013. * @param name The material name
  99014. * @param scene The scene the material will be use in.
  99015. */
  99016. constructor(name: string, scene: Scene);
  99017. /**
  99018. * Gets a boolean indicating that current material needs to register RTT
  99019. */
  99020. readonly hasRenderTargetTextures: boolean;
  99021. /**
  99022. * Gets the name of the material class.
  99023. */
  99024. getClassName(): string;
  99025. /**
  99026. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  99027. */
  99028. /**
  99029. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  99030. */
  99031. useLogarithmicDepth: boolean;
  99032. /**
  99033. * Gets the current transparency mode.
  99034. */
  99035. /**
  99036. * Sets the transparency mode of the material.
  99037. *
  99038. * | Value | Type | Description |
  99039. * | ----- | ----------------------------------- | ----------- |
  99040. * | 0 | OPAQUE | |
  99041. * | 1 | ALPHATEST | |
  99042. * | 2 | ALPHABLEND | |
  99043. * | 3 | ALPHATESTANDBLEND | |
  99044. *
  99045. */
  99046. transparencyMode: Nullable<number>;
  99047. /**
  99048. * Returns true if alpha blending should be disabled.
  99049. */
  99050. private readonly _disableAlphaBlending;
  99051. /**
  99052. * Specifies whether or not this material should be rendered in alpha blend mode.
  99053. */
  99054. needAlphaBlending(): boolean;
  99055. /**
  99056. * Specifies if the mesh will require alpha blending.
  99057. * @param mesh - BJS mesh.
  99058. */
  99059. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  99060. /**
  99061. * Specifies whether or not this material should be rendered in alpha test mode.
  99062. */
  99063. needAlphaTesting(): boolean;
  99064. /**
  99065. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  99066. */
  99067. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  99068. /**
  99069. * Gets the texture used for the alpha test.
  99070. */
  99071. getAlphaTestTexture(): BaseTexture;
  99072. /**
  99073. * Specifies that the submesh is ready to be used.
  99074. * @param mesh - BJS mesh.
  99075. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  99076. * @param useInstances - Specifies that instances should be used.
  99077. * @returns - boolean indicating that the submesh is ready or not.
  99078. */
  99079. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99080. /**
  99081. * Specifies if the material uses metallic roughness workflow.
  99082. * @returns boolean specifiying if the material uses metallic roughness workflow.
  99083. */
  99084. isMetallicWorkflow(): boolean;
  99085. private _prepareEffect;
  99086. private _prepareDefines;
  99087. /**
  99088. * Force shader compilation
  99089. */
  99090. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  99091. clipPlane: boolean;
  99092. }>): void;
  99093. /**
  99094. * Initializes the uniform buffer layout for the shader.
  99095. */
  99096. buildUniformLayout(): void;
  99097. /**
  99098. * Unbinds the textures.
  99099. */
  99100. unbind(): void;
  99101. /**
  99102. * Binds the submesh data.
  99103. * @param world - The world matrix.
  99104. * @param mesh - The BJS mesh.
  99105. * @param subMesh - A submesh of the BJS mesh.
  99106. */
  99107. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99108. /**
  99109. * Returns the animatable textures.
  99110. * @returns - Array of animatable textures.
  99111. */
  99112. getAnimatables(): IAnimatable[];
  99113. /**
  99114. * Returns the texture used for reflections.
  99115. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  99116. */
  99117. private _getReflectionTexture;
  99118. /**
  99119. * Returns the texture used for refraction or null if none is used.
  99120. * @returns - Refection texture if present. If no refraction texture and refraction
  99121. * is linked with transparency, returns environment texture. Otherwise, returns null.
  99122. */
  99123. private _getRefractionTexture;
  99124. /**
  99125. * Disposes the resources of the material.
  99126. * @param forceDisposeEffect - Forces the disposal of effects.
  99127. * @param forceDisposeTextures - Forces the disposal of all textures.
  99128. */
  99129. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99130. }
  99131. }
  99132. declare module BABYLON {
  99133. /**
  99134. * The Physically based material of BJS.
  99135. *
  99136. * This offers the main features of a standard PBR material.
  99137. * For more information, please refer to the documentation :
  99138. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  99139. */
  99140. export class PBRMaterial extends PBRBaseMaterial {
  99141. /**
  99142. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  99143. */
  99144. static readonly PBRMATERIAL_OPAQUE: number;
  99145. /**
  99146. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  99147. */
  99148. static readonly PBRMATERIAL_ALPHATEST: number;
  99149. /**
  99150. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  99151. */
  99152. static readonly PBRMATERIAL_ALPHABLEND: number;
  99153. /**
  99154. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  99155. * They are also discarded below the alpha cutoff threshold to improve performances.
  99156. */
  99157. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  99158. /**
  99159. * Defines the default value of how much AO map is occluding the analytical lights
  99160. * (point spot...).
  99161. */
  99162. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  99163. /**
  99164. * Intensity of the direct lights e.g. the four lights available in your scene.
  99165. * This impacts both the direct diffuse and specular highlights.
  99166. */
  99167. directIntensity: number;
  99168. /**
  99169. * Intensity of the emissive part of the material.
  99170. * This helps controlling the emissive effect without modifying the emissive color.
  99171. */
  99172. emissiveIntensity: number;
  99173. /**
  99174. * Intensity of the environment e.g. how much the environment will light the object
  99175. * either through harmonics for rough material or through the refelction for shiny ones.
  99176. */
  99177. environmentIntensity: number;
  99178. /**
  99179. * This is a special control allowing the reduction of the specular highlights coming from the
  99180. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  99181. */
  99182. specularIntensity: number;
  99183. /**
  99184. * Debug Control allowing disabling the bump map on this material.
  99185. */
  99186. disableBumpMap: boolean;
  99187. /**
  99188. * AKA Diffuse Texture in standard nomenclature.
  99189. */
  99190. albedoTexture: BaseTexture;
  99191. /**
  99192. * AKA Occlusion Texture in other nomenclature.
  99193. */
  99194. ambientTexture: BaseTexture;
  99195. /**
  99196. * AKA Occlusion Texture Intensity in other nomenclature.
  99197. */
  99198. ambientTextureStrength: number;
  99199. /**
  99200. * Defines how much the AO map is occluding the analytical lights (point spot...).
  99201. * 1 means it completely occludes it
  99202. * 0 mean it has no impact
  99203. */
  99204. ambientTextureImpactOnAnalyticalLights: number;
  99205. /**
  99206. * Stores the alpha values in a texture.
  99207. */
  99208. opacityTexture: BaseTexture;
  99209. /**
  99210. * Stores the reflection values in a texture.
  99211. */
  99212. reflectionTexture: Nullable<BaseTexture>;
  99213. /**
  99214. * Stores the emissive values in a texture.
  99215. */
  99216. emissiveTexture: BaseTexture;
  99217. /**
  99218. * AKA Specular texture in other nomenclature.
  99219. */
  99220. reflectivityTexture: BaseTexture;
  99221. /**
  99222. * Used to switch from specular/glossiness to metallic/roughness workflow.
  99223. */
  99224. metallicTexture: BaseTexture;
  99225. /**
  99226. * Specifies the metallic scalar of the metallic/roughness workflow.
  99227. * Can also be used to scale the metalness values of the metallic texture.
  99228. */
  99229. metallic: Nullable<number>;
  99230. /**
  99231. * Specifies the roughness scalar of the metallic/roughness workflow.
  99232. * Can also be used to scale the roughness values of the metallic texture.
  99233. */
  99234. roughness: Nullable<number>;
  99235. /**
  99236. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  99237. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  99238. */
  99239. microSurfaceTexture: BaseTexture;
  99240. /**
  99241. * Stores surface normal data used to displace a mesh in a texture.
  99242. */
  99243. bumpTexture: BaseTexture;
  99244. /**
  99245. * Stores the pre-calculated light information of a mesh in a texture.
  99246. */
  99247. lightmapTexture: BaseTexture;
  99248. /**
  99249. * Stores the refracted light information in a texture.
  99250. */
  99251. refractionTexture: BaseTexture;
  99252. /**
  99253. * The color of a material in ambient lighting.
  99254. */
  99255. ambientColor: Color3;
  99256. /**
  99257. * AKA Diffuse Color in other nomenclature.
  99258. */
  99259. albedoColor: Color3;
  99260. /**
  99261. * AKA Specular Color in other nomenclature.
  99262. */
  99263. reflectivityColor: Color3;
  99264. /**
  99265. * The color reflected from the material.
  99266. */
  99267. reflectionColor: Color3;
  99268. /**
  99269. * The color emitted from the material.
  99270. */
  99271. emissiveColor: Color3;
  99272. /**
  99273. * AKA Glossiness in other nomenclature.
  99274. */
  99275. microSurface: number;
  99276. /**
  99277. * source material index of refraction (IOR)' / 'destination material IOR.
  99278. */
  99279. indexOfRefraction: number;
  99280. /**
  99281. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99282. */
  99283. invertRefractionY: boolean;
  99284. /**
  99285. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99286. * Materials half opaque for instance using refraction could benefit from this control.
  99287. */
  99288. linkRefractionWithTransparency: boolean;
  99289. /**
  99290. * If true, the light map contains occlusion information instead of lighting info.
  99291. */
  99292. useLightmapAsShadowmap: boolean;
  99293. /**
  99294. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  99295. */
  99296. useAlphaFromAlbedoTexture: boolean;
  99297. /**
  99298. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  99299. */
  99300. forceAlphaTest: boolean;
  99301. /**
  99302. * Defines the alpha limits in alpha test mode.
  99303. */
  99304. alphaCutOff: number;
  99305. /**
  99306. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99307. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99308. */
  99309. useSpecularOverAlpha: boolean;
  99310. /**
  99311. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  99312. */
  99313. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  99314. /**
  99315. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  99316. */
  99317. useRoughnessFromMetallicTextureAlpha: boolean;
  99318. /**
  99319. * Specifies if the metallic texture contains the roughness information in its green channel.
  99320. */
  99321. useRoughnessFromMetallicTextureGreen: boolean;
  99322. /**
  99323. * Specifies if the metallic texture contains the metallness information in its blue channel.
  99324. */
  99325. useMetallnessFromMetallicTextureBlue: boolean;
  99326. /**
  99327. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  99328. */
  99329. useAmbientOcclusionFromMetallicTextureRed: boolean;
  99330. /**
  99331. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  99332. */
  99333. useAmbientInGrayScale: boolean;
  99334. /**
  99335. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  99336. * The material will try to infer what glossiness each pixel should be.
  99337. */
  99338. useAutoMicroSurfaceFromReflectivityMap: boolean;
  99339. /**
  99340. * BJS is using an harcoded light falloff based on a manually sets up range.
  99341. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  99342. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  99343. */
  99344. /**
  99345. * BJS is using an harcoded light falloff based on a manually sets up range.
  99346. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  99347. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  99348. */
  99349. usePhysicalLightFalloff: boolean;
  99350. /**
  99351. * In order to support the falloff compatibility with gltf, a special mode has been added
  99352. * to reproduce the gltf light falloff.
  99353. */
  99354. /**
  99355. * In order to support the falloff compatibility with gltf, a special mode has been added
  99356. * to reproduce the gltf light falloff.
  99357. */
  99358. useGLTFLightFalloff: boolean;
  99359. /**
  99360. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99361. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99362. */
  99363. useRadianceOverAlpha: boolean;
  99364. /**
  99365. * Allows using an object space normal map (instead of tangent space).
  99366. */
  99367. useObjectSpaceNormalMap: boolean;
  99368. /**
  99369. * Allows using the bump map in parallax mode.
  99370. */
  99371. useParallax: boolean;
  99372. /**
  99373. * Allows using the bump map in parallax occlusion mode.
  99374. */
  99375. useParallaxOcclusion: boolean;
  99376. /**
  99377. * Controls the scale bias of the parallax mode.
  99378. */
  99379. parallaxScaleBias: number;
  99380. /**
  99381. * If sets to true, disables all the lights affecting the material.
  99382. */
  99383. disableLighting: boolean;
  99384. /**
  99385. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  99386. */
  99387. forceIrradianceInFragment: boolean;
  99388. /**
  99389. * Number of Simultaneous lights allowed on the material.
  99390. */
  99391. maxSimultaneousLights: number;
  99392. /**
  99393. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99394. */
  99395. invertNormalMapX: boolean;
  99396. /**
  99397. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99398. */
  99399. invertNormalMapY: boolean;
  99400. /**
  99401. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99402. */
  99403. twoSidedLighting: boolean;
  99404. /**
  99405. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99406. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  99407. */
  99408. useAlphaFresnel: boolean;
  99409. /**
  99410. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99411. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  99412. */
  99413. useLinearAlphaFresnel: boolean;
  99414. /**
  99415. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99416. * And/Or occlude the blended part.
  99417. */
  99418. environmentBRDFTexture: Nullable<BaseTexture>;
  99419. /**
  99420. * Force normal to face away from face.
  99421. */
  99422. forceNormalForward: boolean;
  99423. /**
  99424. * Enables specular anti aliasing in the PBR shader.
  99425. * It will both interacts on the Geometry for analytical and IBL lighting.
  99426. * It also prefilter the roughness map based on the bump values.
  99427. */
  99428. enableSpecularAntiAliasing: boolean;
  99429. /**
  99430. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  99431. * makes the reflect vector face the model (under horizon).
  99432. */
  99433. useHorizonOcclusion: boolean;
  99434. /**
  99435. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  99436. * too much the area relying on ambient texture to define their ambient occlusion.
  99437. */
  99438. useRadianceOcclusion: boolean;
  99439. /**
  99440. * If set to true, no lighting calculations will be applied.
  99441. */
  99442. unlit: boolean;
  99443. /**
  99444. * Gets the image processing configuration used either in this material.
  99445. */
  99446. /**
  99447. * Sets the Default image processing configuration used either in the this material.
  99448. *
  99449. * If sets to null, the scene one is in use.
  99450. */
  99451. imageProcessingConfiguration: ImageProcessingConfiguration;
  99452. /**
  99453. * Gets wether the color curves effect is enabled.
  99454. */
  99455. /**
  99456. * Sets wether the color curves effect is enabled.
  99457. */
  99458. cameraColorCurvesEnabled: boolean;
  99459. /**
  99460. * Gets wether the color grading effect is enabled.
  99461. */
  99462. /**
  99463. * Gets wether the color grading effect is enabled.
  99464. */
  99465. cameraColorGradingEnabled: boolean;
  99466. /**
  99467. * Gets wether tonemapping is enabled or not.
  99468. */
  99469. /**
  99470. * Sets wether tonemapping is enabled or not
  99471. */
  99472. cameraToneMappingEnabled: boolean;
  99473. /**
  99474. * The camera exposure used on this material.
  99475. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99476. * This corresponds to a photographic exposure.
  99477. */
  99478. /**
  99479. * The camera exposure used on this material.
  99480. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99481. * This corresponds to a photographic exposure.
  99482. */
  99483. cameraExposure: number;
  99484. /**
  99485. * Gets The camera contrast used on this material.
  99486. */
  99487. /**
  99488. * Sets The camera contrast used on this material.
  99489. */
  99490. cameraContrast: number;
  99491. /**
  99492. * Gets the Color Grading 2D Lookup Texture.
  99493. */
  99494. /**
  99495. * Sets the Color Grading 2D Lookup Texture.
  99496. */
  99497. cameraColorGradingTexture: Nullable<BaseTexture>;
  99498. /**
  99499. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99500. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99501. * 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;
  99502. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99503. */
  99504. /**
  99505. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99506. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99507. * 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;
  99508. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99509. */
  99510. cameraColorCurves: Nullable<ColorCurves>;
  99511. /**
  99512. * Instantiates a new PBRMaterial instance.
  99513. *
  99514. * @param name The material name
  99515. * @param scene The scene the material will be use in.
  99516. */
  99517. constructor(name: string, scene: Scene);
  99518. /**
  99519. * Returns the name of this material class.
  99520. */
  99521. getClassName(): string;
  99522. /**
  99523. * Returns an array of the actively used textures.
  99524. * @returns - Array of BaseTextures
  99525. */
  99526. getActiveTextures(): BaseTexture[];
  99527. /**
  99528. * Checks to see if a texture is used in the material.
  99529. * @param texture - Base texture to use.
  99530. * @returns - Boolean specifying if a texture is used in the material.
  99531. */
  99532. hasTexture(texture: BaseTexture): boolean;
  99533. /**
  99534. * Makes a duplicate of the current material.
  99535. * @param name - name to use for the new material.
  99536. */
  99537. clone(name: string): PBRMaterial;
  99538. /**
  99539. * Serializes this PBR Material.
  99540. * @returns - An object with the serialized material.
  99541. */
  99542. serialize(): any;
  99543. /**
  99544. * Parses a PBR Material from a serialized object.
  99545. * @param source - Serialized object.
  99546. * @param scene - BJS scene instance.
  99547. * @param rootUrl - url for the scene object
  99548. * @returns - PBRMaterial
  99549. */
  99550. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  99551. }
  99552. }
  99553. declare module BABYLON {
  99554. /** @hidden */
  99555. export var _forceSceneHelpersToBundle: boolean;
  99556. interface Scene {
  99557. /**
  99558. * Creates a default light for the scene.
  99559. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  99560. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  99561. */
  99562. createDefaultLight(replace?: boolean): void;
  99563. /**
  99564. * Creates a default camera for the scene.
  99565. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  99566. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  99567. * @param replace has default false, when true replaces the active camera in the scene
  99568. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  99569. */
  99570. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  99571. /**
  99572. * Creates a default camera and a default light.
  99573. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  99574. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  99575. * @param replace has the default false, when true replaces the active camera/light in the scene
  99576. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  99577. */
  99578. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  99579. /**
  99580. * Creates a new sky box
  99581. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  99582. * @param environmentTexture defines the texture to use as environment texture
  99583. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  99584. * @param scale defines the overall scale of the skybox
  99585. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  99586. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  99587. * @returns a new mesh holding the sky box
  99588. */
  99589. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  99590. /**
  99591. * Creates a new environment
  99592. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  99593. * @param options defines the options you can use to configure the environment
  99594. * @returns the new EnvironmentHelper
  99595. */
  99596. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  99597. /**
  99598. * Creates a new VREXperienceHelper
  99599. * @see http://doc.babylonjs.com/how_to/webvr_helper
  99600. * @param webVROptions defines the options used to create the new VREXperienceHelper
  99601. * @returns a new VREXperienceHelper
  99602. */
  99603. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  99604. /**
  99605. * Creates a new XREXperienceHelper
  99606. * @see http://doc.babylonjs.com/how_to/webxr
  99607. * @returns a promise for a new XREXperienceHelper
  99608. */
  99609. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  99610. }
  99611. }
  99612. declare module BABYLON {
  99613. /**
  99614. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  99615. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  99616. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  99617. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  99618. */
  99619. export class VideoDome extends TransformNode {
  99620. private _useDirectMapping;
  99621. /**
  99622. * The video texture being displayed on the sphere
  99623. */
  99624. protected _videoTexture: VideoTexture;
  99625. /**
  99626. * Gets the video texture being displayed on the sphere
  99627. */
  99628. readonly videoTexture: VideoTexture;
  99629. /**
  99630. * The skybox material
  99631. */
  99632. protected _material: BackgroundMaterial;
  99633. /**
  99634. * The surface used for the skybox
  99635. */
  99636. protected _mesh: Mesh;
  99637. /**
  99638. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99639. * Also see the options.resolution property.
  99640. */
  99641. fovMultiplier: number;
  99642. /**
  99643. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  99644. * @param name Element's name, child elements will append suffixes for their own names.
  99645. * @param urlsOrVideo defines the url(s) or the video element to use
  99646. * @param options An object containing optional or exposed sub element properties
  99647. */
  99648. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  99649. resolution?: number;
  99650. clickToPlay?: boolean;
  99651. autoPlay?: boolean;
  99652. loop?: boolean;
  99653. size?: number;
  99654. poster?: string;
  99655. useDirectMapping?: boolean;
  99656. }, scene: Scene);
  99657. /**
  99658. * Releases resources associated with this node.
  99659. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99660. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99661. */
  99662. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99663. }
  99664. }
  99665. declare module BABYLON {
  99666. /**
  99667. * This class can be used to get instrumentation data from a Babylon engine
  99668. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99669. */
  99670. export class EngineInstrumentation implements IDisposable {
  99671. /**
  99672. * Define the instrumented engine.
  99673. */
  99674. engine: Engine;
  99675. private _captureGPUFrameTime;
  99676. private _gpuFrameTimeToken;
  99677. private _gpuFrameTime;
  99678. private _captureShaderCompilationTime;
  99679. private _shaderCompilationTime;
  99680. private _onBeginFrameObserver;
  99681. private _onEndFrameObserver;
  99682. private _onBeforeShaderCompilationObserver;
  99683. private _onAfterShaderCompilationObserver;
  99684. /**
  99685. * Gets the perf counter used for GPU frame time
  99686. */
  99687. readonly gpuFrameTimeCounter: PerfCounter;
  99688. /**
  99689. * Gets the GPU frame time capture status
  99690. */
  99691. /**
  99692. * Enable or disable the GPU frame time capture
  99693. */
  99694. captureGPUFrameTime: boolean;
  99695. /**
  99696. * Gets the perf counter used for shader compilation time
  99697. */
  99698. readonly shaderCompilationTimeCounter: PerfCounter;
  99699. /**
  99700. * Gets the shader compilation time capture status
  99701. */
  99702. /**
  99703. * Enable or disable the shader compilation time capture
  99704. */
  99705. captureShaderCompilationTime: boolean;
  99706. /**
  99707. * Instantiates a new engine instrumentation.
  99708. * This class can be used to get instrumentation data from a Babylon engine
  99709. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99710. * @param engine Defines the engine to instrument
  99711. */
  99712. constructor(
  99713. /**
  99714. * Define the instrumented engine.
  99715. */
  99716. engine: Engine);
  99717. /**
  99718. * Dispose and release associated resources.
  99719. */
  99720. dispose(): void;
  99721. }
  99722. }
  99723. declare module BABYLON {
  99724. /**
  99725. * This class can be used to get instrumentation data from a Babylon engine
  99726. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  99727. */
  99728. export class SceneInstrumentation implements IDisposable {
  99729. /**
  99730. * Defines the scene to instrument
  99731. */
  99732. scene: Scene;
  99733. private _captureActiveMeshesEvaluationTime;
  99734. private _activeMeshesEvaluationTime;
  99735. private _captureRenderTargetsRenderTime;
  99736. private _renderTargetsRenderTime;
  99737. private _captureFrameTime;
  99738. private _frameTime;
  99739. private _captureRenderTime;
  99740. private _renderTime;
  99741. private _captureInterFrameTime;
  99742. private _interFrameTime;
  99743. private _captureParticlesRenderTime;
  99744. private _particlesRenderTime;
  99745. private _captureSpritesRenderTime;
  99746. private _spritesRenderTime;
  99747. private _capturePhysicsTime;
  99748. private _physicsTime;
  99749. private _captureAnimationsTime;
  99750. private _animationsTime;
  99751. private _captureCameraRenderTime;
  99752. private _cameraRenderTime;
  99753. private _onBeforeActiveMeshesEvaluationObserver;
  99754. private _onAfterActiveMeshesEvaluationObserver;
  99755. private _onBeforeRenderTargetsRenderObserver;
  99756. private _onAfterRenderTargetsRenderObserver;
  99757. private _onAfterRenderObserver;
  99758. private _onBeforeDrawPhaseObserver;
  99759. private _onAfterDrawPhaseObserver;
  99760. private _onBeforeAnimationsObserver;
  99761. private _onBeforeParticlesRenderingObserver;
  99762. private _onAfterParticlesRenderingObserver;
  99763. private _onBeforeSpritesRenderingObserver;
  99764. private _onAfterSpritesRenderingObserver;
  99765. private _onBeforePhysicsObserver;
  99766. private _onAfterPhysicsObserver;
  99767. private _onAfterAnimationsObserver;
  99768. private _onBeforeCameraRenderObserver;
  99769. private _onAfterCameraRenderObserver;
  99770. /**
  99771. * Gets the perf counter used for active meshes evaluation time
  99772. */
  99773. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  99774. /**
  99775. * Gets the active meshes evaluation time capture status
  99776. */
  99777. /**
  99778. * Enable or disable the active meshes evaluation time capture
  99779. */
  99780. captureActiveMeshesEvaluationTime: boolean;
  99781. /**
  99782. * Gets the perf counter used for render targets render time
  99783. */
  99784. readonly renderTargetsRenderTimeCounter: PerfCounter;
  99785. /**
  99786. * Gets the render targets render time capture status
  99787. */
  99788. /**
  99789. * Enable or disable the render targets render time capture
  99790. */
  99791. captureRenderTargetsRenderTime: boolean;
  99792. /**
  99793. * Gets the perf counter used for particles render time
  99794. */
  99795. readonly particlesRenderTimeCounter: PerfCounter;
  99796. /**
  99797. * Gets the particles render time capture status
  99798. */
  99799. /**
  99800. * Enable or disable the particles render time capture
  99801. */
  99802. captureParticlesRenderTime: boolean;
  99803. /**
  99804. * Gets the perf counter used for sprites render time
  99805. */
  99806. readonly spritesRenderTimeCounter: PerfCounter;
  99807. /**
  99808. * Gets the sprites render time capture status
  99809. */
  99810. /**
  99811. * Enable or disable the sprites render time capture
  99812. */
  99813. captureSpritesRenderTime: boolean;
  99814. /**
  99815. * Gets the perf counter used for physics time
  99816. */
  99817. readonly physicsTimeCounter: PerfCounter;
  99818. /**
  99819. * Gets the physics time capture status
  99820. */
  99821. /**
  99822. * Enable or disable the physics time capture
  99823. */
  99824. capturePhysicsTime: boolean;
  99825. /**
  99826. * Gets the perf counter used for animations time
  99827. */
  99828. readonly animationsTimeCounter: PerfCounter;
  99829. /**
  99830. * Gets the animations time capture status
  99831. */
  99832. /**
  99833. * Enable or disable the animations time capture
  99834. */
  99835. captureAnimationsTime: boolean;
  99836. /**
  99837. * Gets the perf counter used for frame time capture
  99838. */
  99839. readonly frameTimeCounter: PerfCounter;
  99840. /**
  99841. * Gets the frame time capture status
  99842. */
  99843. /**
  99844. * Enable or disable the frame time capture
  99845. */
  99846. captureFrameTime: boolean;
  99847. /**
  99848. * Gets the perf counter used for inter-frames time capture
  99849. */
  99850. readonly interFrameTimeCounter: PerfCounter;
  99851. /**
  99852. * Gets the inter-frames time capture status
  99853. */
  99854. /**
  99855. * Enable or disable the inter-frames time capture
  99856. */
  99857. captureInterFrameTime: boolean;
  99858. /**
  99859. * Gets the perf counter used for render time capture
  99860. */
  99861. readonly renderTimeCounter: PerfCounter;
  99862. /**
  99863. * Gets the render time capture status
  99864. */
  99865. /**
  99866. * Enable or disable the render time capture
  99867. */
  99868. captureRenderTime: boolean;
  99869. /**
  99870. * Gets the perf counter used for camera render time capture
  99871. */
  99872. readonly cameraRenderTimeCounter: PerfCounter;
  99873. /**
  99874. * Gets the camera render time capture status
  99875. */
  99876. /**
  99877. * Enable or disable the camera render time capture
  99878. */
  99879. captureCameraRenderTime: boolean;
  99880. /**
  99881. * Gets the perf counter used for draw calls
  99882. */
  99883. readonly drawCallsCounter: PerfCounter;
  99884. /**
  99885. * Gets the perf counter used for texture collisions
  99886. */
  99887. readonly textureCollisionsCounter: PerfCounter;
  99888. /**
  99889. * Instantiates a new scene instrumentation.
  99890. * This class can be used to get instrumentation data from a Babylon engine
  99891. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  99892. * @param scene Defines the scene to instrument
  99893. */
  99894. constructor(
  99895. /**
  99896. * Defines the scene to instrument
  99897. */
  99898. scene: Scene);
  99899. /**
  99900. * Dispose and release associated resources.
  99901. */
  99902. dispose(): void;
  99903. }
  99904. }
  99905. declare module BABYLON {
  99906. /** @hidden */
  99907. export var glowMapGenerationPixelShader: {
  99908. name: string;
  99909. shader: string;
  99910. };
  99911. }
  99912. declare module BABYLON {
  99913. /** @hidden */
  99914. export var glowMapGenerationVertexShader: {
  99915. name: string;
  99916. shader: string;
  99917. };
  99918. }
  99919. declare module BABYLON {
  99920. /**
  99921. * Effect layer options. This helps customizing the behaviour
  99922. * of the effect layer.
  99923. */
  99924. export interface IEffectLayerOptions {
  99925. /**
  99926. * Multiplication factor apply to the canvas size to compute the render target size
  99927. * used to generated the objects (the smaller the faster).
  99928. */
  99929. mainTextureRatio: number;
  99930. /**
  99931. * Enforces a fixed size texture to ensure effect stability across devices.
  99932. */
  99933. mainTextureFixedSize?: number;
  99934. /**
  99935. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  99936. */
  99937. alphaBlendingMode: number;
  99938. /**
  99939. * The camera attached to the layer.
  99940. */
  99941. camera: Nullable<Camera>;
  99942. /**
  99943. * The rendering group to draw the layer in.
  99944. */
  99945. renderingGroupId: number;
  99946. }
  99947. /**
  99948. * The effect layer Helps adding post process effect blended with the main pass.
  99949. *
  99950. * This can be for instance use to generate glow or higlight effects on the scene.
  99951. *
  99952. * The effect layer class can not be used directly and is intented to inherited from to be
  99953. * customized per effects.
  99954. */
  99955. export abstract class EffectLayer {
  99956. private _vertexBuffers;
  99957. private _indexBuffer;
  99958. private _cachedDefines;
  99959. private _effectLayerMapGenerationEffect;
  99960. private _effectLayerOptions;
  99961. private _mergeEffect;
  99962. protected _scene: Scene;
  99963. protected _engine: Engine;
  99964. protected _maxSize: number;
  99965. protected _mainTextureDesiredSize: ISize;
  99966. protected _mainTexture: RenderTargetTexture;
  99967. protected _shouldRender: boolean;
  99968. protected _postProcesses: PostProcess[];
  99969. protected _textures: BaseTexture[];
  99970. protected _emissiveTextureAndColor: {
  99971. texture: Nullable<BaseTexture>;
  99972. color: Color4;
  99973. };
  99974. /**
  99975. * The name of the layer
  99976. */
  99977. name: string;
  99978. /**
  99979. * The clear color of the texture used to generate the glow map.
  99980. */
  99981. neutralColor: Color4;
  99982. /**
  99983. * Specifies wether the highlight layer is enabled or not.
  99984. */
  99985. isEnabled: boolean;
  99986. /**
  99987. * Gets the camera attached to the layer.
  99988. */
  99989. readonly camera: Nullable<Camera>;
  99990. /**
  99991. * Gets the rendering group id the layer should render in.
  99992. */
  99993. readonly renderingGroupId: number;
  99994. /**
  99995. * An event triggered when the effect layer has been disposed.
  99996. */
  99997. onDisposeObservable: Observable<EffectLayer>;
  99998. /**
  99999. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  100000. */
  100001. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  100002. /**
  100003. * An event triggered when the generated texture is being merged in the scene.
  100004. */
  100005. onBeforeComposeObservable: Observable<EffectLayer>;
  100006. /**
  100007. * An event triggered when the generated texture has been merged in the scene.
  100008. */
  100009. onAfterComposeObservable: Observable<EffectLayer>;
  100010. /**
  100011. * An event triggered when the efffect layer changes its size.
  100012. */
  100013. onSizeChangedObservable: Observable<EffectLayer>;
  100014. /** @hidden */
  100015. static _SceneComponentInitialization: (scene: Scene) => void;
  100016. /**
  100017. * Instantiates a new effect Layer and references it in the scene.
  100018. * @param name The name of the layer
  100019. * @param scene The scene to use the layer in
  100020. */
  100021. constructor(
  100022. /** The Friendly of the effect in the scene */
  100023. name: string, scene: Scene);
  100024. /**
  100025. * Get the effect name of the layer.
  100026. * @return The effect name
  100027. */
  100028. abstract getEffectName(): string;
  100029. /**
  100030. * Checks for the readiness of the element composing the layer.
  100031. * @param subMesh the mesh to check for
  100032. * @param useInstances specify wether or not to use instances to render the mesh
  100033. * @return true if ready otherwise, false
  100034. */
  100035. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  100036. /**
  100037. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  100038. * @returns true if the effect requires stencil during the main canvas render pass.
  100039. */
  100040. abstract needStencil(): boolean;
  100041. /**
  100042. * Create the merge effect. This is the shader use to blit the information back
  100043. * to the main canvas at the end of the scene rendering.
  100044. * @returns The effect containing the shader used to merge the effect on the main canvas
  100045. */
  100046. protected abstract _createMergeEffect(): Effect;
  100047. /**
  100048. * Creates the render target textures and post processes used in the effect layer.
  100049. */
  100050. protected abstract _createTextureAndPostProcesses(): void;
  100051. /**
  100052. * Implementation specific of rendering the generating effect on the main canvas.
  100053. * @param effect The effect used to render through
  100054. */
  100055. protected abstract _internalRender(effect: Effect): void;
  100056. /**
  100057. * Sets the required values for both the emissive texture and and the main color.
  100058. */
  100059. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  100060. /**
  100061. * Free any resources and references associated to a mesh.
  100062. * Internal use
  100063. * @param mesh The mesh to free.
  100064. */
  100065. abstract _disposeMesh(mesh: Mesh): void;
  100066. /**
  100067. * Serializes this layer (Glow or Highlight for example)
  100068. * @returns a serialized layer object
  100069. */
  100070. abstract serialize?(): any;
  100071. /**
  100072. * Initializes the effect layer with the required options.
  100073. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  100074. */
  100075. protected _init(options: Partial<IEffectLayerOptions>): void;
  100076. /**
  100077. * Generates the index buffer of the full screen quad blending to the main canvas.
  100078. */
  100079. private _generateIndexBuffer;
  100080. /**
  100081. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  100082. */
  100083. private _genrateVertexBuffer;
  100084. /**
  100085. * Sets the main texture desired size which is the closest power of two
  100086. * of the engine canvas size.
  100087. */
  100088. private _setMainTextureSize;
  100089. /**
  100090. * Creates the main texture for the effect layer.
  100091. */
  100092. protected _createMainTexture(): void;
  100093. /**
  100094. * Adds specific effects defines.
  100095. * @param defines The defines to add specifics to.
  100096. */
  100097. protected _addCustomEffectDefines(defines: string[]): void;
  100098. /**
  100099. * Checks for the readiness of the element composing the layer.
  100100. * @param subMesh the mesh to check for
  100101. * @param useInstances specify wether or not to use instances to render the mesh
  100102. * @param emissiveTexture the associated emissive texture used to generate the glow
  100103. * @return true if ready otherwise, false
  100104. */
  100105. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  100106. /**
  100107. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  100108. */
  100109. render(): void;
  100110. /**
  100111. * Determine if a given mesh will be used in the current effect.
  100112. * @param mesh mesh to test
  100113. * @returns true if the mesh will be used
  100114. */
  100115. hasMesh(mesh: AbstractMesh): boolean;
  100116. /**
  100117. * Returns true if the layer contains information to display, otherwise false.
  100118. * @returns true if the glow layer should be rendered
  100119. */
  100120. shouldRender(): boolean;
  100121. /**
  100122. * Returns true if the mesh should render, otherwise false.
  100123. * @param mesh The mesh to render
  100124. * @returns true if it should render otherwise false
  100125. */
  100126. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  100127. /**
  100128. * Returns true if the mesh can be rendered, otherwise false.
  100129. * @param mesh The mesh to render
  100130. * @param material The material used on the mesh
  100131. * @returns true if it can be rendered otherwise false
  100132. */
  100133. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  100134. /**
  100135. * Returns true if the mesh should render, otherwise false.
  100136. * @param mesh The mesh to render
  100137. * @returns true if it should render otherwise false
  100138. */
  100139. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  100140. /**
  100141. * Renders the submesh passed in parameter to the generation map.
  100142. */
  100143. protected _renderSubMesh(subMesh: SubMesh): void;
  100144. /**
  100145. * Rebuild the required buffers.
  100146. * @hidden Internal use only.
  100147. */
  100148. _rebuild(): void;
  100149. /**
  100150. * Dispose only the render target textures and post process.
  100151. */
  100152. private _disposeTextureAndPostProcesses;
  100153. /**
  100154. * Dispose the highlight layer and free resources.
  100155. */
  100156. dispose(): void;
  100157. /**
  100158. * Gets the class name of the effect layer
  100159. * @returns the string with the class name of the effect layer
  100160. */
  100161. getClassName(): string;
  100162. /**
  100163. * Creates an effect layer from parsed effect layer data
  100164. * @param parsedEffectLayer defines effect layer data
  100165. * @param scene defines the current scene
  100166. * @param rootUrl defines the root URL containing the effect layer information
  100167. * @returns a parsed effect Layer
  100168. */
  100169. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  100170. }
  100171. }
  100172. declare module BABYLON {
  100173. interface AbstractScene {
  100174. /**
  100175. * The list of effect layers (highlights/glow) added to the scene
  100176. * @see http://doc.babylonjs.com/how_to/highlight_layer
  100177. * @see http://doc.babylonjs.com/how_to/glow_layer
  100178. */
  100179. effectLayers: Array<EffectLayer>;
  100180. /**
  100181. * Removes the given effect layer from this scene.
  100182. * @param toRemove defines the effect layer to remove
  100183. * @returns the index of the removed effect layer
  100184. */
  100185. removeEffectLayer(toRemove: EffectLayer): number;
  100186. /**
  100187. * Adds the given effect layer to this scene
  100188. * @param newEffectLayer defines the effect layer to add
  100189. */
  100190. addEffectLayer(newEffectLayer: EffectLayer): void;
  100191. }
  100192. /**
  100193. * Defines the layer scene component responsible to manage any effect layers
  100194. * in a given scene.
  100195. */
  100196. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  100197. /**
  100198. * The component name helpfull to identify the component in the list of scene components.
  100199. */
  100200. readonly name: string;
  100201. /**
  100202. * The scene the component belongs to.
  100203. */
  100204. scene: Scene;
  100205. private _engine;
  100206. private _renderEffects;
  100207. private _needStencil;
  100208. private _previousStencilState;
  100209. /**
  100210. * Creates a new instance of the component for the given scene
  100211. * @param scene Defines the scene to register the component in
  100212. */
  100213. constructor(scene: Scene);
  100214. /**
  100215. * Registers the component in a given scene
  100216. */
  100217. register(): void;
  100218. /**
  100219. * Rebuilds the elements related to this component in case of
  100220. * context lost for instance.
  100221. */
  100222. rebuild(): void;
  100223. /**
  100224. * Serializes the component data to the specified json object
  100225. * @param serializationObject The object to serialize to
  100226. */
  100227. serialize(serializationObject: any): void;
  100228. /**
  100229. * Adds all the element from the container to the scene
  100230. * @param container the container holding the elements
  100231. */
  100232. addFromContainer(container: AbstractScene): void;
  100233. /**
  100234. * Removes all the elements in the container from the scene
  100235. * @param container contains the elements to remove
  100236. */
  100237. removeFromContainer(container: AbstractScene): void;
  100238. /**
  100239. * Disposes the component and the associated ressources.
  100240. */
  100241. dispose(): void;
  100242. private _isReadyForMesh;
  100243. private _renderMainTexture;
  100244. private _setStencil;
  100245. private _setStencilBack;
  100246. private _draw;
  100247. private _drawCamera;
  100248. private _drawRenderingGroup;
  100249. }
  100250. }
  100251. declare module BABYLON {
  100252. /** @hidden */
  100253. export var glowMapMergePixelShader: {
  100254. name: string;
  100255. shader: string;
  100256. };
  100257. }
  100258. declare module BABYLON {
  100259. /** @hidden */
  100260. export var glowMapMergeVertexShader: {
  100261. name: string;
  100262. shader: string;
  100263. };
  100264. }
  100265. declare module BABYLON {
  100266. interface AbstractScene {
  100267. /**
  100268. * Return a the first highlight layer of the scene with a given name.
  100269. * @param name The name of the highlight layer to look for.
  100270. * @return The highlight layer if found otherwise null.
  100271. */
  100272. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  100273. }
  100274. /**
  100275. * Glow layer options. This helps customizing the behaviour
  100276. * of the glow layer.
  100277. */
  100278. export interface IGlowLayerOptions {
  100279. /**
  100280. * Multiplication factor apply to the canvas size to compute the render target size
  100281. * used to generated the glowing objects (the smaller the faster).
  100282. */
  100283. mainTextureRatio: number;
  100284. /**
  100285. * Enforces a fixed size texture to ensure resize independant blur.
  100286. */
  100287. mainTextureFixedSize?: number;
  100288. /**
  100289. * How big is the kernel of the blur texture.
  100290. */
  100291. blurKernelSize: number;
  100292. /**
  100293. * The camera attached to the layer.
  100294. */
  100295. camera: Nullable<Camera>;
  100296. /**
  100297. * Enable MSAA by chosing the number of samples.
  100298. */
  100299. mainTextureSamples?: number;
  100300. /**
  100301. * The rendering group to draw the layer in.
  100302. */
  100303. renderingGroupId: number;
  100304. }
  100305. /**
  100306. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  100307. *
  100308. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  100309. * glowy meshes to your scene.
  100310. *
  100311. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  100312. */
  100313. export class GlowLayer extends EffectLayer {
  100314. /**
  100315. * Effect Name of the layer.
  100316. */
  100317. static readonly EffectName: string;
  100318. /**
  100319. * The default blur kernel size used for the glow.
  100320. */
  100321. static DefaultBlurKernelSize: number;
  100322. /**
  100323. * The default texture size ratio used for the glow.
  100324. */
  100325. static DefaultTextureRatio: number;
  100326. /**
  100327. * Sets the kernel size of the blur.
  100328. */
  100329. /**
  100330. * Gets the kernel size of the blur.
  100331. */
  100332. blurKernelSize: number;
  100333. /**
  100334. * Sets the glow intensity.
  100335. */
  100336. /**
  100337. * Gets the glow intensity.
  100338. */
  100339. intensity: number;
  100340. private _options;
  100341. private _intensity;
  100342. private _horizontalBlurPostprocess1;
  100343. private _verticalBlurPostprocess1;
  100344. private _horizontalBlurPostprocess2;
  100345. private _verticalBlurPostprocess2;
  100346. private _blurTexture1;
  100347. private _blurTexture2;
  100348. private _postProcesses1;
  100349. private _postProcesses2;
  100350. private _includedOnlyMeshes;
  100351. private _excludedMeshes;
  100352. /**
  100353. * Callback used to let the user override the color selection on a per mesh basis
  100354. */
  100355. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  100356. /**
  100357. * Callback used to let the user override the texture selection on a per mesh basis
  100358. */
  100359. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  100360. /**
  100361. * Instantiates a new glow Layer and references it to the scene.
  100362. * @param name The name of the layer
  100363. * @param scene The scene to use the layer in
  100364. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  100365. */
  100366. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  100367. /**
  100368. * Get the effect name of the layer.
  100369. * @return The effect name
  100370. */
  100371. getEffectName(): string;
  100372. /**
  100373. * Create the merge effect. This is the shader use to blit the information back
  100374. * to the main canvas at the end of the scene rendering.
  100375. */
  100376. protected _createMergeEffect(): Effect;
  100377. /**
  100378. * Creates the render target textures and post processes used in the glow layer.
  100379. */
  100380. protected _createTextureAndPostProcesses(): void;
  100381. /**
  100382. * Checks for the readiness of the element composing the layer.
  100383. * @param subMesh the mesh to check for
  100384. * @param useInstances specify wether or not to use instances to render the mesh
  100385. * @param emissiveTexture the associated emissive texture used to generate the glow
  100386. * @return true if ready otherwise, false
  100387. */
  100388. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  100389. /**
  100390. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  100391. */
  100392. needStencil(): boolean;
  100393. /**
  100394. * Returns true if the mesh can be rendered, otherwise false.
  100395. * @param mesh The mesh to render
  100396. * @param material The material used on the mesh
  100397. * @returns true if it can be rendered otherwise false
  100398. */
  100399. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  100400. /**
  100401. * Implementation specific of rendering the generating effect on the main canvas.
  100402. * @param effect The effect used to render through
  100403. */
  100404. protected _internalRender(effect: Effect): void;
  100405. /**
  100406. * Sets the required values for both the emissive texture and and the main color.
  100407. */
  100408. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  100409. /**
  100410. * Returns true if the mesh should render, otherwise false.
  100411. * @param mesh The mesh to render
  100412. * @returns true if it should render otherwise false
  100413. */
  100414. protected _shouldRenderMesh(mesh: Mesh): boolean;
  100415. /**
  100416. * Adds specific effects defines.
  100417. * @param defines The defines to add specifics to.
  100418. */
  100419. protected _addCustomEffectDefines(defines: string[]): void;
  100420. /**
  100421. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  100422. * @param mesh The mesh to exclude from the glow layer
  100423. */
  100424. addExcludedMesh(mesh: Mesh): void;
  100425. /**
  100426. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  100427. * @param mesh The mesh to remove
  100428. */
  100429. removeExcludedMesh(mesh: Mesh): void;
  100430. /**
  100431. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  100432. * @param mesh The mesh to include in the glow layer
  100433. */
  100434. addIncludedOnlyMesh(mesh: Mesh): void;
  100435. /**
  100436. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  100437. * @param mesh The mesh to remove
  100438. */
  100439. removeIncludedOnlyMesh(mesh: Mesh): void;
  100440. /**
  100441. * Determine if a given mesh will be used in the glow layer
  100442. * @param mesh The mesh to test
  100443. * @returns true if the mesh will be highlighted by the current glow layer
  100444. */
  100445. hasMesh(mesh: AbstractMesh): boolean;
  100446. /**
  100447. * Free any resources and references associated to a mesh.
  100448. * Internal use
  100449. * @param mesh The mesh to free.
  100450. * @hidden
  100451. */
  100452. _disposeMesh(mesh: Mesh): void;
  100453. /**
  100454. * Gets the class name of the effect layer
  100455. * @returns the string with the class name of the effect layer
  100456. */
  100457. getClassName(): string;
  100458. /**
  100459. * Serializes this glow layer
  100460. * @returns a serialized glow layer object
  100461. */
  100462. serialize(): any;
  100463. /**
  100464. * Creates a Glow Layer from parsed glow layer data
  100465. * @param parsedGlowLayer defines glow layer data
  100466. * @param scene defines the current scene
  100467. * @param rootUrl defines the root URL containing the glow layer information
  100468. * @returns a parsed Glow Layer
  100469. */
  100470. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  100471. }
  100472. }
  100473. declare module BABYLON {
  100474. /** @hidden */
  100475. export var glowBlurPostProcessPixelShader: {
  100476. name: string;
  100477. shader: string;
  100478. };
  100479. }
  100480. declare module BABYLON {
  100481. interface AbstractScene {
  100482. /**
  100483. * Return a the first highlight layer of the scene with a given name.
  100484. * @param name The name of the highlight layer to look for.
  100485. * @return The highlight layer if found otherwise null.
  100486. */
  100487. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  100488. }
  100489. /**
  100490. * Highlight layer options. This helps customizing the behaviour
  100491. * of the highlight layer.
  100492. */
  100493. export interface IHighlightLayerOptions {
  100494. /**
  100495. * Multiplication factor apply to the canvas size to compute the render target size
  100496. * used to generated the glowing objects (the smaller the faster).
  100497. */
  100498. mainTextureRatio: number;
  100499. /**
  100500. * Enforces a fixed size texture to ensure resize independant blur.
  100501. */
  100502. mainTextureFixedSize?: number;
  100503. /**
  100504. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  100505. * of the picture to blur (the smaller the faster).
  100506. */
  100507. blurTextureSizeRatio: number;
  100508. /**
  100509. * How big in texel of the blur texture is the vertical blur.
  100510. */
  100511. blurVerticalSize: number;
  100512. /**
  100513. * How big in texel of the blur texture is the horizontal blur.
  100514. */
  100515. blurHorizontalSize: number;
  100516. /**
  100517. * Alpha blending mode used to apply the blur. Default is combine.
  100518. */
  100519. alphaBlendingMode: number;
  100520. /**
  100521. * The camera attached to the layer.
  100522. */
  100523. camera: Nullable<Camera>;
  100524. /**
  100525. * Should we display highlight as a solid stroke?
  100526. */
  100527. isStroke?: boolean;
  100528. /**
  100529. * The rendering group to draw the layer in.
  100530. */
  100531. renderingGroupId: number;
  100532. }
  100533. /**
  100534. * The highlight layer Helps adding a glow effect around a mesh.
  100535. *
  100536. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  100537. * glowy meshes to your scene.
  100538. *
  100539. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  100540. */
  100541. export class HighlightLayer extends EffectLayer {
  100542. name: string;
  100543. /**
  100544. * Effect Name of the highlight layer.
  100545. */
  100546. static readonly EffectName: string;
  100547. /**
  100548. * The neutral color used during the preparation of the glow effect.
  100549. * This is black by default as the blend operation is a blend operation.
  100550. */
  100551. static NeutralColor: Color4;
  100552. /**
  100553. * Stencil value used for glowing meshes.
  100554. */
  100555. static GlowingMeshStencilReference: number;
  100556. /**
  100557. * Stencil value used for the other meshes in the scene.
  100558. */
  100559. static NormalMeshStencilReference: number;
  100560. /**
  100561. * Specifies whether or not the inner glow is ACTIVE in the layer.
  100562. */
  100563. innerGlow: boolean;
  100564. /**
  100565. * Specifies whether or not the outer glow is ACTIVE in the layer.
  100566. */
  100567. outerGlow: boolean;
  100568. /**
  100569. * Specifies the horizontal size of the blur.
  100570. */
  100571. /**
  100572. * Gets the horizontal size of the blur.
  100573. */
  100574. blurHorizontalSize: number;
  100575. /**
  100576. * Specifies the vertical size of the blur.
  100577. */
  100578. /**
  100579. * Gets the vertical size of the blur.
  100580. */
  100581. blurVerticalSize: number;
  100582. /**
  100583. * An event triggered when the highlight layer is being blurred.
  100584. */
  100585. onBeforeBlurObservable: Observable<HighlightLayer>;
  100586. /**
  100587. * An event triggered when the highlight layer has been blurred.
  100588. */
  100589. onAfterBlurObservable: Observable<HighlightLayer>;
  100590. private _instanceGlowingMeshStencilReference;
  100591. private _options;
  100592. private _downSamplePostprocess;
  100593. private _horizontalBlurPostprocess;
  100594. private _verticalBlurPostprocess;
  100595. private _blurTexture;
  100596. private _meshes;
  100597. private _excludedMeshes;
  100598. /**
  100599. * Instantiates a new highlight Layer and references it to the scene..
  100600. * @param name The name of the layer
  100601. * @param scene The scene to use the layer in
  100602. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  100603. */
  100604. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  100605. /**
  100606. * Get the effect name of the layer.
  100607. * @return The effect name
  100608. */
  100609. getEffectName(): string;
  100610. /**
  100611. * Create the merge effect. This is the shader use to blit the information back
  100612. * to the main canvas at the end of the scene rendering.
  100613. */
  100614. protected _createMergeEffect(): Effect;
  100615. /**
  100616. * Creates the render target textures and post processes used in the highlight layer.
  100617. */
  100618. protected _createTextureAndPostProcesses(): void;
  100619. /**
  100620. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  100621. */
  100622. needStencil(): boolean;
  100623. /**
  100624. * Checks for the readiness of the element composing the layer.
  100625. * @param subMesh the mesh to check for
  100626. * @param useInstances specify wether or not to use instances to render the mesh
  100627. * @param emissiveTexture the associated emissive texture used to generate the glow
  100628. * @return true if ready otherwise, false
  100629. */
  100630. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  100631. /**
  100632. * Implementation specific of rendering the generating effect on the main canvas.
  100633. * @param effect The effect used to render through
  100634. */
  100635. protected _internalRender(effect: Effect): void;
  100636. /**
  100637. * Returns true if the layer contains information to display, otherwise false.
  100638. */
  100639. shouldRender(): boolean;
  100640. /**
  100641. * Returns true if the mesh should render, otherwise false.
  100642. * @param mesh The mesh to render
  100643. * @returns true if it should render otherwise false
  100644. */
  100645. protected _shouldRenderMesh(mesh: Mesh): boolean;
  100646. /**
  100647. * Sets the required values for both the emissive texture and and the main color.
  100648. */
  100649. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  100650. /**
  100651. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  100652. * @param mesh The mesh to exclude from the highlight layer
  100653. */
  100654. addExcludedMesh(mesh: Mesh): void;
  100655. /**
  100656. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  100657. * @param mesh The mesh to highlight
  100658. */
  100659. removeExcludedMesh(mesh: Mesh): void;
  100660. /**
  100661. * Determine if a given mesh will be highlighted by the current HighlightLayer
  100662. * @param mesh mesh to test
  100663. * @returns true if the mesh will be highlighted by the current HighlightLayer
  100664. */
  100665. hasMesh(mesh: AbstractMesh): boolean;
  100666. /**
  100667. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  100668. * @param mesh The mesh to highlight
  100669. * @param color The color of the highlight
  100670. * @param glowEmissiveOnly Extract the glow from the emissive texture
  100671. */
  100672. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  100673. /**
  100674. * Remove a mesh from the highlight layer in order to make it stop glowing.
  100675. * @param mesh The mesh to highlight
  100676. */
  100677. removeMesh(mesh: Mesh): void;
  100678. /**
  100679. * Force the stencil to the normal expected value for none glowing parts
  100680. */
  100681. private _defaultStencilReference;
  100682. /**
  100683. * Free any resources and references associated to a mesh.
  100684. * Internal use
  100685. * @param mesh The mesh to free.
  100686. * @hidden
  100687. */
  100688. _disposeMesh(mesh: Mesh): void;
  100689. /**
  100690. * Dispose the highlight layer and free resources.
  100691. */
  100692. dispose(): void;
  100693. /**
  100694. * Gets the class name of the effect layer
  100695. * @returns the string with the class name of the effect layer
  100696. */
  100697. getClassName(): string;
  100698. /**
  100699. * Serializes this Highlight layer
  100700. * @returns a serialized Highlight layer object
  100701. */
  100702. serialize(): any;
  100703. /**
  100704. * Creates a Highlight layer from parsed Highlight layer data
  100705. * @param parsedHightlightLayer defines the Highlight layer data
  100706. * @param scene defines the current scene
  100707. * @param rootUrl defines the root URL containing the Highlight layer information
  100708. * @returns a parsed Highlight layer
  100709. */
  100710. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  100711. }
  100712. }
  100713. declare module BABYLON {
  100714. /** @hidden */
  100715. export var lensFlarePixelShader: {
  100716. name: string;
  100717. shader: string;
  100718. };
  100719. }
  100720. declare module BABYLON {
  100721. /** @hidden */
  100722. export var lensFlareVertexShader: {
  100723. name: string;
  100724. shader: string;
  100725. };
  100726. }
  100727. declare module BABYLON {
  100728. /**
  100729. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  100730. * It is usually composed of several `lensFlare`.
  100731. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100732. */
  100733. export class LensFlareSystem {
  100734. /**
  100735. * Define the name of the lens flare system
  100736. */
  100737. name: string;
  100738. /**
  100739. * List of lens flares used in this system.
  100740. */
  100741. lensFlares: LensFlare[];
  100742. /**
  100743. * Define a limit from the border the lens flare can be visible.
  100744. */
  100745. borderLimit: number;
  100746. /**
  100747. * Define a viewport border we do not want to see the lens flare in.
  100748. */
  100749. viewportBorder: number;
  100750. /**
  100751. * Define a predicate which could limit the list of meshes able to occlude the effect.
  100752. */
  100753. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  100754. /**
  100755. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  100756. */
  100757. layerMask: number;
  100758. /**
  100759. * Define the id of the lens flare system in the scene.
  100760. * (equal to name by default)
  100761. */
  100762. id: string;
  100763. private _scene;
  100764. private _emitter;
  100765. private _vertexBuffers;
  100766. private _indexBuffer;
  100767. private _effect;
  100768. private _positionX;
  100769. private _positionY;
  100770. private _isEnabled;
  100771. /** @hidden */
  100772. static _SceneComponentInitialization: (scene: Scene) => void;
  100773. /**
  100774. * Instantiates a lens flare system.
  100775. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  100776. * It is usually composed of several `lensFlare`.
  100777. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100778. * @param name Define the name of the lens flare system in the scene
  100779. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  100780. * @param scene Define the scene the lens flare system belongs to
  100781. */
  100782. constructor(
  100783. /**
  100784. * Define the name of the lens flare system
  100785. */
  100786. name: string, emitter: any, scene: Scene);
  100787. /**
  100788. * Define if the lens flare system is enabled.
  100789. */
  100790. isEnabled: boolean;
  100791. /**
  100792. * Get the scene the effects belongs to.
  100793. * @returns the scene holding the lens flare system
  100794. */
  100795. getScene(): Scene;
  100796. /**
  100797. * Get the emitter of the lens flare system.
  100798. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  100799. * @returns the emitter of the lens flare system
  100800. */
  100801. getEmitter(): any;
  100802. /**
  100803. * Set the emitter of the lens flare system.
  100804. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  100805. * @param newEmitter Define the new emitter of the system
  100806. */
  100807. setEmitter(newEmitter: any): void;
  100808. /**
  100809. * Get the lens flare system emitter position.
  100810. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  100811. * @returns the position
  100812. */
  100813. getEmitterPosition(): Vector3;
  100814. /**
  100815. * @hidden
  100816. */
  100817. computeEffectivePosition(globalViewport: Viewport): boolean;
  100818. /** @hidden */
  100819. _isVisible(): boolean;
  100820. /**
  100821. * @hidden
  100822. */
  100823. render(): boolean;
  100824. /**
  100825. * Dispose and release the lens flare with its associated resources.
  100826. */
  100827. dispose(): void;
  100828. /**
  100829. * Parse a lens flare system from a JSON repressentation
  100830. * @param parsedLensFlareSystem Define the JSON to parse
  100831. * @param scene Define the scene the parsed system should be instantiated in
  100832. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  100833. * @returns the parsed system
  100834. */
  100835. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  100836. /**
  100837. * Serialize the current Lens Flare System into a JSON representation.
  100838. * @returns the serialized JSON
  100839. */
  100840. serialize(): any;
  100841. }
  100842. }
  100843. declare module BABYLON {
  100844. /**
  100845. * This represents one of the lens effect in a `lensFlareSystem`.
  100846. * It controls one of the indiviual texture used in the effect.
  100847. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100848. */
  100849. export class LensFlare {
  100850. /**
  100851. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  100852. */
  100853. size: number;
  100854. /**
  100855. * 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.
  100856. */
  100857. position: number;
  100858. /**
  100859. * Define the lens color.
  100860. */
  100861. color: Color3;
  100862. /**
  100863. * Define the lens texture.
  100864. */
  100865. texture: Nullable<Texture>;
  100866. /**
  100867. * Define the alpha mode to render this particular lens.
  100868. */
  100869. alphaMode: number;
  100870. private _system;
  100871. /**
  100872. * Creates a new Lens Flare.
  100873. * This represents one of the lens effect in a `lensFlareSystem`.
  100874. * It controls one of the indiviual texture used in the effect.
  100875. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100876. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  100877. * @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.
  100878. * @param color Define the lens color
  100879. * @param imgUrl Define the lens texture url
  100880. * @param system Define the `lensFlareSystem` this flare is part of
  100881. * @returns The newly created Lens Flare
  100882. */
  100883. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  100884. /**
  100885. * Instantiates a new Lens Flare.
  100886. * This represents one of the lens effect in a `lensFlareSystem`.
  100887. * It controls one of the indiviual texture used in the effect.
  100888. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100889. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  100890. * @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.
  100891. * @param color Define the lens color
  100892. * @param imgUrl Define the lens texture url
  100893. * @param system Define the `lensFlareSystem` this flare is part of
  100894. */
  100895. constructor(
  100896. /**
  100897. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  100898. */
  100899. size: number,
  100900. /**
  100901. * 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.
  100902. */
  100903. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  100904. /**
  100905. * Dispose and release the lens flare with its associated resources.
  100906. */
  100907. dispose(): void;
  100908. }
  100909. }
  100910. declare module BABYLON {
  100911. interface AbstractScene {
  100912. /**
  100913. * The list of lens flare system added to the scene
  100914. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100915. */
  100916. lensFlareSystems: Array<LensFlareSystem>;
  100917. /**
  100918. * Removes the given lens flare system from this scene.
  100919. * @param toRemove The lens flare system to remove
  100920. * @returns The index of the removed lens flare system
  100921. */
  100922. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  100923. /**
  100924. * Adds the given lens flare system to this scene
  100925. * @param newLensFlareSystem The lens flare system to add
  100926. */
  100927. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  100928. /**
  100929. * Gets a lens flare system using its name
  100930. * @param name defines the name to look for
  100931. * @returns the lens flare system or null if not found
  100932. */
  100933. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  100934. /**
  100935. * Gets a lens flare system using its id
  100936. * @param id defines the id to look for
  100937. * @returns the lens flare system or null if not found
  100938. */
  100939. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  100940. }
  100941. /**
  100942. * Defines the lens flare scene component responsible to manage any lens flares
  100943. * in a given scene.
  100944. */
  100945. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  100946. /**
  100947. * The component name helpfull to identify the component in the list of scene components.
  100948. */
  100949. readonly name: string;
  100950. /**
  100951. * The scene the component belongs to.
  100952. */
  100953. scene: Scene;
  100954. /**
  100955. * Creates a new instance of the component for the given scene
  100956. * @param scene Defines the scene to register the component in
  100957. */
  100958. constructor(scene: Scene);
  100959. /**
  100960. * Registers the component in a given scene
  100961. */
  100962. register(): void;
  100963. /**
  100964. * Rebuilds the elements related to this component in case of
  100965. * context lost for instance.
  100966. */
  100967. rebuild(): void;
  100968. /**
  100969. * Adds all the element from the container to the scene
  100970. * @param container the container holding the elements
  100971. */
  100972. addFromContainer(container: AbstractScene): void;
  100973. /**
  100974. * Removes all the elements in the container from the scene
  100975. * @param container contains the elements to remove
  100976. */
  100977. removeFromContainer(container: AbstractScene): void;
  100978. /**
  100979. * Serializes the component data to the specified json object
  100980. * @param serializationObject The object to serialize to
  100981. */
  100982. serialize(serializationObject: any): void;
  100983. /**
  100984. * Disposes the component and the associated ressources.
  100985. */
  100986. dispose(): void;
  100987. private _draw;
  100988. }
  100989. }
  100990. declare module BABYLON {
  100991. /**
  100992. * Defines the shadow generator component responsible to manage any shadow generators
  100993. * in a given scene.
  100994. */
  100995. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  100996. /**
  100997. * The component name helpfull to identify the component in the list of scene components.
  100998. */
  100999. readonly name: string;
  101000. /**
  101001. * The scene the component belongs to.
  101002. */
  101003. scene: Scene;
  101004. /**
  101005. * Creates a new instance of the component for the given scene
  101006. * @param scene Defines the scene to register the component in
  101007. */
  101008. constructor(scene: Scene);
  101009. /**
  101010. * Registers the component in a given scene
  101011. */
  101012. register(): void;
  101013. /**
  101014. * Rebuilds the elements related to this component in case of
  101015. * context lost for instance.
  101016. */
  101017. rebuild(): void;
  101018. /**
  101019. * Serializes the component data to the specified json object
  101020. * @param serializationObject The object to serialize to
  101021. */
  101022. serialize(serializationObject: any): void;
  101023. /**
  101024. * Adds all the element from the container to the scene
  101025. * @param container the container holding the elements
  101026. */
  101027. addFromContainer(container: AbstractScene): void;
  101028. /**
  101029. * Removes all the elements in the container from the scene
  101030. * @param container contains the elements to remove
  101031. */
  101032. removeFromContainer(container: AbstractScene): void;
  101033. /**
  101034. * Rebuilds the elements related to this component in case of
  101035. * context lost for instance.
  101036. */
  101037. dispose(): void;
  101038. private _gatherRenderTargets;
  101039. }
  101040. }
  101041. declare module BABYLON {
  101042. /**
  101043. * A directional light is defined by a direction (what a surprise!).
  101044. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  101045. * 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.
  101046. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101047. */
  101048. export class DirectionalLight extends ShadowLight {
  101049. private _shadowFrustumSize;
  101050. /**
  101051. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  101052. */
  101053. /**
  101054. * Specifies a fix frustum size for the shadow generation.
  101055. */
  101056. shadowFrustumSize: number;
  101057. private _shadowOrthoScale;
  101058. /**
  101059. * Gets the shadow projection scale against the optimal computed one.
  101060. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101061. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101062. */
  101063. /**
  101064. * Sets the shadow projection scale against the optimal computed one.
  101065. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101066. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101067. */
  101068. shadowOrthoScale: number;
  101069. /**
  101070. * Automatically compute the projection matrix to best fit (including all the casters)
  101071. * on each frame.
  101072. */
  101073. autoUpdateExtends: boolean;
  101074. private _orthoLeft;
  101075. private _orthoRight;
  101076. private _orthoTop;
  101077. private _orthoBottom;
  101078. /**
  101079. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  101080. * The directional light is emitted from everywhere in the given direction.
  101081. * It can cast shadows.
  101082. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101083. * @param name The friendly name of the light
  101084. * @param direction The direction of the light
  101085. * @param scene The scene the light belongs to
  101086. */
  101087. constructor(name: string, direction: Vector3, scene: Scene);
  101088. /**
  101089. * Returns the string "DirectionalLight".
  101090. * @return The class name
  101091. */
  101092. getClassName(): string;
  101093. /**
  101094. * Returns the integer 1.
  101095. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101096. */
  101097. getTypeID(): number;
  101098. /**
  101099. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  101100. * Returns the DirectionalLight Shadow projection matrix.
  101101. */
  101102. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101103. /**
  101104. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  101105. * Returns the DirectionalLight Shadow projection matrix.
  101106. */
  101107. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  101108. /**
  101109. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  101110. * Returns the DirectionalLight Shadow projection matrix.
  101111. */
  101112. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101113. protected _buildUniformLayout(): void;
  101114. /**
  101115. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  101116. * @param effect The effect to update
  101117. * @param lightIndex The index of the light in the effect to update
  101118. * @returns The directional light
  101119. */
  101120. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  101121. /**
  101122. * Gets the minZ used for shadow according to both the scene and the light.
  101123. *
  101124. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101125. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101126. * @param activeCamera The camera we are returning the min for
  101127. * @returns the depth min z
  101128. */
  101129. getDepthMinZ(activeCamera: Camera): number;
  101130. /**
  101131. * Gets the maxZ used for shadow according to both the scene and the light.
  101132. *
  101133. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101134. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101135. * @param activeCamera The camera we are returning the max for
  101136. * @returns the depth max z
  101137. */
  101138. getDepthMaxZ(activeCamera: Camera): number;
  101139. /**
  101140. * Prepares the list of defines specific to the light type.
  101141. * @param defines the list of defines
  101142. * @param lightIndex defines the index of the light for the effect
  101143. */
  101144. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101145. }
  101146. }
  101147. declare module BABYLON {
  101148. /**
  101149. * A point light is a light defined by an unique point in world space.
  101150. * The light is emitted in every direction from this point.
  101151. * A good example of a point light is a standard light bulb.
  101152. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101153. */
  101154. export class PointLight extends ShadowLight {
  101155. private _shadowAngle;
  101156. /**
  101157. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101158. * This specifies what angle the shadow will use to be created.
  101159. *
  101160. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  101161. */
  101162. /**
  101163. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101164. * This specifies what angle the shadow will use to be created.
  101165. *
  101166. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  101167. */
  101168. shadowAngle: number;
  101169. /**
  101170. * Gets the direction if it has been set.
  101171. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101172. */
  101173. /**
  101174. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101175. */
  101176. direction: Vector3;
  101177. /**
  101178. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  101179. * A PointLight emits the light in every direction.
  101180. * It can cast shadows.
  101181. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  101182. * ```javascript
  101183. * var pointLight = new PointLight("pl", camera.position, scene);
  101184. * ```
  101185. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101186. * @param name The light friendly name
  101187. * @param position The position of the point light in the scene
  101188. * @param scene The scene the lights belongs to
  101189. */
  101190. constructor(name: string, position: Vector3, scene: Scene);
  101191. /**
  101192. * Returns the string "PointLight"
  101193. * @returns the class name
  101194. */
  101195. getClassName(): string;
  101196. /**
  101197. * Returns the integer 0.
  101198. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101199. */
  101200. getTypeID(): number;
  101201. /**
  101202. * Specifies wether or not the shadowmap should be a cube texture.
  101203. * @returns true if the shadowmap needs to be a cube texture.
  101204. */
  101205. needCube(): boolean;
  101206. /**
  101207. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  101208. * @param faceIndex The index of the face we are computed the direction to generate shadow
  101209. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  101210. */
  101211. getShadowDirection(faceIndex?: number): Vector3;
  101212. /**
  101213. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  101214. * - fov = PI / 2
  101215. * - aspect ratio : 1.0
  101216. * - z-near and far equal to the active camera minZ and maxZ.
  101217. * Returns the PointLight.
  101218. */
  101219. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101220. protected _buildUniformLayout(): void;
  101221. /**
  101222. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  101223. * @param effect The effect to update
  101224. * @param lightIndex The index of the light in the effect to update
  101225. * @returns The point light
  101226. */
  101227. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  101228. /**
  101229. * Prepares the list of defines specific to the light type.
  101230. * @param defines the list of defines
  101231. * @param lightIndex defines the index of the light for the effect
  101232. */
  101233. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101234. }
  101235. }
  101236. declare module BABYLON {
  101237. /**
  101238. * A spot light is defined by a position, a direction, an angle, and an exponent.
  101239. * These values define a cone of light starting from the position, emitting toward the direction.
  101240. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  101241. * and the exponent defines the speed of the decay of the light with distance (reach).
  101242. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101243. */
  101244. export class SpotLight extends ShadowLight {
  101245. private _angle;
  101246. private _innerAngle;
  101247. private _cosHalfAngle;
  101248. private _lightAngleScale;
  101249. private _lightAngleOffset;
  101250. /**
  101251. * Gets the cone angle of the spot light in Radians.
  101252. */
  101253. /**
  101254. * Sets the cone angle of the spot light in Radians.
  101255. */
  101256. angle: number;
  101257. /**
  101258. * Only used in gltf falloff mode, this defines the angle where
  101259. * the directional falloff will start before cutting at angle which could be seen
  101260. * as outer angle.
  101261. */
  101262. /**
  101263. * Only used in gltf falloff mode, this defines the angle where
  101264. * the directional falloff will start before cutting at angle which could be seen
  101265. * as outer angle.
  101266. */
  101267. innerAngle: number;
  101268. private _shadowAngleScale;
  101269. /**
  101270. * Allows scaling the angle of the light for shadow generation only.
  101271. */
  101272. /**
  101273. * Allows scaling the angle of the light for shadow generation only.
  101274. */
  101275. shadowAngleScale: number;
  101276. /**
  101277. * The light decay speed with the distance from the emission spot.
  101278. */
  101279. exponent: number;
  101280. private _projectionTextureMatrix;
  101281. /**
  101282. * Allows reading the projecton texture
  101283. */
  101284. readonly projectionTextureMatrix: Matrix;
  101285. protected _projectionTextureLightNear: number;
  101286. /**
  101287. * Gets the near clip of the Spotlight for texture projection.
  101288. */
  101289. /**
  101290. * Sets the near clip of the Spotlight for texture projection.
  101291. */
  101292. projectionTextureLightNear: number;
  101293. protected _projectionTextureLightFar: number;
  101294. /**
  101295. * Gets the far clip of the Spotlight for texture projection.
  101296. */
  101297. /**
  101298. * Sets the far clip of the Spotlight for texture projection.
  101299. */
  101300. projectionTextureLightFar: number;
  101301. protected _projectionTextureUpDirection: Vector3;
  101302. /**
  101303. * Gets the Up vector of the Spotlight for texture projection.
  101304. */
  101305. /**
  101306. * Sets the Up vector of the Spotlight for texture projection.
  101307. */
  101308. projectionTextureUpDirection: Vector3;
  101309. private _projectionTexture;
  101310. /**
  101311. * Gets the projection texture of the light.
  101312. */
  101313. /**
  101314. * Sets the projection texture of the light.
  101315. */
  101316. projectionTexture: Nullable<BaseTexture>;
  101317. private _projectionTextureViewLightDirty;
  101318. private _projectionTextureProjectionLightDirty;
  101319. private _projectionTextureDirty;
  101320. private _projectionTextureViewTargetVector;
  101321. private _projectionTextureViewLightMatrix;
  101322. private _projectionTextureProjectionLightMatrix;
  101323. private _projectionTextureScalingMatrix;
  101324. /**
  101325. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  101326. * It can cast shadows.
  101327. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101328. * @param name The light friendly name
  101329. * @param position The position of the spot light in the scene
  101330. * @param direction The direction of the light in the scene
  101331. * @param angle The cone angle of the light in Radians
  101332. * @param exponent The light decay speed with the distance from the emission spot
  101333. * @param scene The scene the lights belongs to
  101334. */
  101335. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  101336. /**
  101337. * Returns the string "SpotLight".
  101338. * @returns the class name
  101339. */
  101340. getClassName(): string;
  101341. /**
  101342. * Returns the integer 2.
  101343. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101344. */
  101345. getTypeID(): number;
  101346. /**
  101347. * Overrides the direction setter to recompute the projection texture view light Matrix.
  101348. */
  101349. protected _setDirection(value: Vector3): void;
  101350. /**
  101351. * Overrides the position setter to recompute the projection texture view light Matrix.
  101352. */
  101353. protected _setPosition(value: Vector3): void;
  101354. /**
  101355. * 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.
  101356. * Returns the SpotLight.
  101357. */
  101358. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101359. protected _computeProjectionTextureViewLightMatrix(): void;
  101360. protected _computeProjectionTextureProjectionLightMatrix(): void;
  101361. /**
  101362. * Main function for light texture projection matrix computing.
  101363. */
  101364. protected _computeProjectionTextureMatrix(): void;
  101365. protected _buildUniformLayout(): void;
  101366. private _computeAngleValues;
  101367. /**
  101368. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  101369. * @param effect The effect to update
  101370. * @param lightIndex The index of the light in the effect to update
  101371. * @returns The spot light
  101372. */
  101373. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  101374. /**
  101375. * Disposes the light and the associated resources.
  101376. */
  101377. dispose(): void;
  101378. /**
  101379. * Prepares the list of defines specific to the light type.
  101380. * @param defines the list of defines
  101381. * @param lightIndex defines the index of the light for the effect
  101382. */
  101383. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101384. }
  101385. }
  101386. declare module BABYLON {
  101387. /**
  101388. * Header information of HDR texture files.
  101389. */
  101390. export interface HDRInfo {
  101391. /**
  101392. * The height of the texture in pixels.
  101393. */
  101394. height: number;
  101395. /**
  101396. * The width of the texture in pixels.
  101397. */
  101398. width: number;
  101399. /**
  101400. * The index of the beginning of the data in the binary file.
  101401. */
  101402. dataPosition: number;
  101403. }
  101404. /**
  101405. * This groups tools to convert HDR texture to native colors array.
  101406. */
  101407. export class HDRTools {
  101408. private static Ldexp;
  101409. private static Rgbe2float;
  101410. private static readStringLine;
  101411. /**
  101412. * Reads header information from an RGBE texture stored in a native array.
  101413. * More information on this format are available here:
  101414. * https://en.wikipedia.org/wiki/RGBE_image_format
  101415. *
  101416. * @param uint8array The binary file stored in native array.
  101417. * @return The header information.
  101418. */
  101419. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  101420. /**
  101421. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  101422. * This RGBE texture needs to store the information as a panorama.
  101423. *
  101424. * More information on this format are available here:
  101425. * https://en.wikipedia.org/wiki/RGBE_image_format
  101426. *
  101427. * @param buffer The binary file stored in an array buffer.
  101428. * @param size The expected size of the extracted cubemap.
  101429. * @return The Cube Map information.
  101430. */
  101431. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  101432. /**
  101433. * Returns the pixels data extracted from an RGBE texture.
  101434. * This pixels will be stored left to right up to down in the R G B order in one array.
  101435. *
  101436. * More information on this format are available here:
  101437. * https://en.wikipedia.org/wiki/RGBE_image_format
  101438. *
  101439. * @param uint8array The binary file stored in an array buffer.
  101440. * @param hdrInfo The header information of the file.
  101441. * @return The pixels data in RGB right to left up to down order.
  101442. */
  101443. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  101444. private static RGBE_ReadPixels_RLE;
  101445. }
  101446. }
  101447. declare module BABYLON {
  101448. /**
  101449. * This represents a texture coming from an HDR input.
  101450. *
  101451. * The only supported format is currently panorama picture stored in RGBE format.
  101452. * Example of such files can be found on HDRLib: http://hdrlib.com/
  101453. */
  101454. export class HDRCubeTexture extends BaseTexture {
  101455. private static _facesMapping;
  101456. private _generateHarmonics;
  101457. private _noMipmap;
  101458. private _textureMatrix;
  101459. private _size;
  101460. private _onLoad;
  101461. private _onError;
  101462. /**
  101463. * The texture URL.
  101464. */
  101465. url: string;
  101466. /**
  101467. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  101468. */
  101469. coordinatesMode: number;
  101470. protected _isBlocking: boolean;
  101471. /**
  101472. * Sets wether or not the texture is blocking during loading.
  101473. */
  101474. /**
  101475. * Gets wether or not the texture is blocking during loading.
  101476. */
  101477. isBlocking: boolean;
  101478. protected _rotationY: number;
  101479. /**
  101480. * Sets texture matrix rotation angle around Y axis in radians.
  101481. */
  101482. /**
  101483. * Gets texture matrix rotation angle around Y axis radians.
  101484. */
  101485. rotationY: number;
  101486. /**
  101487. * Gets or sets the center of the bounding box associated with the cube texture
  101488. * It must define where the camera used to render the texture was set
  101489. */
  101490. boundingBoxPosition: Vector3;
  101491. private _boundingBoxSize;
  101492. /**
  101493. * Gets or sets the size of the bounding box associated with the cube texture
  101494. * When defined, the cubemap will switch to local mode
  101495. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  101496. * @example https://www.babylonjs-playground.com/#RNASML
  101497. */
  101498. boundingBoxSize: Vector3;
  101499. /**
  101500. * Instantiates an HDRTexture from the following parameters.
  101501. *
  101502. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  101503. * @param scene The scene the texture will be used in
  101504. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  101505. * @param noMipmap Forces to not generate the mipmap if true
  101506. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  101507. * @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)
  101508. * @param reserved Reserved flag for internal use.
  101509. */
  101510. 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>);
  101511. /**
  101512. * Get the current class name of the texture useful for serialization or dynamic coding.
  101513. * @returns "HDRCubeTexture"
  101514. */
  101515. getClassName(): string;
  101516. /**
  101517. * Occurs when the file is raw .hdr file.
  101518. */
  101519. private loadTexture;
  101520. clone(): HDRCubeTexture;
  101521. delayLoad(): void;
  101522. /**
  101523. * Get the texture reflection matrix used to rotate/transform the reflection.
  101524. * @returns the reflection matrix
  101525. */
  101526. getReflectionTextureMatrix(): Matrix;
  101527. /**
  101528. * Set the texture reflection matrix used to rotate/transform the reflection.
  101529. * @param value Define the reflection matrix to set
  101530. */
  101531. setReflectionTextureMatrix(value: Matrix): void;
  101532. /**
  101533. * Parses a JSON representation of an HDR Texture in order to create the texture
  101534. * @param parsedTexture Define the JSON representation
  101535. * @param scene Define the scene the texture should be created in
  101536. * @param rootUrl Define the root url in case we need to load relative dependencies
  101537. * @returns the newly created texture after parsing
  101538. */
  101539. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  101540. serialize(): any;
  101541. }
  101542. }
  101543. declare module BABYLON {
  101544. /**
  101545. * Class used to control physics engine
  101546. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  101547. */
  101548. export class PhysicsEngine implements IPhysicsEngine {
  101549. private _physicsPlugin;
  101550. /**
  101551. * Global value used to control the smallest number supported by the simulation
  101552. */
  101553. static Epsilon: number;
  101554. private _impostors;
  101555. private _joints;
  101556. /**
  101557. * Gets the gravity vector used by the simulation
  101558. */
  101559. gravity: Vector3;
  101560. /**
  101561. * Factory used to create the default physics plugin.
  101562. * @returns The default physics plugin
  101563. */
  101564. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  101565. /**
  101566. * Creates a new Physics Engine
  101567. * @param gravity defines the gravity vector used by the simulation
  101568. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  101569. */
  101570. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  101571. /**
  101572. * Sets the gravity vector used by the simulation
  101573. * @param gravity defines the gravity vector to use
  101574. */
  101575. setGravity(gravity: Vector3): void;
  101576. /**
  101577. * Set the time step of the physics engine.
  101578. * Default is 1/60.
  101579. * To slow it down, enter 1/600 for example.
  101580. * To speed it up, 1/30
  101581. * @param newTimeStep defines the new timestep to apply to this world.
  101582. */
  101583. setTimeStep(newTimeStep?: number): void;
  101584. /**
  101585. * Get the time step of the physics engine.
  101586. * @returns the current time step
  101587. */
  101588. getTimeStep(): number;
  101589. /**
  101590. * Release all resources
  101591. */
  101592. dispose(): void;
  101593. /**
  101594. * Gets the name of the current physics plugin
  101595. * @returns the name of the plugin
  101596. */
  101597. getPhysicsPluginName(): string;
  101598. /**
  101599. * Adding a new impostor for the impostor tracking.
  101600. * This will be done by the impostor itself.
  101601. * @param impostor the impostor to add
  101602. */
  101603. addImpostor(impostor: PhysicsImpostor): void;
  101604. /**
  101605. * Remove an impostor from the engine.
  101606. * This impostor and its mesh will not longer be updated by the physics engine.
  101607. * @param impostor the impostor to remove
  101608. */
  101609. removeImpostor(impostor: PhysicsImpostor): void;
  101610. /**
  101611. * Add a joint to the physics engine
  101612. * @param mainImpostor defines the main impostor to which the joint is added.
  101613. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  101614. * @param joint defines the joint that will connect both impostors.
  101615. */
  101616. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  101617. /**
  101618. * Removes a joint from the simulation
  101619. * @param mainImpostor defines the impostor used with the joint
  101620. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  101621. * @param joint defines the joint to remove
  101622. */
  101623. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  101624. /**
  101625. * Called by the scene. No need to call it.
  101626. * @param delta defines the timespam between frames
  101627. */
  101628. _step(delta: number): void;
  101629. /**
  101630. * Gets the current plugin used to run the simulation
  101631. * @returns current plugin
  101632. */
  101633. getPhysicsPlugin(): IPhysicsEnginePlugin;
  101634. /**
  101635. * Gets the list of physic impostors
  101636. * @returns an array of PhysicsImpostor
  101637. */
  101638. getImpostors(): Array<PhysicsImpostor>;
  101639. /**
  101640. * Gets the impostor for a physics enabled object
  101641. * @param object defines the object impersonated by the impostor
  101642. * @returns the PhysicsImpostor or null if not found
  101643. */
  101644. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  101645. /**
  101646. * Gets the impostor for a physics body object
  101647. * @param body defines physics body used by the impostor
  101648. * @returns the PhysicsImpostor or null if not found
  101649. */
  101650. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  101651. }
  101652. }
  101653. declare module BABYLON {
  101654. /** @hidden */
  101655. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  101656. private _useDeltaForWorldStep;
  101657. world: any;
  101658. name: string;
  101659. private _physicsMaterials;
  101660. private _fixedTimeStep;
  101661. BJSCANNON: any;
  101662. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  101663. setGravity(gravity: Vector3): void;
  101664. setTimeStep(timeStep: number): void;
  101665. getTimeStep(): number;
  101666. executeStep(delta: number): void;
  101667. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101668. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101669. generatePhysicsBody(impostor: PhysicsImpostor): void;
  101670. private _processChildMeshes;
  101671. removePhysicsBody(impostor: PhysicsImpostor): void;
  101672. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  101673. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  101674. private _addMaterial;
  101675. private _checkWithEpsilon;
  101676. private _createShape;
  101677. private _createHeightmap;
  101678. private _minus90X;
  101679. private _plus90X;
  101680. private _tmpPosition;
  101681. private _tmpDeltaPosition;
  101682. private _tmpUnityRotation;
  101683. private _updatePhysicsBodyTransformation;
  101684. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  101685. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  101686. isSupported(): boolean;
  101687. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101688. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101689. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101690. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101691. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  101692. getBodyMass(impostor: PhysicsImpostor): number;
  101693. getBodyFriction(impostor: PhysicsImpostor): number;
  101694. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  101695. getBodyRestitution(impostor: PhysicsImpostor): number;
  101696. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  101697. sleepBody(impostor: PhysicsImpostor): void;
  101698. wakeUpBody(impostor: PhysicsImpostor): void;
  101699. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  101700. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  101701. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  101702. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  101703. getRadius(impostor: PhysicsImpostor): number;
  101704. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  101705. dispose(): void;
  101706. private _extendNamespace;
  101707. }
  101708. }
  101709. declare module BABYLON {
  101710. /** @hidden */
  101711. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  101712. world: any;
  101713. name: string;
  101714. BJSOIMO: any;
  101715. constructor(iterations?: number, oimoInjection?: any);
  101716. setGravity(gravity: Vector3): void;
  101717. setTimeStep(timeStep: number): void;
  101718. getTimeStep(): number;
  101719. private _tmpImpostorsArray;
  101720. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  101721. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101722. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101723. generatePhysicsBody(impostor: PhysicsImpostor): void;
  101724. private _tmpPositionVector;
  101725. removePhysicsBody(impostor: PhysicsImpostor): void;
  101726. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  101727. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  101728. isSupported(): boolean;
  101729. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  101730. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  101731. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101732. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101733. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101734. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101735. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  101736. getBodyMass(impostor: PhysicsImpostor): number;
  101737. getBodyFriction(impostor: PhysicsImpostor): number;
  101738. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  101739. getBodyRestitution(impostor: PhysicsImpostor): number;
  101740. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  101741. sleepBody(impostor: PhysicsImpostor): void;
  101742. wakeUpBody(impostor: PhysicsImpostor): void;
  101743. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  101744. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  101745. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  101746. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  101747. getRadius(impostor: PhysicsImpostor): number;
  101748. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  101749. dispose(): void;
  101750. }
  101751. }
  101752. declare module BABYLON {
  101753. interface AbstractScene {
  101754. /**
  101755. * The list of reflection probes added to the scene
  101756. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  101757. */
  101758. reflectionProbes: Array<ReflectionProbe>;
  101759. /**
  101760. * Removes the given reflection probe from this scene.
  101761. * @param toRemove The reflection probe to remove
  101762. * @returns The index of the removed reflection probe
  101763. */
  101764. removeReflectionProbe(toRemove: ReflectionProbe): number;
  101765. /**
  101766. * Adds the given reflection probe to this scene.
  101767. * @param newReflectionProbe The reflection probe to add
  101768. */
  101769. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  101770. }
  101771. /**
  101772. * Class used to generate realtime reflection / refraction cube textures
  101773. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  101774. */
  101775. export class ReflectionProbe {
  101776. /** defines the name of the probe */
  101777. name: string;
  101778. private _scene;
  101779. private _renderTargetTexture;
  101780. private _projectionMatrix;
  101781. private _viewMatrix;
  101782. private _target;
  101783. private _add;
  101784. private _attachedMesh;
  101785. private _invertYAxis;
  101786. /** Gets or sets probe position (center of the cube map) */
  101787. position: Vector3;
  101788. /**
  101789. * Creates a new reflection probe
  101790. * @param name defines the name of the probe
  101791. * @param size defines the texture resolution (for each face)
  101792. * @param scene defines the hosting scene
  101793. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  101794. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  101795. */
  101796. constructor(
  101797. /** defines the name of the probe */
  101798. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  101799. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  101800. samples: number;
  101801. /** Gets or sets the refresh rate to use (on every frame by default) */
  101802. refreshRate: number;
  101803. /**
  101804. * Gets the hosting scene
  101805. * @returns a Scene
  101806. */
  101807. getScene(): Scene;
  101808. /** Gets the internal CubeTexture used to render to */
  101809. readonly cubeTexture: RenderTargetTexture;
  101810. /** Gets the list of meshes to render */
  101811. readonly renderList: Nullable<AbstractMesh[]>;
  101812. /**
  101813. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  101814. * @param mesh defines the mesh to attach to
  101815. */
  101816. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  101817. /**
  101818. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  101819. * @param renderingGroupId The rendering group id corresponding to its index
  101820. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101821. */
  101822. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  101823. /**
  101824. * Clean all associated resources
  101825. */
  101826. dispose(): void;
  101827. /**
  101828. * Converts the reflection probe information to a readable string for debug purpose.
  101829. * @param fullDetails Supports for multiple levels of logging within scene loading
  101830. * @returns the human readable reflection probe info
  101831. */
  101832. toString(fullDetails?: boolean): string;
  101833. /**
  101834. * Get the class name of the relfection probe.
  101835. * @returns "ReflectionProbe"
  101836. */
  101837. getClassName(): string;
  101838. /**
  101839. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  101840. * @returns The JSON representation of the texture
  101841. */
  101842. serialize(): any;
  101843. /**
  101844. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  101845. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  101846. * @param scene Define the scene the parsed reflection probe should be instantiated in
  101847. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  101848. * @returns The parsed reflection probe if successful
  101849. */
  101850. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  101851. }
  101852. }
  101853. declare module BABYLON {
  101854. /** @hidden */
  101855. export var _BabylonLoaderRegistered: boolean;
  101856. }
  101857. declare module BABYLON {
  101858. /**
  101859. * The Physically based simple base material of BJS.
  101860. *
  101861. * This enables better naming and convention enforcements on top of the pbrMaterial.
  101862. * It is used as the base class for both the specGloss and metalRough conventions.
  101863. */
  101864. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  101865. /**
  101866. * Number of Simultaneous lights allowed on the material.
  101867. */
  101868. maxSimultaneousLights: number;
  101869. /**
  101870. * If sets to true, disables all the lights affecting the material.
  101871. */
  101872. disableLighting: boolean;
  101873. /**
  101874. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  101875. */
  101876. environmentTexture: BaseTexture;
  101877. /**
  101878. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101879. */
  101880. invertNormalMapX: boolean;
  101881. /**
  101882. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101883. */
  101884. invertNormalMapY: boolean;
  101885. /**
  101886. * Normal map used in the model.
  101887. */
  101888. normalTexture: BaseTexture;
  101889. /**
  101890. * Emissivie color used to self-illuminate the model.
  101891. */
  101892. emissiveColor: Color3;
  101893. /**
  101894. * Emissivie texture used to self-illuminate the model.
  101895. */
  101896. emissiveTexture: BaseTexture;
  101897. /**
  101898. * Occlusion Channel Strenght.
  101899. */
  101900. occlusionStrength: number;
  101901. /**
  101902. * Occlusion Texture of the material (adding extra occlusion effects).
  101903. */
  101904. occlusionTexture: BaseTexture;
  101905. /**
  101906. * Defines the alpha limits in alpha test mode.
  101907. */
  101908. alphaCutOff: number;
  101909. /**
  101910. * Gets the current double sided mode.
  101911. */
  101912. /**
  101913. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101914. */
  101915. doubleSided: boolean;
  101916. /**
  101917. * Stores the pre-calculated light information of a mesh in a texture.
  101918. */
  101919. lightmapTexture: BaseTexture;
  101920. /**
  101921. * If true, the light map contains occlusion information instead of lighting info.
  101922. */
  101923. useLightmapAsShadowmap: boolean;
  101924. /**
  101925. * Return the active textures of the material.
  101926. */
  101927. getActiveTextures(): BaseTexture[];
  101928. hasTexture(texture: BaseTexture): boolean;
  101929. /**
  101930. * Instantiates a new PBRMaterial instance.
  101931. *
  101932. * @param name The material name
  101933. * @param scene The scene the material will be use in.
  101934. */
  101935. constructor(name: string, scene: Scene);
  101936. getClassName(): string;
  101937. }
  101938. }
  101939. declare module BABYLON {
  101940. /**
  101941. * The PBR material of BJS following the metal roughness convention.
  101942. *
  101943. * This fits to the PBR convention in the GLTF definition:
  101944. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  101945. */
  101946. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  101947. /**
  101948. * The base color has two different interpretations depending on the value of metalness.
  101949. * When the material is a metal, the base color is the specific measured reflectance value
  101950. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  101951. * of the material.
  101952. */
  101953. baseColor: Color3;
  101954. /**
  101955. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  101956. * well as opacity information in the alpha channel.
  101957. */
  101958. baseTexture: BaseTexture;
  101959. /**
  101960. * Specifies the metallic scalar value of the material.
  101961. * Can also be used to scale the metalness values of the metallic texture.
  101962. */
  101963. metallic: number;
  101964. /**
  101965. * Specifies the roughness scalar value of the material.
  101966. * Can also be used to scale the roughness values of the metallic texture.
  101967. */
  101968. roughness: number;
  101969. /**
  101970. * Texture containing both the metallic value in the B channel and the
  101971. * roughness value in the G channel to keep better precision.
  101972. */
  101973. metallicRoughnessTexture: BaseTexture;
  101974. /**
  101975. * Instantiates a new PBRMetalRoughnessMaterial instance.
  101976. *
  101977. * @param name The material name
  101978. * @param scene The scene the material will be use in.
  101979. */
  101980. constructor(name: string, scene: Scene);
  101981. /**
  101982. * Return the currrent class name of the material.
  101983. */
  101984. getClassName(): string;
  101985. /**
  101986. * Return the active textures of the material.
  101987. */
  101988. getActiveTextures(): BaseTexture[];
  101989. /**
  101990. * Checks to see if a texture is used in the material.
  101991. * @param texture - Base texture to use.
  101992. * @returns - Boolean specifying if a texture is used in the material.
  101993. */
  101994. hasTexture(texture: BaseTexture): boolean;
  101995. /**
  101996. * Makes a duplicate of the current material.
  101997. * @param name - name to use for the new material.
  101998. */
  101999. clone(name: string): PBRMetallicRoughnessMaterial;
  102000. /**
  102001. * Serialize the material to a parsable JSON object.
  102002. */
  102003. serialize(): any;
  102004. /**
  102005. * Parses a JSON object correponding to the serialize function.
  102006. */
  102007. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  102008. }
  102009. }
  102010. declare module BABYLON {
  102011. /**
  102012. * The PBR material of BJS following the specular glossiness convention.
  102013. *
  102014. * This fits to the PBR convention in the GLTF definition:
  102015. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  102016. */
  102017. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  102018. /**
  102019. * Specifies the diffuse color of the material.
  102020. */
  102021. diffuseColor: Color3;
  102022. /**
  102023. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  102024. * channel.
  102025. */
  102026. diffuseTexture: BaseTexture;
  102027. /**
  102028. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  102029. */
  102030. specularColor: Color3;
  102031. /**
  102032. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  102033. */
  102034. glossiness: number;
  102035. /**
  102036. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  102037. */
  102038. specularGlossinessTexture: BaseTexture;
  102039. /**
  102040. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  102041. *
  102042. * @param name The material name
  102043. * @param scene The scene the material will be use in.
  102044. */
  102045. constructor(name: string, scene: Scene);
  102046. /**
  102047. * Return the currrent class name of the material.
  102048. */
  102049. getClassName(): string;
  102050. /**
  102051. * Return the active textures of the material.
  102052. */
  102053. getActiveTextures(): BaseTexture[];
  102054. /**
  102055. * Checks to see if a texture is used in the material.
  102056. * @param texture - Base texture to use.
  102057. * @returns - Boolean specifying if a texture is used in the material.
  102058. */
  102059. hasTexture(texture: BaseTexture): boolean;
  102060. /**
  102061. * Makes a duplicate of the current material.
  102062. * @param name - name to use for the new material.
  102063. */
  102064. clone(name: string): PBRSpecularGlossinessMaterial;
  102065. /**
  102066. * Serialize the material to a parsable JSON object.
  102067. */
  102068. serialize(): any;
  102069. /**
  102070. * Parses a JSON object correponding to the serialize function.
  102071. */
  102072. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  102073. }
  102074. }
  102075. declare module BABYLON {
  102076. /**
  102077. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  102078. * It can help converting any input color in a desired output one. This can then be used to create effects
  102079. * from sepia, black and white to sixties or futuristic rendering...
  102080. *
  102081. * The only supported format is currently 3dl.
  102082. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  102083. */
  102084. export class ColorGradingTexture extends BaseTexture {
  102085. /**
  102086. * The current texture matrix. (will always be identity in color grading texture)
  102087. */
  102088. private _textureMatrix;
  102089. /**
  102090. * The texture URL.
  102091. */
  102092. url: string;
  102093. /**
  102094. * Empty line regex stored for GC.
  102095. */
  102096. private static _noneEmptyLineRegex;
  102097. private _engine;
  102098. /**
  102099. * Instantiates a ColorGradingTexture from the following parameters.
  102100. *
  102101. * @param url The location of the color gradind data (currently only supporting 3dl)
  102102. * @param scene The scene the texture will be used in
  102103. */
  102104. constructor(url: string, scene: Scene);
  102105. /**
  102106. * Returns the texture matrix used in most of the material.
  102107. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  102108. */
  102109. getTextureMatrix(): Matrix;
  102110. /**
  102111. * Occurs when the file being loaded is a .3dl LUT file.
  102112. */
  102113. private load3dlTexture;
  102114. /**
  102115. * Starts the loading process of the texture.
  102116. */
  102117. private loadTexture;
  102118. /**
  102119. * Clones the color gradind texture.
  102120. */
  102121. clone(): ColorGradingTexture;
  102122. /**
  102123. * Called during delayed load for textures.
  102124. */
  102125. delayLoad(): void;
  102126. /**
  102127. * Parses a color grading texture serialized by Babylon.
  102128. * @param parsedTexture The texture information being parsedTexture
  102129. * @param scene The scene to load the texture in
  102130. * @param rootUrl The root url of the data assets to load
  102131. * @return A color gradind texture
  102132. */
  102133. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  102134. /**
  102135. * Serializes the LUT texture to json format.
  102136. */
  102137. serialize(): any;
  102138. }
  102139. }
  102140. declare module BABYLON {
  102141. /**
  102142. * Direct draw surface info
  102143. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  102144. */
  102145. export interface DDSInfo {
  102146. /**
  102147. * Width of the texture
  102148. */
  102149. width: number;
  102150. /**
  102151. * Width of the texture
  102152. */
  102153. height: number;
  102154. /**
  102155. * Number of Mipmaps for the texture
  102156. * @see https://en.wikipedia.org/wiki/Mipmap
  102157. */
  102158. mipmapCount: number;
  102159. /**
  102160. * If the textures format is a known fourCC format
  102161. * @see https://www.fourcc.org/
  102162. */
  102163. isFourCC: boolean;
  102164. /**
  102165. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  102166. */
  102167. isRGB: boolean;
  102168. /**
  102169. * If the texture is a lumincance format
  102170. */
  102171. isLuminance: boolean;
  102172. /**
  102173. * If this is a cube texture
  102174. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  102175. */
  102176. isCube: boolean;
  102177. /**
  102178. * If the texture is a compressed format eg. FOURCC_DXT1
  102179. */
  102180. isCompressed: boolean;
  102181. /**
  102182. * The dxgiFormat of the texture
  102183. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  102184. */
  102185. dxgiFormat: number;
  102186. /**
  102187. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  102188. */
  102189. textureType: number;
  102190. /**
  102191. * Sphericle polynomial created for the dds texture
  102192. */
  102193. sphericalPolynomial?: SphericalPolynomial;
  102194. }
  102195. /**
  102196. * Class used to provide DDS decompression tools
  102197. */
  102198. export class DDSTools {
  102199. /**
  102200. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  102201. */
  102202. static StoreLODInAlphaChannel: boolean;
  102203. /**
  102204. * Gets DDS information from an array buffer
  102205. * @param arrayBuffer defines the array buffer to read data from
  102206. * @returns the DDS information
  102207. */
  102208. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  102209. private static _FloatView;
  102210. private static _Int32View;
  102211. private static _ToHalfFloat;
  102212. private static _FromHalfFloat;
  102213. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  102214. private static _GetHalfFloatRGBAArrayBuffer;
  102215. private static _GetFloatRGBAArrayBuffer;
  102216. private static _GetFloatAsUIntRGBAArrayBuffer;
  102217. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  102218. private static _GetRGBAArrayBuffer;
  102219. private static _ExtractLongWordOrder;
  102220. private static _GetRGBArrayBuffer;
  102221. private static _GetLuminanceArrayBuffer;
  102222. /**
  102223. * Uploads DDS Levels to a Babylon Texture
  102224. * @hidden
  102225. */
  102226. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  102227. }
  102228. interface Engine {
  102229. /**
  102230. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  102231. * @param rootUrl defines the url where the file to load is located
  102232. * @param scene defines the current scene
  102233. * @param lodScale defines scale to apply to the mip map selection
  102234. * @param lodOffset defines offset to apply to the mip map selection
  102235. * @param onLoad defines an optional callback raised when the texture is loaded
  102236. * @param onError defines an optional callback raised if there is an issue to load the texture
  102237. * @param format defines the format of the data
  102238. * @param forcedExtension defines the extension to use to pick the right loader
  102239. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  102240. * @returns the cube texture as an InternalTexture
  102241. */
  102242. 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;
  102243. }
  102244. }
  102245. declare module BABYLON {
  102246. /**
  102247. * Implementation of the DDS Texture Loader.
  102248. * @hidden
  102249. */
  102250. export class _DDSTextureLoader implements IInternalTextureLoader {
  102251. /**
  102252. * Defines wether the loader supports cascade loading the different faces.
  102253. */
  102254. readonly supportCascades: boolean;
  102255. /**
  102256. * This returns if the loader support the current file information.
  102257. * @param extension defines the file extension of the file being loaded
  102258. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102259. * @param fallback defines the fallback internal texture if any
  102260. * @param isBase64 defines whether the texture is encoded as a base64
  102261. * @param isBuffer defines whether the texture data are stored as a buffer
  102262. * @returns true if the loader can load the specified file
  102263. */
  102264. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102265. /**
  102266. * Transform the url before loading if required.
  102267. * @param rootUrl the url of the texture
  102268. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102269. * @returns the transformed texture
  102270. */
  102271. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102272. /**
  102273. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102274. * @param rootUrl the url of the texture
  102275. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102276. * @returns the fallback texture
  102277. */
  102278. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102279. /**
  102280. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102281. * @param data contains the texture data
  102282. * @param texture defines the BabylonJS internal texture
  102283. * @param createPolynomials will be true if polynomials have been requested
  102284. * @param onLoad defines the callback to trigger once the texture is ready
  102285. * @param onError defines the callback to trigger in case of error
  102286. */
  102287. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102288. /**
  102289. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102290. * @param data contains the texture data
  102291. * @param texture defines the BabylonJS internal texture
  102292. * @param callback defines the method to call once ready to upload
  102293. */
  102294. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102295. }
  102296. }
  102297. declare module BABYLON {
  102298. /** @hidden */
  102299. export var rgbdEncodePixelShader: {
  102300. name: string;
  102301. shader: string;
  102302. };
  102303. }
  102304. declare module BABYLON {
  102305. /** @hidden */
  102306. export var rgbdDecodePixelShader: {
  102307. name: string;
  102308. shader: string;
  102309. };
  102310. }
  102311. declare module BABYLON {
  102312. /**
  102313. * Raw texture data and descriptor sufficient for WebGL texture upload
  102314. */
  102315. export interface EnvironmentTextureInfo {
  102316. /**
  102317. * Version of the environment map
  102318. */
  102319. version: number;
  102320. /**
  102321. * Width of image
  102322. */
  102323. width: number;
  102324. /**
  102325. * Irradiance information stored in the file.
  102326. */
  102327. irradiance: any;
  102328. /**
  102329. * Specular information stored in the file.
  102330. */
  102331. specular: any;
  102332. }
  102333. /**
  102334. * Sets of helpers addressing the serialization and deserialization of environment texture
  102335. * stored in a BabylonJS env file.
  102336. * Those files are usually stored as .env files.
  102337. */
  102338. export class EnvironmentTextureTools {
  102339. /**
  102340. * Magic number identifying the env file.
  102341. */
  102342. private static _MagicBytes;
  102343. /**
  102344. * Gets the environment info from an env file.
  102345. * @param data The array buffer containing the .env bytes.
  102346. * @returns the environment file info (the json header) if successfully parsed.
  102347. */
  102348. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  102349. /**
  102350. * Creates an environment texture from a loaded cube texture.
  102351. * @param texture defines the cube texture to convert in env file
  102352. * @return a promise containing the environment data if succesfull.
  102353. */
  102354. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  102355. /**
  102356. * Creates a JSON representation of the spherical data.
  102357. * @param texture defines the texture containing the polynomials
  102358. * @return the JSON representation of the spherical info
  102359. */
  102360. private static _CreateEnvTextureIrradiance;
  102361. /**
  102362. * Uploads the texture info contained in the env file to the GPU.
  102363. * @param texture defines the internal texture to upload to
  102364. * @param arrayBuffer defines the buffer cotaining the data to load
  102365. * @param info defines the texture info retrieved through the GetEnvInfo method
  102366. * @returns a promise
  102367. */
  102368. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  102369. /**
  102370. * Uploads the levels of image data to the GPU.
  102371. * @param texture defines the internal texture to upload to
  102372. * @param imageData defines the array buffer views of image data [mipmap][face]
  102373. * @returns a promise
  102374. */
  102375. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  102376. /**
  102377. * Uploads spherical polynomials information to the texture.
  102378. * @param texture defines the texture we are trying to upload the information to
  102379. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  102380. */
  102381. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  102382. /** @hidden */
  102383. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  102384. }
  102385. }
  102386. declare module BABYLON {
  102387. /**
  102388. * Implementation of the ENV Texture Loader.
  102389. * @hidden
  102390. */
  102391. export class _ENVTextureLoader implements IInternalTextureLoader {
  102392. /**
  102393. * Defines wether the loader supports cascade loading the different faces.
  102394. */
  102395. readonly supportCascades: boolean;
  102396. /**
  102397. * This returns if the loader support the current file information.
  102398. * @param extension defines the file extension of the file being loaded
  102399. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102400. * @param fallback defines the fallback internal texture if any
  102401. * @param isBase64 defines whether the texture is encoded as a base64
  102402. * @param isBuffer defines whether the texture data are stored as a buffer
  102403. * @returns true if the loader can load the specified file
  102404. */
  102405. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102406. /**
  102407. * Transform the url before loading if required.
  102408. * @param rootUrl the url of the texture
  102409. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102410. * @returns the transformed texture
  102411. */
  102412. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102413. /**
  102414. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102415. * @param rootUrl the url of the texture
  102416. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102417. * @returns the fallback texture
  102418. */
  102419. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102420. /**
  102421. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102422. * @param data contains the texture data
  102423. * @param texture defines the BabylonJS internal texture
  102424. * @param createPolynomials will be true if polynomials have been requested
  102425. * @param onLoad defines the callback to trigger once the texture is ready
  102426. * @param onError defines the callback to trigger in case of error
  102427. */
  102428. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102429. /**
  102430. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102431. * @param data contains the texture data
  102432. * @param texture defines the BabylonJS internal texture
  102433. * @param callback defines the method to call once ready to upload
  102434. */
  102435. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102436. }
  102437. }
  102438. declare module BABYLON {
  102439. /**
  102440. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  102441. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  102442. */
  102443. export class KhronosTextureContainer {
  102444. /** contents of the KTX container file */
  102445. arrayBuffer: any;
  102446. private static HEADER_LEN;
  102447. private static COMPRESSED_2D;
  102448. private static COMPRESSED_3D;
  102449. private static TEX_2D;
  102450. private static TEX_3D;
  102451. /**
  102452. * Gets the openGL type
  102453. */
  102454. glType: number;
  102455. /**
  102456. * Gets the openGL type size
  102457. */
  102458. glTypeSize: number;
  102459. /**
  102460. * Gets the openGL format
  102461. */
  102462. glFormat: number;
  102463. /**
  102464. * Gets the openGL internal format
  102465. */
  102466. glInternalFormat: number;
  102467. /**
  102468. * Gets the base internal format
  102469. */
  102470. glBaseInternalFormat: number;
  102471. /**
  102472. * Gets image width in pixel
  102473. */
  102474. pixelWidth: number;
  102475. /**
  102476. * Gets image height in pixel
  102477. */
  102478. pixelHeight: number;
  102479. /**
  102480. * Gets image depth in pixels
  102481. */
  102482. pixelDepth: number;
  102483. /**
  102484. * Gets the number of array elements
  102485. */
  102486. numberOfArrayElements: number;
  102487. /**
  102488. * Gets the number of faces
  102489. */
  102490. numberOfFaces: number;
  102491. /**
  102492. * Gets the number of mipmap levels
  102493. */
  102494. numberOfMipmapLevels: number;
  102495. /**
  102496. * Gets the bytes of key value data
  102497. */
  102498. bytesOfKeyValueData: number;
  102499. /**
  102500. * Gets the load type
  102501. */
  102502. loadType: number;
  102503. /**
  102504. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  102505. */
  102506. isInvalid: boolean;
  102507. /**
  102508. * Creates a new KhronosTextureContainer
  102509. * @param arrayBuffer contents of the KTX container file
  102510. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  102511. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  102512. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  102513. */
  102514. constructor(
  102515. /** contents of the KTX container file */
  102516. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  102517. /**
  102518. * Uploads KTX content to a Babylon Texture.
  102519. * It is assumed that the texture has already been created & is currently bound
  102520. * @hidden
  102521. */
  102522. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  102523. private _upload2DCompressedLevels;
  102524. }
  102525. }
  102526. declare module BABYLON {
  102527. /**
  102528. * Implementation of the KTX Texture Loader.
  102529. * @hidden
  102530. */
  102531. export class _KTXTextureLoader implements IInternalTextureLoader {
  102532. /**
  102533. * Defines wether the loader supports cascade loading the different faces.
  102534. */
  102535. readonly supportCascades: boolean;
  102536. /**
  102537. * This returns if the loader support the current file information.
  102538. * @param extension defines the file extension of the file being loaded
  102539. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102540. * @param fallback defines the fallback internal texture if any
  102541. * @param isBase64 defines whether the texture is encoded as a base64
  102542. * @param isBuffer defines whether the texture data are stored as a buffer
  102543. * @returns true if the loader can load the specified file
  102544. */
  102545. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102546. /**
  102547. * Transform the url before loading if required.
  102548. * @param rootUrl the url of the texture
  102549. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102550. * @returns the transformed texture
  102551. */
  102552. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102553. /**
  102554. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102555. * @param rootUrl the url of the texture
  102556. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102557. * @returns the fallback texture
  102558. */
  102559. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102560. /**
  102561. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102562. * @param data contains the texture data
  102563. * @param texture defines the BabylonJS internal texture
  102564. * @param createPolynomials will be true if polynomials have been requested
  102565. * @param onLoad defines the callback to trigger once the texture is ready
  102566. * @param onError defines the callback to trigger in case of error
  102567. */
  102568. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102569. /**
  102570. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102571. * @param data contains the texture data
  102572. * @param texture defines the BabylonJS internal texture
  102573. * @param callback defines the method to call once ready to upload
  102574. */
  102575. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  102576. }
  102577. }
  102578. declare module BABYLON {
  102579. /**
  102580. * Based on jsTGALoader - Javascript loader for TGA file
  102581. * By Vincent Thibault
  102582. * @see http://blog.robrowser.com/javascript-tga-loader.html
  102583. */
  102584. export class TGATools {
  102585. private static _TYPE_INDEXED;
  102586. private static _TYPE_RGB;
  102587. private static _TYPE_GREY;
  102588. private static _TYPE_RLE_INDEXED;
  102589. private static _TYPE_RLE_RGB;
  102590. private static _TYPE_RLE_GREY;
  102591. private static _ORIGIN_MASK;
  102592. private static _ORIGIN_SHIFT;
  102593. private static _ORIGIN_BL;
  102594. private static _ORIGIN_BR;
  102595. private static _ORIGIN_UL;
  102596. private static _ORIGIN_UR;
  102597. /**
  102598. * Gets the header of a TGA file
  102599. * @param data defines the TGA data
  102600. * @returns the header
  102601. */
  102602. static GetTGAHeader(data: Uint8Array): any;
  102603. /**
  102604. * Uploads TGA content to a Babylon Texture
  102605. * @hidden
  102606. */
  102607. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  102608. /** @hidden */
  102609. 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;
  102610. /** @hidden */
  102611. 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;
  102612. /** @hidden */
  102613. 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;
  102614. /** @hidden */
  102615. 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;
  102616. /** @hidden */
  102617. 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;
  102618. /** @hidden */
  102619. 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;
  102620. }
  102621. }
  102622. declare module BABYLON {
  102623. /**
  102624. * Implementation of the TGA Texture Loader.
  102625. * @hidden
  102626. */
  102627. export class _TGATextureLoader implements IInternalTextureLoader {
  102628. /**
  102629. * Defines wether the loader supports cascade loading the different faces.
  102630. */
  102631. readonly supportCascades: boolean;
  102632. /**
  102633. * This returns if the loader support the current file information.
  102634. * @param extension defines the file extension of the file being loaded
  102635. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102636. * @param fallback defines the fallback internal texture if any
  102637. * @param isBase64 defines whether the texture is encoded as a base64
  102638. * @param isBuffer defines whether the texture data are stored as a buffer
  102639. * @returns true if the loader can load the specified file
  102640. */
  102641. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102642. /**
  102643. * Transform the url before loading if required.
  102644. * @param rootUrl the url of the texture
  102645. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102646. * @returns the transformed texture
  102647. */
  102648. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102649. /**
  102650. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102651. * @param rootUrl the url of the texture
  102652. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102653. * @returns the fallback texture
  102654. */
  102655. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102656. /**
  102657. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102658. * @param data contains the texture data
  102659. * @param texture defines the BabylonJS internal texture
  102660. * @param createPolynomials will be true if polynomials have been requested
  102661. * @param onLoad defines the callback to trigger once the texture is ready
  102662. * @param onError defines the callback to trigger in case of error
  102663. */
  102664. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102665. /**
  102666. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102667. * @param data contains the texture data
  102668. * @param texture defines the BabylonJS internal texture
  102669. * @param callback defines the method to call once ready to upload
  102670. */
  102671. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102672. }
  102673. }
  102674. declare module BABYLON {
  102675. /**
  102676. * 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.
  102677. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  102678. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  102679. */
  102680. export class CustomProceduralTexture extends ProceduralTexture {
  102681. private _animate;
  102682. private _time;
  102683. private _config;
  102684. private _texturePath;
  102685. /**
  102686. * Instantiates a new Custom Procedural Texture.
  102687. * 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.
  102688. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  102689. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  102690. * @param name Define the name of the texture
  102691. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  102692. * @param size Define the size of the texture to create
  102693. * @param scene Define the scene the texture belongs to
  102694. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  102695. * @param generateMipMaps Define if the texture should creates mip maps or not
  102696. */
  102697. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  102698. private _loadJson;
  102699. /**
  102700. * Is the texture ready to be used ? (rendered at least once)
  102701. * @returns true if ready, otherwise, false.
  102702. */
  102703. isReady(): boolean;
  102704. /**
  102705. * Render the texture to its associated render target.
  102706. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  102707. */
  102708. render(useCameraPostProcess?: boolean): void;
  102709. /**
  102710. * Update the list of dependant textures samplers in the shader.
  102711. */
  102712. updateTextures(): void;
  102713. /**
  102714. * Update the uniform values of the procedural texture in the shader.
  102715. */
  102716. updateShaderUniforms(): void;
  102717. /**
  102718. * Define if the texture animates or not.
  102719. */
  102720. animate: boolean;
  102721. }
  102722. }
  102723. declare module BABYLON {
  102724. /** @hidden */
  102725. export var noisePixelShader: {
  102726. name: string;
  102727. shader: string;
  102728. };
  102729. }
  102730. declare module BABYLON {
  102731. /**
  102732. * Class used to generate noise procedural textures
  102733. */
  102734. export class NoiseProceduralTexture extends ProceduralTexture {
  102735. private _time;
  102736. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  102737. brightness: number;
  102738. /** Defines the number of octaves to process */
  102739. octaves: number;
  102740. /** Defines the level of persistence (0.8 by default) */
  102741. persistence: number;
  102742. /** Gets or sets animation speed factor (default is 1) */
  102743. animationSpeedFactor: number;
  102744. /**
  102745. * Creates a new NoiseProceduralTexture
  102746. * @param name defines the name fo the texture
  102747. * @param size defines the size of the texture (default is 256)
  102748. * @param scene defines the hosting scene
  102749. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  102750. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  102751. */
  102752. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  102753. private _updateShaderUniforms;
  102754. protected _getDefines(): string;
  102755. /** Generate the current state of the procedural texture */
  102756. render(useCameraPostProcess?: boolean): void;
  102757. /**
  102758. * Serializes this noise procedural texture
  102759. * @returns a serialized noise procedural texture object
  102760. */
  102761. serialize(): any;
  102762. /**
  102763. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  102764. * @param parsedTexture defines parsed texture data
  102765. * @param scene defines the current scene
  102766. * @param rootUrl defines the root URL containing noise procedural texture information
  102767. * @returns a parsed NoiseProceduralTexture
  102768. */
  102769. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  102770. }
  102771. }
  102772. declare module BABYLON {
  102773. /**
  102774. * Raw cube texture where the raw buffers are passed in
  102775. */
  102776. export class RawCubeTexture extends CubeTexture {
  102777. /**
  102778. * Creates a cube texture where the raw buffers are passed in.
  102779. * @param scene defines the scene the texture is attached to
  102780. * @param data defines the array of data to use to create each face
  102781. * @param size defines the size of the textures
  102782. * @param format defines the format of the data
  102783. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  102784. * @param generateMipMaps defines if the engine should generate the mip levels
  102785. * @param invertY defines if data must be stored with Y axis inverted
  102786. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102787. * @param compression defines the compression used (null by default)
  102788. */
  102789. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  102790. /**
  102791. * Updates the raw cube texture.
  102792. * @param data defines the data to store
  102793. * @param format defines the data format
  102794. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  102795. * @param invertY defines if data must be stored with Y axis inverted
  102796. * @param compression defines the compression used (null by default)
  102797. * @param level defines which level of the texture to update
  102798. */
  102799. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  102800. /**
  102801. * Updates a raw cube texture with RGBD encoded data.
  102802. * @param data defines the array of data [mipmap][face] to use to create each face
  102803. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  102804. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  102805. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  102806. * @returns a promsie that resolves when the operation is complete
  102807. */
  102808. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  102809. /**
  102810. * Clones the raw cube texture.
  102811. * @return a new cube texture
  102812. */
  102813. clone(): CubeTexture;
  102814. /** @hidden */
  102815. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  102816. }
  102817. }
  102818. declare module BABYLON {
  102819. /**
  102820. * Class used to store 3D textures containing user data
  102821. */
  102822. export class RawTexture3D extends Texture {
  102823. /** Gets or sets the texture format to use */
  102824. format: number;
  102825. private _engine;
  102826. /**
  102827. * Create a new RawTexture3D
  102828. * @param data defines the data of the texture
  102829. * @param width defines the width of the texture
  102830. * @param height defines the height of the texture
  102831. * @param depth defines the depth of the texture
  102832. * @param format defines the texture format to use
  102833. * @param scene defines the hosting scene
  102834. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  102835. * @param invertY defines if texture must be stored with Y axis inverted
  102836. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  102837. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  102838. */
  102839. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  102840. /** Gets or sets the texture format to use */
  102841. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  102842. /**
  102843. * Update the texture with new data
  102844. * @param data defines the data to store in the texture
  102845. */
  102846. update(data: ArrayBufferView): void;
  102847. }
  102848. }
  102849. declare module BABYLON {
  102850. /**
  102851. * Creates a refraction texture used by refraction channel of the standard material.
  102852. * It is like a mirror but to see through a material.
  102853. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  102854. */
  102855. export class RefractionTexture extends RenderTargetTexture {
  102856. /**
  102857. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  102858. * 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.
  102859. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  102860. */
  102861. refractionPlane: Plane;
  102862. /**
  102863. * Define how deep under the surface we should see.
  102864. */
  102865. depth: number;
  102866. /**
  102867. * Creates a refraction texture used by refraction channel of the standard material.
  102868. * It is like a mirror but to see through a material.
  102869. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  102870. * @param name Define the texture name
  102871. * @param size Define the size of the underlying texture
  102872. * @param scene Define the scene the refraction belongs to
  102873. * @param generateMipMaps Define if we need to generate mips level for the refraction
  102874. */
  102875. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  102876. /**
  102877. * Clone the refraction texture.
  102878. * @returns the cloned texture
  102879. */
  102880. clone(): RefractionTexture;
  102881. /**
  102882. * Serialize the texture to a JSON representation you could use in Parse later on
  102883. * @returns the serialized JSON representation
  102884. */
  102885. serialize(): any;
  102886. }
  102887. }
  102888. declare module BABYLON {
  102889. /**
  102890. * Configuration for Draco compression
  102891. */
  102892. export interface IDracoCompressionConfiguration {
  102893. /**
  102894. * Configuration for the decoder.
  102895. */
  102896. decoder?: {
  102897. /**
  102898. * The url to the WebAssembly module.
  102899. */
  102900. wasmUrl?: string;
  102901. /**
  102902. * The url to the WebAssembly binary.
  102903. */
  102904. wasmBinaryUrl?: string;
  102905. /**
  102906. * The url to the fallback JavaScript module.
  102907. */
  102908. fallbackUrl?: string;
  102909. };
  102910. }
  102911. /**
  102912. * Draco compression (https://google.github.io/draco/)
  102913. *
  102914. * This class wraps the Draco module.
  102915. *
  102916. * **Encoder**
  102917. *
  102918. * The encoder is not currently implemented.
  102919. *
  102920. * **Decoder**
  102921. *
  102922. * 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.
  102923. *
  102924. * To update the configuration, use the following code:
  102925. * ```javascript
  102926. * DracoCompression.Configuration = {
  102927. * decoder: {
  102928. * wasmUrl: "<url to the WebAssembly library>",
  102929. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  102930. * fallbackUrl: "<url to the fallback JavaScript library>",
  102931. * }
  102932. * };
  102933. * ```
  102934. *
  102935. * 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.
  102936. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  102937. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  102938. *
  102939. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  102940. * ```javascript
  102941. * var dracoCompression = new DracoCompression();
  102942. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  102943. * [VertexBuffer.PositionKind]: 0
  102944. * });
  102945. * ```
  102946. *
  102947. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  102948. */
  102949. export class DracoCompression implements IDisposable {
  102950. private static _DecoderModulePromise;
  102951. /**
  102952. * The configuration. Defaults to the following urls:
  102953. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  102954. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  102955. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  102956. */
  102957. static Configuration: IDracoCompressionConfiguration;
  102958. /**
  102959. * Returns true if the decoder is available.
  102960. */
  102961. static readonly DecoderAvailable: boolean;
  102962. /**
  102963. * Constructor
  102964. */
  102965. constructor();
  102966. /**
  102967. * Stop all async operations and release resources.
  102968. */
  102969. dispose(): void;
  102970. /**
  102971. * Decode Draco compressed mesh data to vertex data.
  102972. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  102973. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  102974. * @returns A promise that resolves with the decoded vertex data
  102975. */
  102976. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  102977. [kind: string]: number;
  102978. }): Promise<VertexData>;
  102979. private static _GetDecoderModule;
  102980. private static _LoadScriptAsync;
  102981. private static _LoadFileAsync;
  102982. }
  102983. }
  102984. declare module BABYLON {
  102985. /**
  102986. * Class for building Constructive Solid Geometry
  102987. */
  102988. export class CSG {
  102989. private polygons;
  102990. /**
  102991. * The world matrix
  102992. */
  102993. matrix: Matrix;
  102994. /**
  102995. * Stores the position
  102996. */
  102997. position: Vector3;
  102998. /**
  102999. * Stores the rotation
  103000. */
  103001. rotation: Vector3;
  103002. /**
  103003. * Stores the rotation quaternion
  103004. */
  103005. rotationQuaternion: Nullable<Quaternion>;
  103006. /**
  103007. * Stores the scaling vector
  103008. */
  103009. scaling: Vector3;
  103010. /**
  103011. * Convert the Mesh to CSG
  103012. * @param mesh The Mesh to convert to CSG
  103013. * @returns A new CSG from the Mesh
  103014. */
  103015. static FromMesh(mesh: Mesh): CSG;
  103016. /**
  103017. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  103018. * @param polygons Polygons used to construct a CSG solid
  103019. */
  103020. private static FromPolygons;
  103021. /**
  103022. * Clones, or makes a deep copy, of the CSG
  103023. * @returns A new CSG
  103024. */
  103025. clone(): CSG;
  103026. /**
  103027. * Unions this CSG with another CSG
  103028. * @param csg The CSG to union against this CSG
  103029. * @returns The unioned CSG
  103030. */
  103031. union(csg: CSG): CSG;
  103032. /**
  103033. * Unions this CSG with another CSG in place
  103034. * @param csg The CSG to union against this CSG
  103035. */
  103036. unionInPlace(csg: CSG): void;
  103037. /**
  103038. * Subtracts this CSG with another CSG
  103039. * @param csg The CSG to subtract against this CSG
  103040. * @returns A new CSG
  103041. */
  103042. subtract(csg: CSG): CSG;
  103043. /**
  103044. * Subtracts this CSG with another CSG in place
  103045. * @param csg The CSG to subtact against this CSG
  103046. */
  103047. subtractInPlace(csg: CSG): void;
  103048. /**
  103049. * Intersect this CSG with another CSG
  103050. * @param csg The CSG to intersect against this CSG
  103051. * @returns A new CSG
  103052. */
  103053. intersect(csg: CSG): CSG;
  103054. /**
  103055. * Intersects this CSG with another CSG in place
  103056. * @param csg The CSG to intersect against this CSG
  103057. */
  103058. intersectInPlace(csg: CSG): void;
  103059. /**
  103060. * Return a new CSG solid with solid and empty space switched. This solid is
  103061. * not modified.
  103062. * @returns A new CSG solid with solid and empty space switched
  103063. */
  103064. inverse(): CSG;
  103065. /**
  103066. * Inverses the CSG in place
  103067. */
  103068. inverseInPlace(): void;
  103069. /**
  103070. * This is used to keep meshes transformations so they can be restored
  103071. * when we build back a Babylon Mesh
  103072. * NB : All CSG operations are performed in world coordinates
  103073. * @param csg The CSG to copy the transform attributes from
  103074. * @returns This CSG
  103075. */
  103076. copyTransformAttributes(csg: CSG): CSG;
  103077. /**
  103078. * Build Raw mesh from CSG
  103079. * Coordinates here are in world space
  103080. * @param name The name of the mesh geometry
  103081. * @param scene The Scene
  103082. * @param keepSubMeshes Specifies if the submeshes should be kept
  103083. * @returns A new Mesh
  103084. */
  103085. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  103086. /**
  103087. * Build Mesh from CSG taking material and transforms into account
  103088. * @param name The name of the Mesh
  103089. * @param material The material of the Mesh
  103090. * @param scene The Scene
  103091. * @param keepSubMeshes Specifies if submeshes should be kept
  103092. * @returns The new Mesh
  103093. */
  103094. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  103095. }
  103096. }
  103097. declare module BABYLON {
  103098. /**
  103099. * Class containing static functions to help procedurally build meshes
  103100. */
  103101. export class RibbonBuilder {
  103102. /**
  103103. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  103104. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  103105. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  103106. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  103107. * * 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
  103108. * * 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
  103109. * * 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
  103110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103112. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103113. * * 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
  103114. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  103115. * * 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
  103116. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  103117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103118. * @param name defines the name of the mesh
  103119. * @param options defines the options used to create the mesh
  103120. * @param scene defines the hosting scene
  103121. * @returns the ribbon mesh
  103122. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  103123. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103124. */
  103125. static CreateRibbon(name: string, options: {
  103126. pathArray: Vector3[][];
  103127. closeArray?: boolean;
  103128. closePath?: boolean;
  103129. offset?: number;
  103130. updatable?: boolean;
  103131. sideOrientation?: number;
  103132. frontUVs?: Vector4;
  103133. backUVs?: Vector4;
  103134. instance?: Mesh;
  103135. invertUV?: boolean;
  103136. uvs?: Vector2[];
  103137. colors?: Color4[];
  103138. }, scene?: Nullable<Scene>): Mesh;
  103139. }
  103140. }
  103141. declare module BABYLON {
  103142. /**
  103143. * Class containing static functions to help procedurally build meshes
  103144. */
  103145. export class TorusKnotBuilder {
  103146. /**
  103147. * Creates a torus knot mesh
  103148. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  103149. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  103150. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  103151. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  103152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103153. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103155. * @param name defines the name of the mesh
  103156. * @param options defines the options used to create the mesh
  103157. * @param scene defines the hosting scene
  103158. * @returns the torus knot mesh
  103159. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  103160. */
  103161. static CreateTorusKnot(name: string, options: {
  103162. radius?: number;
  103163. tube?: number;
  103164. radialSegments?: number;
  103165. tubularSegments?: number;
  103166. p?: number;
  103167. q?: number;
  103168. updatable?: boolean;
  103169. sideOrientation?: number;
  103170. frontUVs?: Vector4;
  103171. backUVs?: Vector4;
  103172. }, scene: any): Mesh;
  103173. }
  103174. }
  103175. declare module BABYLON {
  103176. /**
  103177. * Polygon
  103178. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  103179. */
  103180. export class Polygon {
  103181. /**
  103182. * Creates a rectangle
  103183. * @param xmin bottom X coord
  103184. * @param ymin bottom Y coord
  103185. * @param xmax top X coord
  103186. * @param ymax top Y coord
  103187. * @returns points that make the resulting rectation
  103188. */
  103189. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  103190. /**
  103191. * Creates a circle
  103192. * @param radius radius of circle
  103193. * @param cx scale in x
  103194. * @param cy scale in y
  103195. * @param numberOfSides number of sides that make up the circle
  103196. * @returns points that make the resulting circle
  103197. */
  103198. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  103199. /**
  103200. * Creates a polygon from input string
  103201. * @param input Input polygon data
  103202. * @returns the parsed points
  103203. */
  103204. static Parse(input: string): Vector2[];
  103205. /**
  103206. * Starts building a polygon from x and y coordinates
  103207. * @param x x coordinate
  103208. * @param y y coordinate
  103209. * @returns the started path2
  103210. */
  103211. static StartingAt(x: number, y: number): Path2;
  103212. }
  103213. /**
  103214. * Builds a polygon
  103215. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  103216. */
  103217. export class PolygonMeshBuilder {
  103218. private _points;
  103219. private _outlinepoints;
  103220. private _holes;
  103221. private _name;
  103222. private _scene;
  103223. private _epoints;
  103224. private _eholes;
  103225. private _addToepoint;
  103226. /**
  103227. * Babylon reference to the earcut plugin.
  103228. */
  103229. bjsEarcut: any;
  103230. /**
  103231. * Creates a PolygonMeshBuilder
  103232. * @param name name of the builder
  103233. * @param contours Path of the polygon
  103234. * @param scene scene to add to
  103235. * @param earcutInjection can be used to inject your own earcut reference
  103236. */
  103237. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  103238. /**
  103239. * Adds a whole within the polygon
  103240. * @param hole Array of points defining the hole
  103241. * @returns this
  103242. */
  103243. addHole(hole: Vector2[]): PolygonMeshBuilder;
  103244. /**
  103245. * Creates the polygon
  103246. * @param updatable If the mesh should be updatable
  103247. * @param depth The depth of the mesh created
  103248. * @returns the created mesh
  103249. */
  103250. build(updatable?: boolean, depth?: number): Mesh;
  103251. /**
  103252. * Adds a side to the polygon
  103253. * @param positions points that make the polygon
  103254. * @param normals normals of the polygon
  103255. * @param uvs uvs of the polygon
  103256. * @param indices indices of the polygon
  103257. * @param bounds bounds of the polygon
  103258. * @param points points of the polygon
  103259. * @param depth depth of the polygon
  103260. * @param flip flip of the polygon
  103261. */
  103262. private addSide;
  103263. }
  103264. }
  103265. declare module BABYLON {
  103266. /**
  103267. * Class containing static functions to help procedurally build meshes
  103268. */
  103269. export class PolygonBuilder {
  103270. /**
  103271. * Creates a polygon mesh
  103272. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  103273. * * 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
  103274. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103276. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  103277. * * Remember you can only change the shape positions, not their number when updating a polygon
  103278. * @param name defines the name of the mesh
  103279. * @param options defines the options used to create the mesh
  103280. * @param scene defines the hosting scene
  103281. * @param earcutInjection can be used to inject your own earcut reference
  103282. * @returns the polygon mesh
  103283. */
  103284. static CreatePolygon(name: string, options: {
  103285. shape: Vector3[];
  103286. holes?: Vector3[][];
  103287. depth?: number;
  103288. faceUV?: Vector4[];
  103289. faceColors?: Color4[];
  103290. updatable?: boolean;
  103291. sideOrientation?: number;
  103292. frontUVs?: Vector4;
  103293. backUVs?: Vector4;
  103294. }, scene: Scene, earcutInjection?: any): Mesh;
  103295. /**
  103296. * Creates an extruded polygon mesh, with depth in the Y direction.
  103297. * * 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)
  103298. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  103299. * @param name defines the name of the mesh
  103300. * @param options defines the options used to create the mesh
  103301. * @param scene defines the hosting scene
  103302. * @param earcutInjection can be used to inject your own earcut reference
  103303. * @returns the polygon mesh
  103304. */
  103305. static ExtrudePolygon(name: string, options: {
  103306. shape: Vector3[];
  103307. holes?: Vector3[][];
  103308. depth?: number;
  103309. faceUV?: Vector4[];
  103310. faceColors?: Color4[];
  103311. updatable?: boolean;
  103312. sideOrientation?: number;
  103313. frontUVs?: Vector4;
  103314. backUVs?: Vector4;
  103315. }, scene: Scene, earcutInjection?: any): Mesh;
  103316. }
  103317. }
  103318. declare module BABYLON {
  103319. /**
  103320. * Class containing static functions to help procedurally build meshes
  103321. */
  103322. export class ShapeBuilder {
  103323. /**
  103324. * 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.
  103325. * * 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.
  103326. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103327. * * 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.
  103328. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  103329. * * 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
  103330. * * 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
  103331. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  103332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103333. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103334. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  103335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103336. * @param name defines the name of the mesh
  103337. * @param options defines the options used to create the mesh
  103338. * @param scene defines the hosting scene
  103339. * @returns the extruded shape mesh
  103340. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103341. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  103342. */
  103343. static ExtrudeShape(name: string, options: {
  103344. shape: Vector3[];
  103345. path: Vector3[];
  103346. scale?: number;
  103347. rotation?: number;
  103348. cap?: number;
  103349. updatable?: boolean;
  103350. sideOrientation?: number;
  103351. frontUVs?: Vector4;
  103352. backUVs?: Vector4;
  103353. instance?: Mesh;
  103354. invertUV?: boolean;
  103355. }, scene?: Nullable<Scene>): Mesh;
  103356. /**
  103357. * Creates an custom extruded shape mesh.
  103358. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  103359. * * 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.
  103360. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103361. * * 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
  103362. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  103363. * * 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
  103364. * * It must returns a float value that will be the scale value applied to the shape on each path point
  103365. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  103366. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  103367. * * 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
  103368. * * 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
  103369. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  103370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103372. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103374. * @param name defines the name of the mesh
  103375. * @param options defines the options used to create the mesh
  103376. * @param scene defines the hosting scene
  103377. * @returns the custom extruded shape mesh
  103378. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  103379. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103380. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  103381. */
  103382. static ExtrudeShapeCustom(name: string, options: {
  103383. shape: Vector3[];
  103384. path: Vector3[];
  103385. scaleFunction?: any;
  103386. rotationFunction?: any;
  103387. ribbonCloseArray?: boolean;
  103388. ribbonClosePath?: boolean;
  103389. cap?: number;
  103390. updatable?: boolean;
  103391. sideOrientation?: number;
  103392. frontUVs?: Vector4;
  103393. backUVs?: Vector4;
  103394. instance?: Mesh;
  103395. invertUV?: boolean;
  103396. }, scene: Scene): Mesh;
  103397. private static _ExtrudeShapeGeneric;
  103398. }
  103399. }
  103400. declare module BABYLON {
  103401. /**
  103402. * Class containing static functions to help procedurally build meshes
  103403. */
  103404. export class LatheBuilder {
  103405. /**
  103406. * Creates lathe mesh.
  103407. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  103408. * * 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
  103409. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  103410. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  103411. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  103412. * * 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
  103413. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  103414. * * 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
  103415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103416. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103417. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103419. * @param name defines the name of the mesh
  103420. * @param options defines the options used to create the mesh
  103421. * @param scene defines the hosting scene
  103422. * @returns the lathe mesh
  103423. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  103424. */
  103425. static CreateLathe(name: string, options: {
  103426. shape: Vector3[];
  103427. radius?: number;
  103428. tessellation?: number;
  103429. clip?: number;
  103430. arc?: number;
  103431. closed?: boolean;
  103432. updatable?: boolean;
  103433. sideOrientation?: number;
  103434. frontUVs?: Vector4;
  103435. backUVs?: Vector4;
  103436. cap?: number;
  103437. invertUV?: boolean;
  103438. }, scene: Scene): Mesh;
  103439. }
  103440. }
  103441. declare module BABYLON {
  103442. /**
  103443. * Class containing static functions to help procedurally build meshes
  103444. */
  103445. export class TubeBuilder {
  103446. /**
  103447. * Creates a tube mesh.
  103448. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  103449. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  103450. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  103451. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  103452. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  103453. * * 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)
  103454. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  103455. * * 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
  103456. * * 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
  103457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103459. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103461. * @param name defines the name of the mesh
  103462. * @param options defines the options used to create the mesh
  103463. * @param scene defines the hosting scene
  103464. * @returns the tube mesh
  103465. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103466. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  103467. */
  103468. static CreateTube(name: string, options: {
  103469. path: Vector3[];
  103470. radius?: number;
  103471. tessellation?: number;
  103472. radiusFunction?: {
  103473. (i: number, distance: number): number;
  103474. };
  103475. cap?: number;
  103476. arc?: number;
  103477. updatable?: boolean;
  103478. sideOrientation?: number;
  103479. frontUVs?: Vector4;
  103480. backUVs?: Vector4;
  103481. instance?: Mesh;
  103482. invertUV?: boolean;
  103483. }, scene: Scene): Mesh;
  103484. }
  103485. }
  103486. declare module BABYLON {
  103487. /**
  103488. * Class containing static functions to help procedurally build meshes
  103489. */
  103490. export class IcoSphereBuilder {
  103491. /**
  103492. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  103493. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  103494. * * 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`)
  103495. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  103496. * * 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
  103497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103500. * @param name defines the name of the mesh
  103501. * @param options defines the options used to create the mesh
  103502. * @param scene defines the hosting scene
  103503. * @returns the icosahedron mesh
  103504. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  103505. */
  103506. static CreateIcoSphere(name: string, options: {
  103507. radius?: number;
  103508. radiusX?: number;
  103509. radiusY?: number;
  103510. radiusZ?: number;
  103511. flat?: boolean;
  103512. subdivisions?: number;
  103513. sideOrientation?: number;
  103514. frontUVs?: Vector4;
  103515. backUVs?: Vector4;
  103516. updatable?: boolean;
  103517. }, scene: Scene): Mesh;
  103518. }
  103519. }
  103520. declare module BABYLON {
  103521. /**
  103522. * Class containing static functions to help procedurally build meshes
  103523. */
  103524. export class DecalBuilder {
  103525. /**
  103526. * Creates a decal mesh.
  103527. * 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
  103528. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  103529. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  103530. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  103531. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  103532. * @param name defines the name of the mesh
  103533. * @param sourceMesh defines the mesh where the decal must be applied
  103534. * @param options defines the options used to create the mesh
  103535. * @param scene defines the hosting scene
  103536. * @returns the decal mesh
  103537. * @see https://doc.babylonjs.com/how_to/decals
  103538. */
  103539. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  103540. position?: Vector3;
  103541. normal?: Vector3;
  103542. size?: Vector3;
  103543. angle?: number;
  103544. }): Mesh;
  103545. }
  103546. }
  103547. declare module BABYLON {
  103548. /**
  103549. * Class containing static functions to help procedurally build meshes
  103550. */
  103551. export class MeshBuilder {
  103552. /**
  103553. * Creates a box mesh
  103554. * * The parameter `size` sets the size (float) of each box side (default 1)
  103555. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  103556. * * 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)
  103557. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  103558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103559. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103561. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  103562. * @param name defines the name of the mesh
  103563. * @param options defines the options used to create the mesh
  103564. * @param scene defines the hosting scene
  103565. * @returns the box mesh
  103566. */
  103567. static CreateBox(name: string, options: {
  103568. size?: number;
  103569. width?: number;
  103570. height?: number;
  103571. depth?: number;
  103572. faceUV?: Vector4[];
  103573. faceColors?: Color4[];
  103574. sideOrientation?: number;
  103575. frontUVs?: Vector4;
  103576. backUVs?: Vector4;
  103577. updatable?: boolean;
  103578. }, scene?: Nullable<Scene>): Mesh;
  103579. /**
  103580. * Creates a sphere mesh
  103581. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  103582. * * 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`)
  103583. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  103584. * * 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
  103585. * * 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)
  103586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103587. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103589. * @param name defines the name of the mesh
  103590. * @param options defines the options used to create the mesh
  103591. * @param scene defines the hosting scene
  103592. * @returns the sphere mesh
  103593. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  103594. */
  103595. static CreateSphere(name: string, options: {
  103596. segments?: number;
  103597. diameter?: number;
  103598. diameterX?: number;
  103599. diameterY?: number;
  103600. diameterZ?: number;
  103601. arc?: number;
  103602. slice?: number;
  103603. sideOrientation?: number;
  103604. frontUVs?: Vector4;
  103605. backUVs?: Vector4;
  103606. updatable?: boolean;
  103607. }, scene: any): Mesh;
  103608. /**
  103609. * Creates a plane polygonal mesh. By default, this is a disc
  103610. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  103611. * * 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
  103612. * * 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
  103613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103614. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103616. * @param name defines the name of the mesh
  103617. * @param options defines the options used to create the mesh
  103618. * @param scene defines the hosting scene
  103619. * @returns the plane polygonal mesh
  103620. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  103621. */
  103622. static CreateDisc(name: string, options: {
  103623. radius?: number;
  103624. tessellation?: number;
  103625. arc?: number;
  103626. updatable?: boolean;
  103627. sideOrientation?: number;
  103628. frontUVs?: Vector4;
  103629. backUVs?: Vector4;
  103630. }, scene?: Nullable<Scene>): Mesh;
  103631. /**
  103632. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  103633. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  103634. * * 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`)
  103635. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  103636. * * 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
  103637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103640. * @param name defines the name of the mesh
  103641. * @param options defines the options used to create the mesh
  103642. * @param scene defines the hosting scene
  103643. * @returns the icosahedron mesh
  103644. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  103645. */
  103646. static CreateIcoSphere(name: string, options: {
  103647. radius?: number;
  103648. radiusX?: number;
  103649. radiusY?: number;
  103650. radiusZ?: number;
  103651. flat?: boolean;
  103652. subdivisions?: number;
  103653. sideOrientation?: number;
  103654. frontUVs?: Vector4;
  103655. backUVs?: Vector4;
  103656. updatable?: boolean;
  103657. }, scene: Scene): Mesh;
  103658. /**
  103659. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  103660. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  103661. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  103662. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  103663. * * 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
  103664. * * 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
  103665. * * 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
  103666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103667. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103668. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103669. * * 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
  103670. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  103671. * * 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
  103672. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  103673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103674. * @param name defines the name of the mesh
  103675. * @param options defines the options used to create the mesh
  103676. * @param scene defines the hosting scene
  103677. * @returns the ribbon mesh
  103678. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  103679. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103680. */
  103681. static CreateRibbon(name: string, options: {
  103682. pathArray: Vector3[][];
  103683. closeArray?: boolean;
  103684. closePath?: boolean;
  103685. offset?: number;
  103686. updatable?: boolean;
  103687. sideOrientation?: number;
  103688. frontUVs?: Vector4;
  103689. backUVs?: Vector4;
  103690. instance?: Mesh;
  103691. invertUV?: boolean;
  103692. uvs?: Vector2[];
  103693. colors?: Color4[];
  103694. }, scene?: Nullable<Scene>): Mesh;
  103695. /**
  103696. * Creates a cylinder or a cone mesh
  103697. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  103698. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  103699. * * 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.
  103700. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  103701. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  103702. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  103703. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  103704. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  103705. * * 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).
  103706. * * 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
  103707. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  103708. * * 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
  103709. * * 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.
  103710. * * If `enclose` is false, a ring surface is one element.
  103711. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  103712. * * 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
  103713. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103714. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103716. * @param name defines the name of the mesh
  103717. * @param options defines the options used to create the mesh
  103718. * @param scene defines the hosting scene
  103719. * @returns the cylinder mesh
  103720. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  103721. */
  103722. static CreateCylinder(name: string, options: {
  103723. height?: number;
  103724. diameterTop?: number;
  103725. diameterBottom?: number;
  103726. diameter?: number;
  103727. tessellation?: number;
  103728. subdivisions?: number;
  103729. arc?: number;
  103730. faceColors?: Color4[];
  103731. faceUV?: Vector4[];
  103732. updatable?: boolean;
  103733. hasRings?: boolean;
  103734. enclose?: boolean;
  103735. sideOrientation?: number;
  103736. frontUVs?: Vector4;
  103737. backUVs?: Vector4;
  103738. }, scene: any): Mesh;
  103739. /**
  103740. * Creates a torus mesh
  103741. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  103742. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  103743. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  103744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103745. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103747. * @param name defines the name of the mesh
  103748. * @param options defines the options used to create the mesh
  103749. * @param scene defines the hosting scene
  103750. * @returns the torus mesh
  103751. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  103752. */
  103753. static CreateTorus(name: string, options: {
  103754. diameter?: number;
  103755. thickness?: number;
  103756. tessellation?: number;
  103757. updatable?: boolean;
  103758. sideOrientation?: number;
  103759. frontUVs?: Vector4;
  103760. backUVs?: Vector4;
  103761. }, scene: any): Mesh;
  103762. /**
  103763. * Creates a torus knot mesh
  103764. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  103765. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  103766. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  103767. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  103768. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103769. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103771. * @param name defines the name of the mesh
  103772. * @param options defines the options used to create the mesh
  103773. * @param scene defines the hosting scene
  103774. * @returns the torus knot mesh
  103775. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  103776. */
  103777. static CreateTorusKnot(name: string, options: {
  103778. radius?: number;
  103779. tube?: number;
  103780. radialSegments?: number;
  103781. tubularSegments?: number;
  103782. p?: number;
  103783. q?: number;
  103784. updatable?: boolean;
  103785. sideOrientation?: number;
  103786. frontUVs?: Vector4;
  103787. backUVs?: Vector4;
  103788. }, scene: any): Mesh;
  103789. /**
  103790. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  103791. * * 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
  103792. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  103793. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  103794. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  103795. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  103796. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  103797. * * 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
  103798. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  103799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103800. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  103801. * @param name defines the name of the new line system
  103802. * @param options defines the options used to create the line system
  103803. * @param scene defines the hosting scene
  103804. * @returns a new line system mesh
  103805. */
  103806. static CreateLineSystem(name: string, options: {
  103807. lines: Vector3[][];
  103808. updatable?: boolean;
  103809. instance?: Nullable<LinesMesh>;
  103810. colors?: Nullable<Color4[][]>;
  103811. useVertexAlpha?: boolean;
  103812. }, scene: Nullable<Scene>): LinesMesh;
  103813. /**
  103814. * Creates a line mesh
  103815. * 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
  103816. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103817. * * The parameter `points` is an array successive Vector3
  103818. * * 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
  103819. * * The optional parameter `colors` is an array of successive Color4, one per line point
  103820. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  103821. * * When updating an instance, remember that only point positions can change, not the number of points
  103822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103823. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  103824. * @param name defines the name of the new line system
  103825. * @param options defines the options used to create the line system
  103826. * @param scene defines the hosting scene
  103827. * @returns a new line mesh
  103828. */
  103829. static CreateLines(name: string, options: {
  103830. points: Vector3[];
  103831. updatable?: boolean;
  103832. instance?: Nullable<LinesMesh>;
  103833. colors?: Color4[];
  103834. useVertexAlpha?: boolean;
  103835. }, scene?: Nullable<Scene>): LinesMesh;
  103836. /**
  103837. * Creates a dashed line mesh
  103838. * * 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
  103839. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103840. * * The parameter `points` is an array successive Vector3
  103841. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  103842. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  103843. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  103844. * * 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
  103845. * * When updating an instance, remember that only point positions can change, not the number of points
  103846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103847. * @param name defines the name of the mesh
  103848. * @param options defines the options used to create the mesh
  103849. * @param scene defines the hosting scene
  103850. * @returns the dashed line mesh
  103851. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  103852. */
  103853. static CreateDashedLines(name: string, options: {
  103854. points: Vector3[];
  103855. dashSize?: number;
  103856. gapSize?: number;
  103857. dashNb?: number;
  103858. updatable?: boolean;
  103859. instance?: LinesMesh;
  103860. }, scene?: Nullable<Scene>): LinesMesh;
  103861. /**
  103862. * 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.
  103863. * * 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.
  103864. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103865. * * 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.
  103866. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  103867. * * 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
  103868. * * 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
  103869. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  103870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103871. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103872. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  103873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103874. * @param name defines the name of the mesh
  103875. * @param options defines the options used to create the mesh
  103876. * @param scene defines the hosting scene
  103877. * @returns the extruded shape mesh
  103878. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103879. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  103880. */
  103881. static ExtrudeShape(name: string, options: {
  103882. shape: Vector3[];
  103883. path: Vector3[];
  103884. scale?: number;
  103885. rotation?: number;
  103886. cap?: number;
  103887. updatable?: boolean;
  103888. sideOrientation?: number;
  103889. frontUVs?: Vector4;
  103890. backUVs?: Vector4;
  103891. instance?: Mesh;
  103892. invertUV?: boolean;
  103893. }, scene?: Nullable<Scene>): Mesh;
  103894. /**
  103895. * Creates an custom extruded shape mesh.
  103896. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  103897. * * 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.
  103898. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103899. * * 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
  103900. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  103901. * * 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
  103902. * * It must returns a float value that will be the scale value applied to the shape on each path point
  103903. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  103904. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  103905. * * 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
  103906. * * 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
  103907. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  103908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103909. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103910. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103912. * @param name defines the name of the mesh
  103913. * @param options defines the options used to create the mesh
  103914. * @param scene defines the hosting scene
  103915. * @returns the custom extruded shape mesh
  103916. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  103917. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103918. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  103919. */
  103920. static ExtrudeShapeCustom(name: string, options: {
  103921. shape: Vector3[];
  103922. path: Vector3[];
  103923. scaleFunction?: any;
  103924. rotationFunction?: any;
  103925. ribbonCloseArray?: boolean;
  103926. ribbonClosePath?: boolean;
  103927. cap?: number;
  103928. updatable?: boolean;
  103929. sideOrientation?: number;
  103930. frontUVs?: Vector4;
  103931. backUVs?: Vector4;
  103932. instance?: Mesh;
  103933. invertUV?: boolean;
  103934. }, scene: Scene): Mesh;
  103935. /**
  103936. * Creates lathe mesh.
  103937. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  103938. * * 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
  103939. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  103940. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  103941. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  103942. * * 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
  103943. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  103944. * * 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
  103945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103947. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103949. * @param name defines the name of the mesh
  103950. * @param options defines the options used to create the mesh
  103951. * @param scene defines the hosting scene
  103952. * @returns the lathe mesh
  103953. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  103954. */
  103955. static CreateLathe(name: string, options: {
  103956. shape: Vector3[];
  103957. radius?: number;
  103958. tessellation?: number;
  103959. clip?: number;
  103960. arc?: number;
  103961. closed?: boolean;
  103962. updatable?: boolean;
  103963. sideOrientation?: number;
  103964. frontUVs?: Vector4;
  103965. backUVs?: Vector4;
  103966. cap?: number;
  103967. invertUV?: boolean;
  103968. }, scene: Scene): Mesh;
  103969. /**
  103970. * Creates a plane mesh
  103971. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  103972. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  103973. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  103974. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103975. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103977. * @param name defines the name of the mesh
  103978. * @param options defines the options used to create the mesh
  103979. * @param scene defines the hosting scene
  103980. * @returns the plane mesh
  103981. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  103982. */
  103983. static CreatePlane(name: string, options: {
  103984. size?: number;
  103985. width?: number;
  103986. height?: number;
  103987. sideOrientation?: number;
  103988. frontUVs?: Vector4;
  103989. backUVs?: Vector4;
  103990. updatable?: boolean;
  103991. sourcePlane?: Plane;
  103992. }, scene: Scene): Mesh;
  103993. /**
  103994. * Creates a ground mesh
  103995. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  103996. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  103997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103998. * @param name defines the name of the mesh
  103999. * @param options defines the options used to create the mesh
  104000. * @param scene defines the hosting scene
  104001. * @returns the ground mesh
  104002. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  104003. */
  104004. static CreateGround(name: string, options: {
  104005. width?: number;
  104006. height?: number;
  104007. subdivisions?: number;
  104008. subdivisionsX?: number;
  104009. subdivisionsY?: number;
  104010. updatable?: boolean;
  104011. }, scene: any): Mesh;
  104012. /**
  104013. * Creates a tiled ground mesh
  104014. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  104015. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  104016. * * 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
  104017. * * 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
  104018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104019. * @param name defines the name of the mesh
  104020. * @param options defines the options used to create the mesh
  104021. * @param scene defines the hosting scene
  104022. * @returns the tiled ground mesh
  104023. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  104024. */
  104025. static CreateTiledGround(name: string, options: {
  104026. xmin: number;
  104027. zmin: number;
  104028. xmax: number;
  104029. zmax: number;
  104030. subdivisions?: {
  104031. w: number;
  104032. h: number;
  104033. };
  104034. precision?: {
  104035. w: number;
  104036. h: number;
  104037. };
  104038. updatable?: boolean;
  104039. }, scene: Scene): Mesh;
  104040. /**
  104041. * Creates a ground mesh from a height map
  104042. * * The parameter `url` sets the URL of the height map image resource.
  104043. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  104044. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  104045. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  104046. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  104047. * * 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.
  104048. * * 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).
  104049. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  104050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104051. * @param name defines the name of the mesh
  104052. * @param url defines the url to the height map
  104053. * @param options defines the options used to create the mesh
  104054. * @param scene defines the hosting scene
  104055. * @returns the ground mesh
  104056. * @see https://doc.babylonjs.com/babylon101/height_map
  104057. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  104058. */
  104059. static CreateGroundFromHeightMap(name: string, url: string, options: {
  104060. width?: number;
  104061. height?: number;
  104062. subdivisions?: number;
  104063. minHeight?: number;
  104064. maxHeight?: number;
  104065. colorFilter?: Color3;
  104066. alphaFilter?: number;
  104067. updatable?: boolean;
  104068. onReady?: (mesh: GroundMesh) => void;
  104069. }, scene: Scene): GroundMesh;
  104070. /**
  104071. * Creates a polygon mesh
  104072. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  104073. * * 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
  104074. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104076. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  104077. * * Remember you can only change the shape positions, not their number when updating a polygon
  104078. * @param name defines the name of the mesh
  104079. * @param options defines the options used to create the mesh
  104080. * @param scene defines the hosting scene
  104081. * @param earcutInjection can be used to inject your own earcut reference
  104082. * @returns the polygon mesh
  104083. */
  104084. static CreatePolygon(name: string, options: {
  104085. shape: Vector3[];
  104086. holes?: Vector3[][];
  104087. depth?: number;
  104088. faceUV?: Vector4[];
  104089. faceColors?: Color4[];
  104090. updatable?: boolean;
  104091. sideOrientation?: number;
  104092. frontUVs?: Vector4;
  104093. backUVs?: Vector4;
  104094. }, scene: Scene, earcutInjection?: any): Mesh;
  104095. /**
  104096. * Creates an extruded polygon mesh, with depth in the Y direction.
  104097. * * 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)
  104098. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104099. * @param name defines the name of the mesh
  104100. * @param options defines the options used to create the mesh
  104101. * @param scene defines the hosting scene
  104102. * @param earcutInjection can be used to inject your own earcut reference
  104103. * @returns the polygon mesh
  104104. */
  104105. static ExtrudePolygon(name: string, options: {
  104106. shape: Vector3[];
  104107. holes?: Vector3[][];
  104108. depth?: number;
  104109. faceUV?: Vector4[];
  104110. faceColors?: Color4[];
  104111. updatable?: boolean;
  104112. sideOrientation?: number;
  104113. frontUVs?: Vector4;
  104114. backUVs?: Vector4;
  104115. }, scene: Scene, earcutInjection?: any): Mesh;
  104116. /**
  104117. * Creates a tube mesh.
  104118. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  104119. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  104120. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  104121. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  104122. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  104123. * * 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)
  104124. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  104125. * * 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
  104126. * * 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
  104127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104129. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104131. * @param name defines the name of the mesh
  104132. * @param options defines the options used to create the mesh
  104133. * @param scene defines the hosting scene
  104134. * @returns the tube mesh
  104135. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104136. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  104137. */
  104138. static CreateTube(name: string, options: {
  104139. path: Vector3[];
  104140. radius?: number;
  104141. tessellation?: number;
  104142. radiusFunction?: {
  104143. (i: number, distance: number): number;
  104144. };
  104145. cap?: number;
  104146. arc?: number;
  104147. updatable?: boolean;
  104148. sideOrientation?: number;
  104149. frontUVs?: Vector4;
  104150. backUVs?: Vector4;
  104151. instance?: Mesh;
  104152. invertUV?: boolean;
  104153. }, scene: Scene): Mesh;
  104154. /**
  104155. * Creates a polyhedron mesh
  104156. * * 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
  104157. * * The parameter `size` (positive float, default 1) sets the polygon size
  104158. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  104159. * * 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`
  104160. * * 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
  104161. * * 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)`)
  104162. * * 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
  104163. * * 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
  104164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104167. * @param name defines the name of the mesh
  104168. * @param options defines the options used to create the mesh
  104169. * @param scene defines the hosting scene
  104170. * @returns the polyhedron mesh
  104171. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  104172. */
  104173. static CreatePolyhedron(name: string, options: {
  104174. type?: number;
  104175. size?: number;
  104176. sizeX?: number;
  104177. sizeY?: number;
  104178. sizeZ?: number;
  104179. custom?: any;
  104180. faceUV?: Vector4[];
  104181. faceColors?: Color4[];
  104182. flat?: boolean;
  104183. updatable?: boolean;
  104184. sideOrientation?: number;
  104185. frontUVs?: Vector4;
  104186. backUVs?: Vector4;
  104187. }, scene: Scene): Mesh;
  104188. /**
  104189. * Creates a decal mesh.
  104190. * 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
  104191. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  104192. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  104193. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  104194. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  104195. * @param name defines the name of the mesh
  104196. * @param sourceMesh defines the mesh where the decal must be applied
  104197. * @param options defines the options used to create the mesh
  104198. * @param scene defines the hosting scene
  104199. * @returns the decal mesh
  104200. * @see https://doc.babylonjs.com/how_to/decals
  104201. */
  104202. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  104203. position?: Vector3;
  104204. normal?: Vector3;
  104205. size?: Vector3;
  104206. angle?: number;
  104207. }): Mesh;
  104208. }
  104209. }
  104210. declare module BABYLON {
  104211. /**
  104212. * A simplifier interface for future simplification implementations
  104213. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104214. */
  104215. export interface ISimplifier {
  104216. /**
  104217. * Simplification of a given mesh according to the given settings.
  104218. * Since this requires computation, it is assumed that the function runs async.
  104219. * @param settings The settings of the simplification, including quality and distance
  104220. * @param successCallback A callback that will be called after the mesh was simplified.
  104221. * @param errorCallback in case of an error, this callback will be called. optional.
  104222. */
  104223. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  104224. }
  104225. /**
  104226. * Expected simplification settings.
  104227. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  104228. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104229. */
  104230. export interface ISimplificationSettings {
  104231. /**
  104232. * Gets or sets the expected quality
  104233. */
  104234. quality: number;
  104235. /**
  104236. * Gets or sets the distance when this optimized version should be used
  104237. */
  104238. distance: number;
  104239. /**
  104240. * Gets an already optimized mesh
  104241. */
  104242. optimizeMesh?: boolean;
  104243. }
  104244. /**
  104245. * Class used to specify simplification options
  104246. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104247. */
  104248. export class SimplificationSettings implements ISimplificationSettings {
  104249. /** expected quality */
  104250. quality: number;
  104251. /** distance when this optimized version should be used */
  104252. distance: number;
  104253. /** already optimized mesh */
  104254. optimizeMesh?: boolean | undefined;
  104255. /**
  104256. * Creates a SimplificationSettings
  104257. * @param quality expected quality
  104258. * @param distance distance when this optimized version should be used
  104259. * @param optimizeMesh already optimized mesh
  104260. */
  104261. constructor(
  104262. /** expected quality */
  104263. quality: number,
  104264. /** distance when this optimized version should be used */
  104265. distance: number,
  104266. /** already optimized mesh */
  104267. optimizeMesh?: boolean | undefined);
  104268. }
  104269. /**
  104270. * Interface used to define a simplification task
  104271. */
  104272. export interface ISimplificationTask {
  104273. /**
  104274. * Array of settings
  104275. */
  104276. settings: Array<ISimplificationSettings>;
  104277. /**
  104278. * Simplification type
  104279. */
  104280. simplificationType: SimplificationType;
  104281. /**
  104282. * Mesh to simplify
  104283. */
  104284. mesh: Mesh;
  104285. /**
  104286. * Callback called on success
  104287. */
  104288. successCallback?: () => void;
  104289. /**
  104290. * Defines if parallel processing can be used
  104291. */
  104292. parallelProcessing: boolean;
  104293. }
  104294. /**
  104295. * Queue used to order the simplification tasks
  104296. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104297. */
  104298. export class SimplificationQueue {
  104299. private _simplificationArray;
  104300. /**
  104301. * Gets a boolean indicating that the process is still running
  104302. */
  104303. running: boolean;
  104304. /**
  104305. * Creates a new queue
  104306. */
  104307. constructor();
  104308. /**
  104309. * Adds a new simplification task
  104310. * @param task defines a task to add
  104311. */
  104312. addTask(task: ISimplificationTask): void;
  104313. /**
  104314. * Execute next task
  104315. */
  104316. executeNext(): void;
  104317. /**
  104318. * Execute a simplification task
  104319. * @param task defines the task to run
  104320. */
  104321. runSimplification(task: ISimplificationTask): void;
  104322. private getSimplifier;
  104323. }
  104324. /**
  104325. * The implemented types of simplification
  104326. * At the moment only Quadratic Error Decimation is implemented
  104327. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104328. */
  104329. export enum SimplificationType {
  104330. /** Quadratic error decimation */
  104331. QUADRATIC = 0
  104332. }
  104333. }
  104334. declare module BABYLON {
  104335. interface Scene {
  104336. /** @hidden (Backing field) */
  104337. _simplificationQueue: SimplificationQueue;
  104338. /**
  104339. * Gets or sets the simplification queue attached to the scene
  104340. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104341. */
  104342. simplificationQueue: SimplificationQueue;
  104343. }
  104344. interface Mesh {
  104345. /**
  104346. * Simplify the mesh according to the given array of settings.
  104347. * Function will return immediately and will simplify async
  104348. * @param settings a collection of simplification settings
  104349. * @param parallelProcessing should all levels calculate parallel or one after the other
  104350. * @param simplificationType the type of simplification to run
  104351. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  104352. * @returns the current mesh
  104353. */
  104354. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  104355. }
  104356. /**
  104357. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  104358. * created in a scene
  104359. */
  104360. export class SimplicationQueueSceneComponent implements ISceneComponent {
  104361. /**
  104362. * The component name helpfull to identify the component in the list of scene components.
  104363. */
  104364. readonly name: string;
  104365. /**
  104366. * The scene the component belongs to.
  104367. */
  104368. scene: Scene;
  104369. /**
  104370. * Creates a new instance of the component for the given scene
  104371. * @param scene Defines the scene to register the component in
  104372. */
  104373. constructor(scene: Scene);
  104374. /**
  104375. * Registers the component in a given scene
  104376. */
  104377. register(): void;
  104378. /**
  104379. * Rebuilds the elements related to this component in case of
  104380. * context lost for instance.
  104381. */
  104382. rebuild(): void;
  104383. /**
  104384. * Disposes the component and the associated ressources
  104385. */
  104386. dispose(): void;
  104387. private _beforeCameraUpdate;
  104388. }
  104389. }
  104390. declare module BABYLON {
  104391. /**
  104392. * Class used to enable access to IndexedDB
  104393. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  104394. */
  104395. export class Database implements IOfflineProvider {
  104396. private _callbackManifestChecked;
  104397. private _currentSceneUrl;
  104398. private _db;
  104399. private _enableSceneOffline;
  104400. private _enableTexturesOffline;
  104401. private _manifestVersionFound;
  104402. private _mustUpdateRessources;
  104403. private _hasReachedQuota;
  104404. private _isSupported;
  104405. private _idbFactory;
  104406. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  104407. private static IsUASupportingBlobStorage;
  104408. /**
  104409. * Gets a boolean indicating if Database storate is enabled (off by default)
  104410. */
  104411. static IDBStorageEnabled: boolean;
  104412. /**
  104413. * Gets a boolean indicating if scene must be saved in the database
  104414. */
  104415. readonly enableSceneOffline: boolean;
  104416. /**
  104417. * Gets a boolean indicating if textures must be saved in the database
  104418. */
  104419. readonly enableTexturesOffline: boolean;
  104420. /**
  104421. * Creates a new Database
  104422. * @param urlToScene defines the url to load the scene
  104423. * @param callbackManifestChecked defines the callback to use when manifest is checked
  104424. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  104425. */
  104426. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  104427. private static _ParseURL;
  104428. private static _ReturnFullUrlLocation;
  104429. private _checkManifestFile;
  104430. /**
  104431. * Open the database and make it available
  104432. * @param successCallback defines the callback to call on success
  104433. * @param errorCallback defines the callback to call on error
  104434. */
  104435. open(successCallback: () => void, errorCallback: () => void): void;
  104436. /**
  104437. * Loads an image from the database
  104438. * @param url defines the url to load from
  104439. * @param image defines the target DOM image
  104440. */
  104441. loadImage(url: string, image: HTMLImageElement): void;
  104442. private _loadImageFromDBAsync;
  104443. private _saveImageIntoDBAsync;
  104444. private _checkVersionFromDB;
  104445. private _loadVersionFromDBAsync;
  104446. private _saveVersionIntoDBAsync;
  104447. /**
  104448. * Loads a file from database
  104449. * @param url defines the URL to load from
  104450. * @param sceneLoaded defines a callback to call on success
  104451. * @param progressCallBack defines a callback to call when progress changed
  104452. * @param errorCallback defines a callback to call on error
  104453. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  104454. */
  104455. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  104456. private _loadFileAsync;
  104457. private _saveFileAsync;
  104458. /**
  104459. * Validates if xhr data is correct
  104460. * @param xhr defines the request to validate
  104461. * @param dataType defines the expected data type
  104462. * @returns true if data is correct
  104463. */
  104464. private static _ValidateXHRData;
  104465. }
  104466. }
  104467. declare module BABYLON {
  104468. /** @hidden */
  104469. export var gpuUpdateParticlesPixelShader: {
  104470. name: string;
  104471. shader: string;
  104472. };
  104473. }
  104474. declare module BABYLON {
  104475. /** @hidden */
  104476. export var gpuUpdateParticlesVertexShader: {
  104477. name: string;
  104478. shader: string;
  104479. };
  104480. }
  104481. declare module BABYLON {
  104482. /** @hidden */
  104483. export var clipPlaneFragmentDeclaration2: {
  104484. name: string;
  104485. shader: string;
  104486. };
  104487. }
  104488. declare module BABYLON {
  104489. /** @hidden */
  104490. export var gpuRenderParticlesPixelShader: {
  104491. name: string;
  104492. shader: string;
  104493. };
  104494. }
  104495. declare module BABYLON {
  104496. /** @hidden */
  104497. export var clipPlaneVertexDeclaration2: {
  104498. name: string;
  104499. shader: string;
  104500. };
  104501. }
  104502. declare module BABYLON {
  104503. /** @hidden */
  104504. export var gpuRenderParticlesVertexShader: {
  104505. name: string;
  104506. shader: string;
  104507. };
  104508. }
  104509. declare module BABYLON {
  104510. /**
  104511. * This represents a GPU particle system in Babylon
  104512. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  104513. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  104514. */
  104515. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  104516. /**
  104517. * The layer mask we are rendering the particles through.
  104518. */
  104519. layerMask: number;
  104520. private _capacity;
  104521. private _activeCount;
  104522. private _currentActiveCount;
  104523. private _accumulatedCount;
  104524. private _renderEffect;
  104525. private _updateEffect;
  104526. private _buffer0;
  104527. private _buffer1;
  104528. private _spriteBuffer;
  104529. private _updateVAO;
  104530. private _renderVAO;
  104531. private _targetIndex;
  104532. private _sourceBuffer;
  104533. private _targetBuffer;
  104534. private _engine;
  104535. private _currentRenderId;
  104536. private _started;
  104537. private _stopped;
  104538. private _timeDelta;
  104539. private _randomTexture;
  104540. private _randomTexture2;
  104541. private _attributesStrideSize;
  104542. private _updateEffectOptions;
  104543. private _randomTextureSize;
  104544. private _actualFrame;
  104545. private readonly _rawTextureWidth;
  104546. /**
  104547. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  104548. */
  104549. static readonly IsSupported: boolean;
  104550. /**
  104551. * An event triggered when the system is disposed.
  104552. */
  104553. onDisposeObservable: Observable<GPUParticleSystem>;
  104554. /**
  104555. * Gets the maximum number of particles active at the same time.
  104556. * @returns The max number of active particles.
  104557. */
  104558. getCapacity(): number;
  104559. /**
  104560. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  104561. * to override the particles.
  104562. */
  104563. forceDepthWrite: boolean;
  104564. /**
  104565. * Gets or set the number of active particles
  104566. */
  104567. activeParticleCount: number;
  104568. private _preWarmDone;
  104569. /**
  104570. * Is this system ready to be used/rendered
  104571. * @return true if the system is ready
  104572. */
  104573. isReady(): boolean;
  104574. /**
  104575. * Gets if the system has been started. (Note: this will still be true after stop is called)
  104576. * @returns True if it has been started, otherwise false.
  104577. */
  104578. isStarted(): boolean;
  104579. /**
  104580. * Starts the particle system and begins to emit
  104581. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  104582. */
  104583. start(delay?: number): void;
  104584. /**
  104585. * Stops the particle system.
  104586. */
  104587. stop(): void;
  104588. /**
  104589. * Remove all active particles
  104590. */
  104591. reset(): void;
  104592. /**
  104593. * Returns the string "GPUParticleSystem"
  104594. * @returns a string containing the class name
  104595. */
  104596. getClassName(): string;
  104597. private _colorGradientsTexture;
  104598. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  104599. /**
  104600. * Adds a new color gradient
  104601. * @param gradient defines the gradient to use (between 0 and 1)
  104602. * @param color1 defines the color to affect to the specified gradient
  104603. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  104604. * @returns the current particle system
  104605. */
  104606. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  104607. /**
  104608. * Remove a specific color gradient
  104609. * @param gradient defines the gradient to remove
  104610. * @returns the current particle system
  104611. */
  104612. removeColorGradient(gradient: number): GPUParticleSystem;
  104613. private _angularSpeedGradientsTexture;
  104614. private _sizeGradientsTexture;
  104615. private _velocityGradientsTexture;
  104616. private _limitVelocityGradientsTexture;
  104617. private _dragGradientsTexture;
  104618. private _addFactorGradient;
  104619. /**
  104620. * Adds a new size gradient
  104621. * @param gradient defines the gradient to use (between 0 and 1)
  104622. * @param factor defines the size factor to affect to the specified gradient
  104623. * @returns the current particle system
  104624. */
  104625. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  104626. /**
  104627. * Remove a specific size gradient
  104628. * @param gradient defines the gradient to remove
  104629. * @returns the current particle system
  104630. */
  104631. removeSizeGradient(gradient: number): GPUParticleSystem;
  104632. /**
  104633. * Adds a new angular speed gradient
  104634. * @param gradient defines the gradient to use (between 0 and 1)
  104635. * @param factor defines the angular speed to affect to the specified gradient
  104636. * @returns the current particle system
  104637. */
  104638. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  104639. /**
  104640. * Remove a specific angular speed gradient
  104641. * @param gradient defines the gradient to remove
  104642. * @returns the current particle system
  104643. */
  104644. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  104645. /**
  104646. * Adds a new velocity gradient
  104647. * @param gradient defines the gradient to use (between 0 and 1)
  104648. * @param factor defines the velocity to affect to the specified gradient
  104649. * @returns the current particle system
  104650. */
  104651. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  104652. /**
  104653. * Remove a specific velocity gradient
  104654. * @param gradient defines the gradient to remove
  104655. * @returns the current particle system
  104656. */
  104657. removeVelocityGradient(gradient: number): GPUParticleSystem;
  104658. /**
  104659. * Adds a new limit velocity gradient
  104660. * @param gradient defines the gradient to use (between 0 and 1)
  104661. * @param factor defines the limit velocity value to affect to the specified gradient
  104662. * @returns the current particle system
  104663. */
  104664. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  104665. /**
  104666. * Remove a specific limit velocity gradient
  104667. * @param gradient defines the gradient to remove
  104668. * @returns the current particle system
  104669. */
  104670. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  104671. /**
  104672. * Adds a new drag gradient
  104673. * @param gradient defines the gradient to use (between 0 and 1)
  104674. * @param factor defines the drag value to affect to the specified gradient
  104675. * @returns the current particle system
  104676. */
  104677. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  104678. /**
  104679. * Remove a specific drag gradient
  104680. * @param gradient defines the gradient to remove
  104681. * @returns the current particle system
  104682. */
  104683. removeDragGradient(gradient: number): GPUParticleSystem;
  104684. /**
  104685. * Not supported by GPUParticleSystem
  104686. * @param gradient defines the gradient to use (between 0 and 1)
  104687. * @param factor defines the emit rate value to affect to the specified gradient
  104688. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104689. * @returns the current particle system
  104690. */
  104691. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  104692. /**
  104693. * Not supported by GPUParticleSystem
  104694. * @param gradient defines the gradient to remove
  104695. * @returns the current particle system
  104696. */
  104697. removeEmitRateGradient(gradient: number): IParticleSystem;
  104698. /**
  104699. * Not supported by GPUParticleSystem
  104700. * @param gradient defines the gradient to use (between 0 and 1)
  104701. * @param factor defines the start size value to affect to the specified gradient
  104702. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104703. * @returns the current particle system
  104704. */
  104705. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  104706. /**
  104707. * Not supported by GPUParticleSystem
  104708. * @param gradient defines the gradient to remove
  104709. * @returns the current particle system
  104710. */
  104711. removeStartSizeGradient(gradient: number): IParticleSystem;
  104712. /**
  104713. * Not supported by GPUParticleSystem
  104714. * @param gradient defines the gradient to use (between 0 and 1)
  104715. * @param min defines the color remap minimal range
  104716. * @param max defines the color remap maximal range
  104717. * @returns the current particle system
  104718. */
  104719. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  104720. /**
  104721. * Not supported by GPUParticleSystem
  104722. * @param gradient defines the gradient to remove
  104723. * @returns the current particle system
  104724. */
  104725. removeColorRemapGradient(): IParticleSystem;
  104726. /**
  104727. * Not supported by GPUParticleSystem
  104728. * @param gradient defines the gradient to use (between 0 and 1)
  104729. * @param min defines the alpha remap minimal range
  104730. * @param max defines the alpha remap maximal range
  104731. * @returns the current particle system
  104732. */
  104733. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  104734. /**
  104735. * Not supported by GPUParticleSystem
  104736. * @param gradient defines the gradient to remove
  104737. * @returns the current particle system
  104738. */
  104739. removeAlphaRemapGradient(): IParticleSystem;
  104740. /**
  104741. * Not supported by GPUParticleSystem
  104742. * @param gradient defines the gradient to use (between 0 and 1)
  104743. * @param color defines the color to affect to the specified gradient
  104744. * @returns the current particle system
  104745. */
  104746. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  104747. /**
  104748. * Not supported by GPUParticleSystem
  104749. * @param gradient defines the gradient to remove
  104750. * @returns the current particle system
  104751. */
  104752. removeRampGradient(): IParticleSystem;
  104753. /**
  104754. * Not supported by GPUParticleSystem
  104755. * @returns the list of ramp gradients
  104756. */
  104757. getRampGradients(): Nullable<Array<Color3Gradient>>;
  104758. /**
  104759. * Not supported by GPUParticleSystem
  104760. * Gets or sets a boolean indicating that ramp gradients must be used
  104761. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  104762. */
  104763. useRampGradients: boolean;
  104764. /**
  104765. * Not supported by GPUParticleSystem
  104766. * @param gradient defines the gradient to use (between 0 and 1)
  104767. * @param factor defines the life time factor to affect to the specified gradient
  104768. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104769. * @returns the current particle system
  104770. */
  104771. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  104772. /**
  104773. * Not supported by GPUParticleSystem
  104774. * @param gradient defines the gradient to remove
  104775. * @returns the current particle system
  104776. */
  104777. removeLifeTimeGradient(gradient: number): IParticleSystem;
  104778. /**
  104779. * Instantiates a GPU particle system.
  104780. * 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.
  104781. * @param name The name of the particle system
  104782. * @param options The options used to create the system
  104783. * @param scene The scene the particle system belongs to
  104784. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  104785. */
  104786. constructor(name: string, options: Partial<{
  104787. capacity: number;
  104788. randomTextureSize: number;
  104789. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  104790. protected _reset(): void;
  104791. private _createUpdateVAO;
  104792. private _createRenderVAO;
  104793. private _initialize;
  104794. /** @hidden */
  104795. _recreateUpdateEffect(): void;
  104796. /** @hidden */
  104797. _recreateRenderEffect(): void;
  104798. /**
  104799. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  104800. * @param preWarm defines if we are in the pre-warmimg phase
  104801. */
  104802. animate(preWarm?: boolean): void;
  104803. private _createFactorGradientTexture;
  104804. private _createSizeGradientTexture;
  104805. private _createAngularSpeedGradientTexture;
  104806. private _createVelocityGradientTexture;
  104807. private _createLimitVelocityGradientTexture;
  104808. private _createDragGradientTexture;
  104809. private _createColorGradientTexture;
  104810. /**
  104811. * Renders the particle system in its current state
  104812. * @param preWarm defines if the system should only update the particles but not render them
  104813. * @returns the current number of particles
  104814. */
  104815. render(preWarm?: boolean): number;
  104816. /**
  104817. * Rebuilds the particle system
  104818. */
  104819. rebuild(): void;
  104820. private _releaseBuffers;
  104821. private _releaseVAOs;
  104822. /**
  104823. * Disposes the particle system and free the associated resources
  104824. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  104825. */
  104826. dispose(disposeTexture?: boolean): void;
  104827. /**
  104828. * Clones the particle system.
  104829. * @param name The name of the cloned object
  104830. * @param newEmitter The new emitter to use
  104831. * @returns the cloned particle system
  104832. */
  104833. clone(name: string, newEmitter: any): GPUParticleSystem;
  104834. /**
  104835. * Serializes the particle system to a JSON object.
  104836. * @returns the JSON object
  104837. */
  104838. serialize(): any;
  104839. /**
  104840. * Parses a JSON object to create a GPU particle system.
  104841. * @param parsedParticleSystem The JSON object to parse
  104842. * @param scene The scene to create the particle system in
  104843. * @param rootUrl The root url to use to load external dependencies like texture
  104844. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  104845. * @returns the parsed GPU particle system
  104846. */
  104847. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  104848. }
  104849. }
  104850. declare module BABYLON {
  104851. /**
  104852. * Represents a set of particle systems working together to create a specific effect
  104853. */
  104854. export class ParticleSystemSet implements IDisposable {
  104855. private _emitterCreationOptions;
  104856. private _emitterNode;
  104857. /**
  104858. * Gets the particle system list
  104859. */
  104860. systems: IParticleSystem[];
  104861. /**
  104862. * Gets the emitter node used with this set
  104863. */
  104864. readonly emitterNode: Nullable<TransformNode>;
  104865. /**
  104866. * Creates a new emitter mesh as a sphere
  104867. * @param options defines the options used to create the sphere
  104868. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  104869. * @param scene defines the hosting scene
  104870. */
  104871. setEmitterAsSphere(options: {
  104872. diameter: number;
  104873. segments: number;
  104874. color: Color3;
  104875. }, renderingGroupId: number, scene: Scene): void;
  104876. /**
  104877. * Starts all particle systems of the set
  104878. * @param emitter defines an optional mesh to use as emitter for the particle systems
  104879. */
  104880. start(emitter?: AbstractMesh): void;
  104881. /**
  104882. * Release all associated resources
  104883. */
  104884. dispose(): void;
  104885. /**
  104886. * Serialize the set into a JSON compatible object
  104887. * @returns a JSON compatible representation of the set
  104888. */
  104889. serialize(): any;
  104890. /**
  104891. * Parse a new ParticleSystemSet from a serialized source
  104892. * @param data defines a JSON compatible representation of the set
  104893. * @param scene defines the hosting scene
  104894. * @param gpu defines if we want GPU particles or CPU particles
  104895. * @returns a new ParticleSystemSet
  104896. */
  104897. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  104898. }
  104899. }
  104900. declare module BABYLON {
  104901. /**
  104902. * This class is made for on one-liner static method to help creating particle system set.
  104903. */
  104904. export class ParticleHelper {
  104905. /**
  104906. * Gets or sets base Assets URL
  104907. */
  104908. static BaseAssetsUrl: string;
  104909. /**
  104910. * Create a default particle system that you can tweak
  104911. * @param emitter defines the emitter to use
  104912. * @param capacity defines the system capacity (default is 500 particles)
  104913. * @param scene defines the hosting scene
  104914. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  104915. * @returns the new Particle system
  104916. */
  104917. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  104918. /**
  104919. * This is the main static method (one-liner) of this helper to create different particle systems
  104920. * @param type This string represents the type to the particle system to create
  104921. * @param scene The scene where the particle system should live
  104922. * @param gpu If the system will use gpu
  104923. * @returns the ParticleSystemSet created
  104924. */
  104925. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  104926. /**
  104927. * Static function used to export a particle system to a ParticleSystemSet variable.
  104928. * Please note that the emitter shape is not exported
  104929. * @param systems defines the particle systems to export
  104930. * @returns the created particle system set
  104931. */
  104932. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  104933. }
  104934. }
  104935. declare module BABYLON {
  104936. interface Engine {
  104937. /**
  104938. * Create an effect to use with particle systems.
  104939. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  104940. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  104941. * @param uniformsNames defines a list of attribute names
  104942. * @param samplers defines an array of string used to represent textures
  104943. * @param defines defines the string containing the defines to use to compile the shaders
  104944. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104945. * @param onCompiled defines a function to call when the effect creation is successful
  104946. * @param onError defines a function to call when the effect creation has failed
  104947. * @returns the new Effect
  104948. */
  104949. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  104950. }
  104951. interface Mesh {
  104952. /**
  104953. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  104954. * @returns an array of IParticleSystem
  104955. */
  104956. getEmittedParticleSystems(): IParticleSystem[];
  104957. /**
  104958. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  104959. * @returns an array of IParticleSystem
  104960. */
  104961. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  104962. }
  104963. /**
  104964. * @hidden
  104965. */
  104966. export var _IDoNeedToBeInTheBuild: number;
  104967. }
  104968. declare module BABYLON {
  104969. interface Scene {
  104970. /** @hidden (Backing field) */
  104971. _physicsEngine: Nullable<IPhysicsEngine>;
  104972. /**
  104973. * Gets the current physics engine
  104974. * @returns a IPhysicsEngine or null if none attached
  104975. */
  104976. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  104977. /**
  104978. * Enables physics to the current scene
  104979. * @param gravity defines the scene's gravity for the physics engine
  104980. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  104981. * @return a boolean indicating if the physics engine was initialized
  104982. */
  104983. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  104984. /**
  104985. * Disables and disposes the physics engine associated with the scene
  104986. */
  104987. disablePhysicsEngine(): void;
  104988. /**
  104989. * Gets a boolean indicating if there is an active physics engine
  104990. * @returns a boolean indicating if there is an active physics engine
  104991. */
  104992. isPhysicsEnabled(): boolean;
  104993. /**
  104994. * Deletes a physics compound impostor
  104995. * @param compound defines the compound to delete
  104996. */
  104997. deleteCompoundImpostor(compound: any): void;
  104998. /**
  104999. * An event triggered when physic simulation is about to be run
  105000. */
  105001. onBeforePhysicsObservable: Observable<Scene>;
  105002. /**
  105003. * An event triggered when physic simulation has been done
  105004. */
  105005. onAfterPhysicsObservable: Observable<Scene>;
  105006. }
  105007. interface AbstractMesh {
  105008. /** @hidden */
  105009. _physicsImpostor: Nullable<PhysicsImpostor>;
  105010. /**
  105011. * Gets or sets impostor used for physic simulation
  105012. * @see http://doc.babylonjs.com/features/physics_engine
  105013. */
  105014. physicsImpostor: Nullable<PhysicsImpostor>;
  105015. /**
  105016. * Gets the current physics impostor
  105017. * @see http://doc.babylonjs.com/features/physics_engine
  105018. * @returns a physics impostor or null
  105019. */
  105020. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  105021. /** Apply a physic impulse to the mesh
  105022. * @param force defines the force to apply
  105023. * @param contactPoint defines where to apply the force
  105024. * @returns the current mesh
  105025. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  105026. */
  105027. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  105028. /**
  105029. * Creates a physic joint between two meshes
  105030. * @param otherMesh defines the other mesh to use
  105031. * @param pivot1 defines the pivot to use on this mesh
  105032. * @param pivot2 defines the pivot to use on the other mesh
  105033. * @param options defines additional options (can be plugin dependent)
  105034. * @returns the current mesh
  105035. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  105036. */
  105037. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  105038. /** @hidden */
  105039. _disposePhysicsObserver: Nullable<Observer<Node>>;
  105040. }
  105041. /**
  105042. * Defines the physics engine scene component responsible to manage a physics engine
  105043. */
  105044. export class PhysicsEngineSceneComponent implements ISceneComponent {
  105045. /**
  105046. * The component name helpful to identify the component in the list of scene components.
  105047. */
  105048. readonly name: string;
  105049. /**
  105050. * The scene the component belongs to.
  105051. */
  105052. scene: Scene;
  105053. /**
  105054. * Creates a new instance of the component for the given scene
  105055. * @param scene Defines the scene to register the component in
  105056. */
  105057. constructor(scene: Scene);
  105058. /**
  105059. * Registers the component in a given scene
  105060. */
  105061. register(): void;
  105062. /**
  105063. * Rebuilds the elements related to this component in case of
  105064. * context lost for instance.
  105065. */
  105066. rebuild(): void;
  105067. /**
  105068. * Disposes the component and the associated ressources
  105069. */
  105070. dispose(): void;
  105071. }
  105072. }
  105073. declare module BABYLON {
  105074. /**
  105075. * A helper for physics simulations
  105076. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105077. */
  105078. export class PhysicsHelper {
  105079. private _scene;
  105080. private _physicsEngine;
  105081. /**
  105082. * Initializes the Physics helper
  105083. * @param scene Babylon.js scene
  105084. */
  105085. constructor(scene: Scene);
  105086. /**
  105087. * Applies a radial explosion impulse
  105088. * @param origin the origin of the explosion
  105089. * @param radius the explosion radius
  105090. * @param strength the explosion strength
  105091. * @param falloff possible options: Constant & Linear. Defaults to Constant
  105092. * @returns A physics radial explosion event, or null
  105093. */
  105094. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  105095. /**
  105096. * Applies a radial explosion force
  105097. * @param origin the origin of the explosion
  105098. * @param radius the explosion radius
  105099. * @param strength the explosion strength
  105100. * @param falloff possible options: Constant & Linear. Defaults to Constant
  105101. * @returns A physics radial explosion event, or null
  105102. */
  105103. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  105104. /**
  105105. * Creates a gravitational field
  105106. * @param origin the origin of the explosion
  105107. * @param radius the explosion radius
  105108. * @param strength the explosion strength
  105109. * @param falloff possible options: Constant & Linear. Defaults to Constant
  105110. * @returns A physics gravitational field event, or null
  105111. */
  105112. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  105113. /**
  105114. * Creates a physics updraft event
  105115. * @param origin the origin of the updraft
  105116. * @param radius the radius of the updraft
  105117. * @param strength the strength of the updraft
  105118. * @param height the height of the updraft
  105119. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  105120. * @returns A physics updraft event, or null
  105121. */
  105122. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  105123. /**
  105124. * Creates a physics vortex event
  105125. * @param origin the of the vortex
  105126. * @param radius the radius of the vortex
  105127. * @param strength the strength of the vortex
  105128. * @param height the height of the vortex
  105129. * @returns a Physics vortex event, or null
  105130. * A physics vortex event or null
  105131. */
  105132. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  105133. }
  105134. /**
  105135. * Represents a physics radial explosion event
  105136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105137. */
  105138. export class PhysicsRadialExplosionEvent {
  105139. private _scene;
  105140. private _sphere;
  105141. private _sphereOptions;
  105142. private _rays;
  105143. private _dataFetched;
  105144. /**
  105145. * Initializes a radial explosioin event
  105146. * @param scene BabylonJS scene
  105147. */
  105148. constructor(scene: Scene);
  105149. /**
  105150. * Returns the data related to the radial explosion event (sphere & rays).
  105151. * @returns The radial explosion event data
  105152. */
  105153. getData(): PhysicsRadialExplosionEventData;
  105154. /**
  105155. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  105156. * @param impostor A physics imposter
  105157. * @param origin the origin of the explosion
  105158. * @param radius the explosion radius
  105159. * @param strength the explosion strength
  105160. * @param falloff possible options: Constant & Linear
  105161. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  105162. */
  105163. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  105164. /**
  105165. * Disposes the sphere.
  105166. * @param force Specifies if the sphere should be disposed by force
  105167. */
  105168. dispose(force?: boolean): void;
  105169. /*** Helpers ***/
  105170. private _prepareSphere;
  105171. private _intersectsWithSphere;
  105172. }
  105173. /**
  105174. * Represents a gravitational field event
  105175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105176. */
  105177. export class PhysicsGravitationalFieldEvent {
  105178. private _physicsHelper;
  105179. private _scene;
  105180. private _origin;
  105181. private _radius;
  105182. private _strength;
  105183. private _falloff;
  105184. private _tickCallback;
  105185. private _sphere;
  105186. private _dataFetched;
  105187. /**
  105188. * Initializes the physics gravitational field event
  105189. * @param physicsHelper A physics helper
  105190. * @param scene BabylonJS scene
  105191. * @param origin The origin position of the gravitational field event
  105192. * @param radius The radius of the gravitational field event
  105193. * @param strength The strength of the gravitational field event
  105194. * @param falloff The falloff for the gravitational field event
  105195. */
  105196. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  105197. /**
  105198. * Returns the data related to the gravitational field event (sphere).
  105199. * @returns A gravitational field event
  105200. */
  105201. getData(): PhysicsGravitationalFieldEventData;
  105202. /**
  105203. * Enables the gravitational field.
  105204. */
  105205. enable(): void;
  105206. /**
  105207. * Disables the gravitational field.
  105208. */
  105209. disable(): void;
  105210. /**
  105211. * Disposes the sphere.
  105212. * @param force The force to dispose from the gravitational field event
  105213. */
  105214. dispose(force?: boolean): void;
  105215. private _tick;
  105216. }
  105217. /**
  105218. * Represents a physics updraft event
  105219. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105220. */
  105221. export class PhysicsUpdraftEvent {
  105222. private _scene;
  105223. private _origin;
  105224. private _radius;
  105225. private _strength;
  105226. private _height;
  105227. private _updraftMode;
  105228. private _physicsEngine;
  105229. private _originTop;
  105230. private _originDirection;
  105231. private _tickCallback;
  105232. private _cylinder;
  105233. private _cylinderPosition;
  105234. private _dataFetched;
  105235. /**
  105236. * Initializes the physics updraft event
  105237. * @param _scene BabylonJS scene
  105238. * @param _origin The origin position of the updraft
  105239. * @param _radius The radius of the updraft
  105240. * @param _strength The strength of the updraft
  105241. * @param _height The height of the updraft
  105242. * @param _updraftMode The mode of the updraft
  105243. */
  105244. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  105245. /**
  105246. * Returns the data related to the updraft event (cylinder).
  105247. * @returns A physics updraft event
  105248. */
  105249. getData(): PhysicsUpdraftEventData;
  105250. /**
  105251. * Enables the updraft.
  105252. */
  105253. enable(): void;
  105254. /**
  105255. * Disables the cortex.
  105256. */
  105257. disable(): void;
  105258. /**
  105259. * Disposes the sphere.
  105260. * @param force Specifies if the updraft should be disposed by force
  105261. */
  105262. dispose(force?: boolean): void;
  105263. private getImpostorForceAndContactPoint;
  105264. private _tick;
  105265. /*** Helpers ***/
  105266. private _prepareCylinder;
  105267. private _intersectsWithCylinder;
  105268. }
  105269. /**
  105270. * Represents a physics vortex event
  105271. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105272. */
  105273. export class PhysicsVortexEvent {
  105274. private _scene;
  105275. private _origin;
  105276. private _radius;
  105277. private _strength;
  105278. private _height;
  105279. private _physicsEngine;
  105280. private _originTop;
  105281. private _centripetalForceThreshold;
  105282. private _updraftMultiplier;
  105283. private _tickCallback;
  105284. private _cylinder;
  105285. private _cylinderPosition;
  105286. private _dataFetched;
  105287. /**
  105288. * Initializes the physics vortex event
  105289. * @param _scene The BabylonJS scene
  105290. * @param _origin The origin position of the vortex
  105291. * @param _radius The radius of the vortex
  105292. * @param _strength The strength of the vortex
  105293. * @param _height The height of the vortex
  105294. */
  105295. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  105296. /**
  105297. * Returns the data related to the vortex event (cylinder).
  105298. * @returns The physics vortex event data
  105299. */
  105300. getData(): PhysicsVortexEventData;
  105301. /**
  105302. * Enables the vortex.
  105303. */
  105304. enable(): void;
  105305. /**
  105306. * Disables the cortex.
  105307. */
  105308. disable(): void;
  105309. /**
  105310. * Disposes the sphere.
  105311. * @param force
  105312. */
  105313. dispose(force?: boolean): void;
  105314. private getImpostorForceAndContactPoint;
  105315. private _tick;
  105316. /*** Helpers ***/
  105317. private _prepareCylinder;
  105318. private _intersectsWithCylinder;
  105319. }
  105320. /**
  105321. * The strenght of the force in correspondence to the distance of the affected object
  105322. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105323. */
  105324. export enum PhysicsRadialImpulseFalloff {
  105325. /** Defines that impulse is constant in strength across it's whole radius */
  105326. Constant = 0,
  105327. /** DEfines that impulse gets weaker if it's further from the origin */
  105328. Linear = 1
  105329. }
  105330. /**
  105331. * The strength of the force in correspondence to the distance of the affected object
  105332. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105333. */
  105334. export enum PhysicsUpdraftMode {
  105335. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  105336. Center = 0,
  105337. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  105338. Perpendicular = 1
  105339. }
  105340. /**
  105341. * Interface for a physics force and contact point
  105342. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105343. */
  105344. export interface PhysicsForceAndContactPoint {
  105345. /**
  105346. * The force applied at the contact point
  105347. */
  105348. force: Vector3;
  105349. /**
  105350. * The contact point
  105351. */
  105352. contactPoint: Vector3;
  105353. }
  105354. /**
  105355. * Interface for radial explosion event data
  105356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105357. */
  105358. export interface PhysicsRadialExplosionEventData {
  105359. /**
  105360. * A sphere used for the radial explosion event
  105361. */
  105362. sphere: Mesh;
  105363. /**
  105364. * An array of rays for the radial explosion event
  105365. */
  105366. rays: Array<Ray>;
  105367. }
  105368. /**
  105369. * Interface for gravitational field event data
  105370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105371. */
  105372. export interface PhysicsGravitationalFieldEventData {
  105373. /**
  105374. * A sphere mesh used for the gravitational field event
  105375. */
  105376. sphere: Mesh;
  105377. }
  105378. /**
  105379. * Interface for updraft event data
  105380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105381. */
  105382. export interface PhysicsUpdraftEventData {
  105383. /**
  105384. * A cylinder used for the updraft event
  105385. */
  105386. cylinder: Mesh;
  105387. }
  105388. /**
  105389. * Interface for vortex event data
  105390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105391. */
  105392. export interface PhysicsVortexEventData {
  105393. /**
  105394. * A cylinder used for the vortex event
  105395. */
  105396. cylinder: Mesh;
  105397. }
  105398. }
  105399. declare module BABYLON {
  105400. /**
  105401. * AmmoJS Physics plugin
  105402. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105403. * @see https://github.com/kripken/ammo.js/
  105404. */
  105405. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  105406. private _useDeltaForWorldStep;
  105407. /**
  105408. * Reference to the Ammo library
  105409. */
  105410. bjsAMMO: any;
  105411. /**
  105412. * Created ammoJS world which physics bodies are added to
  105413. */
  105414. world: any;
  105415. /**
  105416. * Name of the plugin
  105417. */
  105418. name: string;
  105419. private _timeStep;
  105420. private _fixedTimeStep;
  105421. private _maxSteps;
  105422. private _tmpQuaternion;
  105423. private _tmpAmmoTransform;
  105424. private _tmpAmmoQuaternion;
  105425. private _tmpAmmoConcreteContactResultCallback;
  105426. private _collisionConfiguration;
  105427. private _dispatcher;
  105428. private _overlappingPairCache;
  105429. private _solver;
  105430. private _tmpAmmoVectorA;
  105431. private _tmpAmmoVectorB;
  105432. private _tmpAmmoVectorC;
  105433. private _tmpContactCallbackResult;
  105434. private static readonly DISABLE_COLLISION_FLAG;
  105435. private static readonly KINEMATIC_FLAG;
  105436. private static readonly DISABLE_DEACTIVATION_FLAG;
  105437. /**
  105438. * Initializes the ammoJS plugin
  105439. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  105440. * @param ammoInjection can be used to inject your own ammo reference
  105441. */
  105442. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  105443. /**
  105444. * Sets the gravity of the physics world (m/(s^2))
  105445. * @param gravity Gravity to set
  105446. */
  105447. setGravity(gravity: Vector3): void;
  105448. /**
  105449. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  105450. * @param timeStep timestep to use in seconds
  105451. */
  105452. setTimeStep(timeStep: number): void;
  105453. /**
  105454. * 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)
  105455. * @param fixedTimeStep fixedTimeStep to use in seconds
  105456. */
  105457. setFixedTimeStep(fixedTimeStep: number): void;
  105458. /**
  105459. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  105460. * @param maxSteps the maximum number of steps by the physics engine per frame
  105461. */
  105462. setMaxSteps(maxSteps: number): void;
  105463. /**
  105464. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  105465. * @returns the current timestep in seconds
  105466. */
  105467. getTimeStep(): number;
  105468. private _isImpostorInContact;
  105469. private _isImpostorPairInContact;
  105470. private _stepSimulation;
  105471. /**
  105472. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  105473. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  105474. * After the step the babylon meshes are set to the position of the physics imposters
  105475. * @param delta amount of time to step forward
  105476. * @param impostors array of imposters to update before/after the step
  105477. */
  105478. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  105479. private _tmpVector;
  105480. private _tmpMatrix;
  105481. /**
  105482. * Applies an implulse on the imposter
  105483. * @param impostor imposter to apply impulse
  105484. * @param force amount of force to be applied to the imposter
  105485. * @param contactPoint the location to apply the impulse on the imposter
  105486. */
  105487. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105488. /**
  105489. * Applies a force on the imposter
  105490. * @param impostor imposter to apply force
  105491. * @param force amount of force to be applied to the imposter
  105492. * @param contactPoint the location to apply the force on the imposter
  105493. */
  105494. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105495. /**
  105496. * Creates a physics body using the plugin
  105497. * @param impostor the imposter to create the physics body on
  105498. */
  105499. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105500. /**
  105501. * Removes the physics body from the imposter and disposes of the body's memory
  105502. * @param impostor imposter to remove the physics body from
  105503. */
  105504. removePhysicsBody(impostor: PhysicsImpostor): void;
  105505. /**
  105506. * Generates a joint
  105507. * @param impostorJoint the imposter joint to create the joint with
  105508. */
  105509. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  105510. /**
  105511. * Removes a joint
  105512. * @param impostorJoint the imposter joint to remove the joint from
  105513. */
  105514. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  105515. private _addMeshVerts;
  105516. private _createShape;
  105517. /**
  105518. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  105519. * @param impostor imposter containing the physics body and babylon object
  105520. */
  105521. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105522. /**
  105523. * Sets the babylon object's position/rotation from the physics body's position/rotation
  105524. * @param impostor imposter containing the physics body and babylon object
  105525. * @param newPosition new position
  105526. * @param newRotation new rotation
  105527. */
  105528. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105529. /**
  105530. * If this plugin is supported
  105531. * @returns true if its supported
  105532. */
  105533. isSupported(): boolean;
  105534. /**
  105535. * Sets the linear velocity of the physics body
  105536. * @param impostor imposter to set the velocity on
  105537. * @param velocity velocity to set
  105538. */
  105539. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105540. /**
  105541. * Sets the angular velocity of the physics body
  105542. * @param impostor imposter to set the velocity on
  105543. * @param velocity velocity to set
  105544. */
  105545. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105546. /**
  105547. * gets the linear velocity
  105548. * @param impostor imposter to get linear velocity from
  105549. * @returns linear velocity
  105550. */
  105551. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105552. /**
  105553. * gets the angular velocity
  105554. * @param impostor imposter to get angular velocity from
  105555. * @returns angular velocity
  105556. */
  105557. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105558. /**
  105559. * Sets the mass of physics body
  105560. * @param impostor imposter to set the mass on
  105561. * @param mass mass to set
  105562. */
  105563. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  105564. /**
  105565. * Gets the mass of the physics body
  105566. * @param impostor imposter to get the mass from
  105567. * @returns mass
  105568. */
  105569. getBodyMass(impostor: PhysicsImpostor): number;
  105570. /**
  105571. * Gets friction of the impostor
  105572. * @param impostor impostor to get friction from
  105573. * @returns friction value
  105574. */
  105575. getBodyFriction(impostor: PhysicsImpostor): number;
  105576. /**
  105577. * Sets friction of the impostor
  105578. * @param impostor impostor to set friction on
  105579. * @param friction friction value
  105580. */
  105581. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  105582. /**
  105583. * Gets restitution of the impostor
  105584. * @param impostor impostor to get restitution from
  105585. * @returns restitution value
  105586. */
  105587. getBodyRestitution(impostor: PhysicsImpostor): number;
  105588. /**
  105589. * Sets resitution of the impostor
  105590. * @param impostor impostor to set resitution on
  105591. * @param restitution resitution value
  105592. */
  105593. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  105594. /**
  105595. * Sleeps the physics body and stops it from being active
  105596. * @param impostor impostor to sleep
  105597. */
  105598. sleepBody(impostor: PhysicsImpostor): void;
  105599. /**
  105600. * Activates the physics body
  105601. * @param impostor impostor to activate
  105602. */
  105603. wakeUpBody(impostor: PhysicsImpostor): void;
  105604. /**
  105605. * Updates the distance parameters of the joint
  105606. * @param joint joint to update
  105607. * @param maxDistance maximum distance of the joint
  105608. * @param minDistance minimum distance of the joint
  105609. */
  105610. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  105611. /**
  105612. * Sets a motor on the joint
  105613. * @param joint joint to set motor on
  105614. * @param speed speed of the motor
  105615. * @param maxForce maximum force of the motor
  105616. * @param motorIndex index of the motor
  105617. */
  105618. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  105619. /**
  105620. * Sets the motors limit
  105621. * @param joint joint to set limit on
  105622. * @param upperLimit upper limit
  105623. * @param lowerLimit lower limit
  105624. */
  105625. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  105626. /**
  105627. * Syncs the position and rotation of a mesh with the impostor
  105628. * @param mesh mesh to sync
  105629. * @param impostor impostor to update the mesh with
  105630. */
  105631. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  105632. /**
  105633. * Gets the radius of the impostor
  105634. * @param impostor impostor to get radius from
  105635. * @returns the radius
  105636. */
  105637. getRadius(impostor: PhysicsImpostor): number;
  105638. /**
  105639. * Gets the box size of the impostor
  105640. * @param impostor impostor to get box size from
  105641. * @param result the resulting box size
  105642. */
  105643. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  105644. /**
  105645. * Disposes of the impostor
  105646. */
  105647. dispose(): void;
  105648. }
  105649. }
  105650. declare module BABYLON {
  105651. /** @hidden */
  105652. export var blackAndWhitePixelShader: {
  105653. name: string;
  105654. shader: string;
  105655. };
  105656. }
  105657. declare module BABYLON {
  105658. /**
  105659. * Post process used to render in black and white
  105660. */
  105661. export class BlackAndWhitePostProcess extends PostProcess {
  105662. /**
  105663. * Linear about to convert he result to black and white (default: 1)
  105664. */
  105665. degree: number;
  105666. /**
  105667. * Creates a black and white post process
  105668. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  105669. * @param name The name of the effect.
  105670. * @param options The required width/height ratio to downsize to before computing the render pass.
  105671. * @param camera The camera to apply the render pass to.
  105672. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105673. * @param engine The engine which the post process will be applied. (default: current engine)
  105674. * @param reusable If the post process can be reused on the same frame. (default: false)
  105675. */
  105676. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105677. }
  105678. }
  105679. declare module BABYLON {
  105680. /**
  105681. * This represents a set of one or more post processes in Babylon.
  105682. * A post process can be used to apply a shader to a texture after it is rendered.
  105683. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  105684. */
  105685. export class PostProcessRenderEffect {
  105686. private _postProcesses;
  105687. private _getPostProcesses;
  105688. private _singleInstance;
  105689. private _cameras;
  105690. private _indicesForCamera;
  105691. /**
  105692. * Name of the effect
  105693. * @hidden
  105694. */
  105695. _name: string;
  105696. /**
  105697. * Instantiates a post process render effect.
  105698. * A post process can be used to apply a shader to a texture after it is rendered.
  105699. * @param engine The engine the effect is tied to
  105700. * @param name The name of the effect
  105701. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  105702. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  105703. */
  105704. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  105705. /**
  105706. * Checks if all the post processes in the effect are supported.
  105707. */
  105708. readonly isSupported: boolean;
  105709. /**
  105710. * Updates the current state of the effect
  105711. * @hidden
  105712. */
  105713. _update(): void;
  105714. /**
  105715. * Attaches the effect on cameras
  105716. * @param cameras The camera to attach to.
  105717. * @hidden
  105718. */
  105719. _attachCameras(cameras: Camera): void;
  105720. /**
  105721. * Attaches the effect on cameras
  105722. * @param cameras The camera to attach to.
  105723. * @hidden
  105724. */
  105725. _attachCameras(cameras: Camera[]): void;
  105726. /**
  105727. * Detatches the effect on cameras
  105728. * @param cameras The camera to detatch from.
  105729. * @hidden
  105730. */
  105731. _detachCameras(cameras: Camera): void;
  105732. /**
  105733. * Detatches the effect on cameras
  105734. * @param cameras The camera to detatch from.
  105735. * @hidden
  105736. */
  105737. _detachCameras(cameras: Camera[]): void;
  105738. /**
  105739. * Enables the effect on given cameras
  105740. * @param cameras The camera to enable.
  105741. * @hidden
  105742. */
  105743. _enable(cameras: Camera): void;
  105744. /**
  105745. * Enables the effect on given cameras
  105746. * @param cameras The camera to enable.
  105747. * @hidden
  105748. */
  105749. _enable(cameras: Nullable<Camera[]>): void;
  105750. /**
  105751. * Disables the effect on the given cameras
  105752. * @param cameras The camera to disable.
  105753. * @hidden
  105754. */
  105755. _disable(cameras: Camera): void;
  105756. /**
  105757. * Disables the effect on the given cameras
  105758. * @param cameras The camera to disable.
  105759. * @hidden
  105760. */
  105761. _disable(cameras: Nullable<Camera[]>): void;
  105762. /**
  105763. * Gets a list of the post processes contained in the effect.
  105764. * @param camera The camera to get the post processes on.
  105765. * @returns The list of the post processes in the effect.
  105766. */
  105767. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  105768. }
  105769. }
  105770. declare module BABYLON {
  105771. /** @hidden */
  105772. export var extractHighlightsPixelShader: {
  105773. name: string;
  105774. shader: string;
  105775. };
  105776. }
  105777. declare module BABYLON {
  105778. /**
  105779. * 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.
  105780. */
  105781. export class ExtractHighlightsPostProcess extends PostProcess {
  105782. /**
  105783. * The luminance threshold, pixels below this value will be set to black.
  105784. */
  105785. threshold: number;
  105786. /** @hidden */
  105787. _exposure: number;
  105788. /**
  105789. * Post process which has the input texture to be used when performing highlight extraction
  105790. * @hidden
  105791. */
  105792. _inputPostProcess: Nullable<PostProcess>;
  105793. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105794. }
  105795. }
  105796. declare module BABYLON {
  105797. /** @hidden */
  105798. export var bloomMergePixelShader: {
  105799. name: string;
  105800. shader: string;
  105801. };
  105802. }
  105803. declare module BABYLON {
  105804. /**
  105805. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  105806. */
  105807. export class BloomMergePostProcess extends PostProcess {
  105808. /** Weight of the bloom to be added to the original input. */
  105809. weight: number;
  105810. /**
  105811. * Creates a new instance of @see BloomMergePostProcess
  105812. * @param name The name of the effect.
  105813. * @param originalFromInput Post process which's input will be used for the merge.
  105814. * @param blurred Blurred highlights post process which's output will be used.
  105815. * @param weight Weight of the bloom to be added to the original input.
  105816. * @param options The required width/height ratio to downsize to before computing the render pass.
  105817. * @param camera The camera to apply the render pass to.
  105818. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105819. * @param engine The engine which the post process will be applied. (default: current engine)
  105820. * @param reusable If the post process can be reused on the same frame. (default: false)
  105821. * @param textureType Type of textures used when performing the post process. (default: 0)
  105822. * @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)
  105823. */
  105824. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  105825. /** Weight of the bloom to be added to the original input. */
  105826. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105827. }
  105828. }
  105829. declare module BABYLON {
  105830. /**
  105831. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  105832. */
  105833. export class BloomEffect extends PostProcessRenderEffect {
  105834. private bloomScale;
  105835. /**
  105836. * @hidden Internal
  105837. */
  105838. _effects: Array<PostProcess>;
  105839. /**
  105840. * @hidden Internal
  105841. */
  105842. _downscale: ExtractHighlightsPostProcess;
  105843. private _blurX;
  105844. private _blurY;
  105845. private _merge;
  105846. /**
  105847. * The luminance threshold to find bright areas of the image to bloom.
  105848. */
  105849. threshold: number;
  105850. /**
  105851. * The strength of the bloom.
  105852. */
  105853. weight: number;
  105854. /**
  105855. * Specifies the size of the bloom blur kernel, relative to the final output size
  105856. */
  105857. kernel: number;
  105858. /**
  105859. * Creates a new instance of @see BloomEffect
  105860. * @param scene The scene the effect belongs to.
  105861. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  105862. * @param bloomKernel The size of the kernel to be used when applying the blur.
  105863. * @param bloomWeight The the strength of bloom.
  105864. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  105865. * @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)
  105866. */
  105867. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  105868. /**
  105869. * Disposes each of the internal effects for a given camera.
  105870. * @param camera The camera to dispose the effect on.
  105871. */
  105872. disposeEffects(camera: Camera): void;
  105873. /**
  105874. * @hidden Internal
  105875. */
  105876. _updateEffects(): void;
  105877. /**
  105878. * Internal
  105879. * @returns if all the contained post processes are ready.
  105880. * @hidden
  105881. */
  105882. _isReady(): boolean;
  105883. }
  105884. }
  105885. declare module BABYLON {
  105886. /** @hidden */
  105887. export var chromaticAberrationPixelShader: {
  105888. name: string;
  105889. shader: string;
  105890. };
  105891. }
  105892. declare module BABYLON {
  105893. /**
  105894. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  105895. */
  105896. export class ChromaticAberrationPostProcess extends PostProcess {
  105897. /**
  105898. * The amount of seperation of rgb channels (default: 30)
  105899. */
  105900. aberrationAmount: number;
  105901. /**
  105902. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  105903. */
  105904. radialIntensity: number;
  105905. /**
  105906. * 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))
  105907. */
  105908. direction: Vector2;
  105909. /**
  105910. * 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))
  105911. */
  105912. centerPosition: Vector2;
  105913. /**
  105914. * Creates a new instance ChromaticAberrationPostProcess
  105915. * @param name The name of the effect.
  105916. * @param screenWidth The width of the screen to apply the effect on.
  105917. * @param screenHeight The height of the screen to apply the effect on.
  105918. * @param options The required width/height ratio to downsize to before computing the render pass.
  105919. * @param camera The camera to apply the render pass to.
  105920. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105921. * @param engine The engine which the post process will be applied. (default: current engine)
  105922. * @param reusable If the post process can be reused on the same frame. (default: false)
  105923. * @param textureType Type of textures used when performing the post process. (default: 0)
  105924. * @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)
  105925. */
  105926. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105927. }
  105928. }
  105929. declare module BABYLON {
  105930. /** @hidden */
  105931. export var circleOfConfusionPixelShader: {
  105932. name: string;
  105933. shader: string;
  105934. };
  105935. }
  105936. declare module BABYLON {
  105937. /**
  105938. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  105939. */
  105940. export class CircleOfConfusionPostProcess extends PostProcess {
  105941. /**
  105942. * 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.
  105943. */
  105944. lensSize: number;
  105945. /**
  105946. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  105947. */
  105948. fStop: number;
  105949. /**
  105950. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  105951. */
  105952. focusDistance: number;
  105953. /**
  105954. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  105955. */
  105956. focalLength: number;
  105957. private _depthTexture;
  105958. /**
  105959. * Creates a new instance CircleOfConfusionPostProcess
  105960. * @param name The name of the effect.
  105961. * @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.
  105962. * @param options The required width/height ratio to downsize to before computing the render pass.
  105963. * @param camera The camera to apply the render pass to.
  105964. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105965. * @param engine The engine which the post process will be applied. (default: current engine)
  105966. * @param reusable If the post process can be reused on the same frame. (default: false)
  105967. * @param textureType Type of textures used when performing the post process. (default: 0)
  105968. * @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)
  105969. */
  105970. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105971. /**
  105972. * 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.
  105973. */
  105974. depthTexture: RenderTargetTexture;
  105975. }
  105976. }
  105977. declare module BABYLON {
  105978. /** @hidden */
  105979. export var colorCorrectionPixelShader: {
  105980. name: string;
  105981. shader: string;
  105982. };
  105983. }
  105984. declare module BABYLON {
  105985. /**
  105986. *
  105987. * This post-process allows the modification of rendered colors by using
  105988. * a 'look-up table' (LUT). This effect is also called Color Grading.
  105989. *
  105990. * The object needs to be provided an url to a texture containing the color
  105991. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  105992. * Use an image editing software to tweak the LUT to match your needs.
  105993. *
  105994. * For an example of a color LUT, see here:
  105995. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  105996. * For explanations on color grading, see here:
  105997. * @see http://udn.epicgames.com/Three/ColorGrading.html
  105998. *
  105999. */
  106000. export class ColorCorrectionPostProcess extends PostProcess {
  106001. private _colorTableTexture;
  106002. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106003. }
  106004. }
  106005. declare module BABYLON {
  106006. /** @hidden */
  106007. export var convolutionPixelShader: {
  106008. name: string;
  106009. shader: string;
  106010. };
  106011. }
  106012. declare module BABYLON {
  106013. /**
  106014. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  106015. * input texture to perform effects such as edge detection or sharpening
  106016. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  106017. */
  106018. export class ConvolutionPostProcess extends PostProcess {
  106019. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  106020. kernel: number[];
  106021. /**
  106022. * Creates a new instance ConvolutionPostProcess
  106023. * @param name The name of the effect.
  106024. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  106025. * @param options The required width/height ratio to downsize to before computing the render pass.
  106026. * @param camera The camera to apply the render pass to.
  106027. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106028. * @param engine The engine which the post process will be applied. (default: current engine)
  106029. * @param reusable If the post process can be reused on the same frame. (default: false)
  106030. * @param textureType Type of textures used when performing the post process. (default: 0)
  106031. */
  106032. constructor(name: string,
  106033. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  106034. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  106035. /**
  106036. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106037. */
  106038. static EdgeDetect0Kernel: number[];
  106039. /**
  106040. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106041. */
  106042. static EdgeDetect1Kernel: number[];
  106043. /**
  106044. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106045. */
  106046. static EdgeDetect2Kernel: number[];
  106047. /**
  106048. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106049. */
  106050. static SharpenKernel: number[];
  106051. /**
  106052. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106053. */
  106054. static EmbossKernel: number[];
  106055. /**
  106056. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106057. */
  106058. static GaussianKernel: number[];
  106059. }
  106060. }
  106061. declare module BABYLON {
  106062. /**
  106063. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  106064. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  106065. * based on samples that have a large difference in distance than the center pixel.
  106066. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  106067. */
  106068. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  106069. direction: Vector2;
  106070. /**
  106071. * Creates a new instance CircleOfConfusionPostProcess
  106072. * @param name The name of the effect.
  106073. * @param scene The scene the effect belongs to.
  106074. * @param direction The direction the blur should be applied.
  106075. * @param kernel The size of the kernel used to blur.
  106076. * @param options The required width/height ratio to downsize to before computing the render pass.
  106077. * @param camera The camera to apply the render pass to.
  106078. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  106079. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  106080. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106081. * @param engine The engine which the post process will be applied. (default: current engine)
  106082. * @param reusable If the post process can be reused on the same frame. (default: false)
  106083. * @param textureType Type of textures used when performing the post process. (default: 0)
  106084. * @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)
  106085. */
  106086. 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);
  106087. }
  106088. }
  106089. declare module BABYLON {
  106090. /** @hidden */
  106091. export var depthOfFieldMergePixelShader: {
  106092. name: string;
  106093. shader: string;
  106094. };
  106095. }
  106096. declare module BABYLON {
  106097. /**
  106098. * Options to be set when merging outputs from the default pipeline.
  106099. */
  106100. export class DepthOfFieldMergePostProcessOptions {
  106101. /**
  106102. * The original image to merge on top of
  106103. */
  106104. originalFromInput: PostProcess;
  106105. /**
  106106. * Parameters to perform the merge of the depth of field effect
  106107. */
  106108. depthOfField?: {
  106109. circleOfConfusion: PostProcess;
  106110. blurSteps: Array<PostProcess>;
  106111. };
  106112. /**
  106113. * Parameters to perform the merge of bloom effect
  106114. */
  106115. bloom?: {
  106116. blurred: PostProcess;
  106117. weight: number;
  106118. };
  106119. }
  106120. /**
  106121. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  106122. */
  106123. export class DepthOfFieldMergePostProcess extends PostProcess {
  106124. private blurSteps;
  106125. /**
  106126. * Creates a new instance of DepthOfFieldMergePostProcess
  106127. * @param name The name of the effect.
  106128. * @param originalFromInput Post process which's input will be used for the merge.
  106129. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  106130. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  106131. * @param options The required width/height ratio to downsize to before computing the render pass.
  106132. * @param camera The camera to apply the render pass to.
  106133. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106134. * @param engine The engine which the post process will be applied. (default: current engine)
  106135. * @param reusable If the post process can be reused on the same frame. (default: false)
  106136. * @param textureType Type of textures used when performing the post process. (default: 0)
  106137. * @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)
  106138. */
  106139. 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);
  106140. /**
  106141. * Updates the effect with the current post process compile time values and recompiles the shader.
  106142. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  106143. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  106144. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  106145. * @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
  106146. * @param onCompiled Called when the shader has been compiled.
  106147. * @param onError Called if there is an error when compiling a shader.
  106148. */
  106149. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  106150. }
  106151. }
  106152. declare module BABYLON {
  106153. /**
  106154. * Specifies the level of max blur that should be applied when using the depth of field effect
  106155. */
  106156. export enum DepthOfFieldEffectBlurLevel {
  106157. /**
  106158. * Subtle blur
  106159. */
  106160. Low = 0,
  106161. /**
  106162. * Medium blur
  106163. */
  106164. Medium = 1,
  106165. /**
  106166. * Large blur
  106167. */
  106168. High = 2
  106169. }
  106170. /**
  106171. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  106172. */
  106173. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  106174. private _circleOfConfusion;
  106175. /**
  106176. * @hidden Internal, blurs from high to low
  106177. */
  106178. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  106179. private _depthOfFieldBlurY;
  106180. private _dofMerge;
  106181. /**
  106182. * @hidden Internal post processes in depth of field effect
  106183. */
  106184. _effects: Array<PostProcess>;
  106185. /**
  106186. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  106187. */
  106188. focalLength: number;
  106189. /**
  106190. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  106191. */
  106192. fStop: number;
  106193. /**
  106194. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  106195. */
  106196. focusDistance: number;
  106197. /**
  106198. * 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.
  106199. */
  106200. lensSize: number;
  106201. /**
  106202. * Creates a new instance DepthOfFieldEffect
  106203. * @param scene The scene the effect belongs to.
  106204. * @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.
  106205. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  106206. * @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)
  106207. */
  106208. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  106209. /**
  106210. * 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.
  106211. */
  106212. depthTexture: RenderTargetTexture;
  106213. /**
  106214. * Disposes each of the internal effects for a given camera.
  106215. * @param camera The camera to dispose the effect on.
  106216. */
  106217. disposeEffects(camera: Camera): void;
  106218. /**
  106219. * @hidden Internal
  106220. */
  106221. _updateEffects(): void;
  106222. /**
  106223. * Internal
  106224. * @returns if all the contained post processes are ready.
  106225. * @hidden
  106226. */
  106227. _isReady(): boolean;
  106228. }
  106229. }
  106230. declare module BABYLON {
  106231. /** @hidden */
  106232. export var displayPassPixelShader: {
  106233. name: string;
  106234. shader: string;
  106235. };
  106236. }
  106237. declare module BABYLON {
  106238. /**
  106239. * DisplayPassPostProcess which produces an output the same as it's input
  106240. */
  106241. export class DisplayPassPostProcess extends PostProcess {
  106242. /**
  106243. * Creates the DisplayPassPostProcess
  106244. * @param name The name of the effect.
  106245. * @param options The required width/height ratio to downsize to before computing the render pass.
  106246. * @param camera The camera to apply the render pass to.
  106247. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106248. * @param engine The engine which the post process will be applied. (default: current engine)
  106249. * @param reusable If the post process can be reused on the same frame. (default: false)
  106250. */
  106251. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106252. }
  106253. }
  106254. declare module BABYLON {
  106255. /** @hidden */
  106256. export var filterPixelShader: {
  106257. name: string;
  106258. shader: string;
  106259. };
  106260. }
  106261. declare module BABYLON {
  106262. /**
  106263. * Applies a kernel filter to the image
  106264. */
  106265. export class FilterPostProcess extends PostProcess {
  106266. /** The matrix to be applied to the image */
  106267. kernelMatrix: Matrix;
  106268. /**
  106269. *
  106270. * @param name The name of the effect.
  106271. * @param kernelMatrix The matrix to be applied to the image
  106272. * @param options The required width/height ratio to downsize to before computing the render pass.
  106273. * @param camera The camera to apply the render pass to.
  106274. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106275. * @param engine The engine which the post process will be applied. (default: current engine)
  106276. * @param reusable If the post process can be reused on the same frame. (default: false)
  106277. */
  106278. constructor(name: string,
  106279. /** The matrix to be applied to the image */
  106280. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106281. }
  106282. }
  106283. declare module BABYLON {
  106284. /** @hidden */
  106285. export var fxaaPixelShader: {
  106286. name: string;
  106287. shader: string;
  106288. };
  106289. }
  106290. declare module BABYLON {
  106291. /** @hidden */
  106292. export var fxaaVertexShader: {
  106293. name: string;
  106294. shader: string;
  106295. };
  106296. }
  106297. declare module BABYLON {
  106298. /**
  106299. * Fxaa post process
  106300. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  106301. */
  106302. export class FxaaPostProcess extends PostProcess {
  106303. /** @hidden */
  106304. texelWidth: number;
  106305. /** @hidden */
  106306. texelHeight: number;
  106307. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  106308. private _getDefines;
  106309. }
  106310. }
  106311. declare module BABYLON {
  106312. /** @hidden */
  106313. export var grainPixelShader: {
  106314. name: string;
  106315. shader: string;
  106316. };
  106317. }
  106318. declare module BABYLON {
  106319. /**
  106320. * The GrainPostProcess adds noise to the image at mid luminance levels
  106321. */
  106322. export class GrainPostProcess extends PostProcess {
  106323. /**
  106324. * The intensity of the grain added (default: 30)
  106325. */
  106326. intensity: number;
  106327. /**
  106328. * If the grain should be randomized on every frame
  106329. */
  106330. animated: boolean;
  106331. /**
  106332. * Creates a new instance of @see GrainPostProcess
  106333. * @param name The name of the effect.
  106334. * @param options The required width/height ratio to downsize to before computing the render pass.
  106335. * @param camera The camera to apply the render pass to.
  106336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106337. * @param engine The engine which the post process will be applied. (default: current engine)
  106338. * @param reusable If the post process can be reused on the same frame. (default: false)
  106339. * @param textureType Type of textures used when performing the post process. (default: 0)
  106340. * @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)
  106341. */
  106342. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106343. }
  106344. }
  106345. declare module BABYLON {
  106346. /** @hidden */
  106347. export var highlightsPixelShader: {
  106348. name: string;
  106349. shader: string;
  106350. };
  106351. }
  106352. declare module BABYLON {
  106353. /**
  106354. * Extracts highlights from the image
  106355. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  106356. */
  106357. export class HighlightsPostProcess extends PostProcess {
  106358. /**
  106359. * Extracts highlights from the image
  106360. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  106361. * @param name The name of the effect.
  106362. * @param options The required width/height ratio to downsize to before computing the render pass.
  106363. * @param camera The camera to apply the render pass to.
  106364. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106365. * @param engine The engine which the post process will be applied. (default: current engine)
  106366. * @param reusable If the post process can be reused on the same frame. (default: false)
  106367. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  106368. */
  106369. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  106370. }
  106371. }
  106372. declare module BABYLON {
  106373. /** @hidden */
  106374. export var mrtFragmentDeclaration: {
  106375. name: string;
  106376. shader: string;
  106377. };
  106378. }
  106379. declare module BABYLON {
  106380. /** @hidden */
  106381. export var geometryPixelShader: {
  106382. name: string;
  106383. shader: string;
  106384. };
  106385. }
  106386. declare module BABYLON {
  106387. /** @hidden */
  106388. export var geometryVertexShader: {
  106389. name: string;
  106390. shader: string;
  106391. };
  106392. }
  106393. declare module BABYLON {
  106394. /**
  106395. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  106396. */
  106397. export class GeometryBufferRenderer {
  106398. /**
  106399. * Constant used to retrieve the position texture index in the G-Buffer textures array
  106400. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  106401. */
  106402. static readonly POSITION_TEXTURE_TYPE: number;
  106403. /**
  106404. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  106405. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  106406. */
  106407. static readonly VELOCITY_TEXTURE_TYPE: number;
  106408. /**
  106409. * Dictionary used to store the previous transformation matrices of each rendered mesh
  106410. * in order to compute objects velocities when enableVelocity is set to "true"
  106411. * @hidden
  106412. */
  106413. _previousTransformationMatrices: {
  106414. [index: number]: Matrix;
  106415. };
  106416. private _scene;
  106417. private _multiRenderTarget;
  106418. private _ratio;
  106419. private _enablePosition;
  106420. private _enableVelocity;
  106421. private _positionIndex;
  106422. private _velocityIndex;
  106423. protected _effect: Effect;
  106424. protected _cachedDefines: string;
  106425. /**
  106426. * Set the render list (meshes to be rendered) used in the G buffer.
  106427. */
  106428. renderList: Mesh[];
  106429. /**
  106430. * Gets wether or not G buffer are supported by the running hardware.
  106431. * This requires draw buffer supports
  106432. */
  106433. readonly isSupported: boolean;
  106434. /**
  106435. * Returns the index of the given texture type in the G-Buffer textures array
  106436. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  106437. * @returns the index of the given texture type in the G-Buffer textures array
  106438. */
  106439. getTextureIndex(textureType: number): number;
  106440. /**
  106441. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  106442. */
  106443. /**
  106444. * Sets whether or not objects positions are enabled for the G buffer.
  106445. */
  106446. enablePosition: boolean;
  106447. /**
  106448. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  106449. */
  106450. /**
  106451. * Sets wether or not objects velocities are enabled for the G buffer.
  106452. */
  106453. enableVelocity: boolean;
  106454. /**
  106455. * Gets the scene associated with the buffer.
  106456. */
  106457. readonly scene: Scene;
  106458. /**
  106459. * Gets the ratio used by the buffer during its creation.
  106460. * How big is the buffer related to the main canvas.
  106461. */
  106462. readonly ratio: number;
  106463. /** @hidden */
  106464. static _SceneComponentInitialization: (scene: Scene) => void;
  106465. /**
  106466. * Creates a new G Buffer for the scene
  106467. * @param scene The scene the buffer belongs to
  106468. * @param ratio How big is the buffer related to the main canvas.
  106469. */
  106470. constructor(scene: Scene, ratio?: number);
  106471. /**
  106472. * Checks wether everything is ready to render a submesh to the G buffer.
  106473. * @param subMesh the submesh to check readiness for
  106474. * @param useInstances is the mesh drawn using instance or not
  106475. * @returns true if ready otherwise false
  106476. */
  106477. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106478. /**
  106479. * Gets the current underlying G Buffer.
  106480. * @returns the buffer
  106481. */
  106482. getGBuffer(): MultiRenderTarget;
  106483. /**
  106484. * Gets the number of samples used to render the buffer (anti aliasing).
  106485. */
  106486. /**
  106487. * Sets the number of samples used to render the buffer (anti aliasing).
  106488. */
  106489. samples: number;
  106490. /**
  106491. * Disposes the renderer and frees up associated resources.
  106492. */
  106493. dispose(): void;
  106494. protected _createRenderTargets(): void;
  106495. }
  106496. }
  106497. declare module BABYLON {
  106498. /** @hidden */
  106499. export var motionBlurPixelShader: {
  106500. name: string;
  106501. shader: string;
  106502. };
  106503. }
  106504. declare module BABYLON {
  106505. /**
  106506. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  106507. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  106508. * As an example, all you have to do is to create the post-process:
  106509. * var mb = new BABYLON.MotionBlurPostProcess(
  106510. * 'mb', // The name of the effect.
  106511. * scene, // The scene containing the objects to blur according to their velocity.
  106512. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  106513. * camera // The camera to apply the render pass to.
  106514. * );
  106515. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  106516. */
  106517. export class MotionBlurPostProcess extends PostProcess {
  106518. /**
  106519. * Defines how much the image is blurred by the movement. Default value is equal to 1
  106520. */
  106521. motionStrength: number;
  106522. /**
  106523. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  106524. */
  106525. /**
  106526. * Sets the number of iterations to be used for motion blur quality
  106527. */
  106528. motionBlurSamples: number;
  106529. private _motionBlurSamples;
  106530. private _geometryBufferRenderer;
  106531. /**
  106532. * Creates a new instance MotionBlurPostProcess
  106533. * @param name The name of the effect.
  106534. * @param scene The scene containing the objects to blur according to their velocity.
  106535. * @param options The required width/height ratio to downsize to before computing the render pass.
  106536. * @param camera The camera to apply the render pass to.
  106537. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106538. * @param engine The engine which the post process will be applied. (default: current engine)
  106539. * @param reusable If the post process can be reused on the same frame. (default: false)
  106540. * @param textureType Type of textures used when performing the post process. (default: 0)
  106541. * @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)
  106542. */
  106543. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106544. /**
  106545. * Disposes the post process.
  106546. * @param camera The camera to dispose the post process on.
  106547. */
  106548. dispose(camera?: Camera): void;
  106549. }
  106550. }
  106551. declare module BABYLON {
  106552. /** @hidden */
  106553. export var refractionPixelShader: {
  106554. name: string;
  106555. shader: string;
  106556. };
  106557. }
  106558. declare module BABYLON {
  106559. /**
  106560. * Post process which applies a refractin texture
  106561. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  106562. */
  106563. export class RefractionPostProcess extends PostProcess {
  106564. /** the base color of the refraction (used to taint the rendering) */
  106565. color: Color3;
  106566. /** simulated refraction depth */
  106567. depth: number;
  106568. /** the coefficient of the base color (0 to remove base color tainting) */
  106569. colorLevel: number;
  106570. private _refTexture;
  106571. private _ownRefractionTexture;
  106572. /**
  106573. * Gets or sets the refraction texture
  106574. * Please note that you are responsible for disposing the texture if you set it manually
  106575. */
  106576. refractionTexture: Texture;
  106577. /**
  106578. * Initializes the RefractionPostProcess
  106579. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  106580. * @param name The name of the effect.
  106581. * @param refractionTextureUrl Url of the refraction texture to use
  106582. * @param color the base color of the refraction (used to taint the rendering)
  106583. * @param depth simulated refraction depth
  106584. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  106585. * @param camera The camera to apply the render pass to.
  106586. * @param options The required width/height ratio to downsize to before computing the render pass.
  106587. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106588. * @param engine The engine which the post process will be applied. (default: current engine)
  106589. * @param reusable If the post process can be reused on the same frame. (default: false)
  106590. */
  106591. constructor(name: string, refractionTextureUrl: string,
  106592. /** the base color of the refraction (used to taint the rendering) */
  106593. color: Color3,
  106594. /** simulated refraction depth */
  106595. depth: number,
  106596. /** the coefficient of the base color (0 to remove base color tainting) */
  106597. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106598. /**
  106599. * Disposes of the post process
  106600. * @param camera Camera to dispose post process on
  106601. */
  106602. dispose(camera: Camera): void;
  106603. }
  106604. }
  106605. declare module BABYLON {
  106606. /** @hidden */
  106607. export var sharpenPixelShader: {
  106608. name: string;
  106609. shader: string;
  106610. };
  106611. }
  106612. declare module BABYLON {
  106613. /**
  106614. * The SharpenPostProcess applies a sharpen kernel to every pixel
  106615. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  106616. */
  106617. export class SharpenPostProcess extends PostProcess {
  106618. /**
  106619. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  106620. */
  106621. colorAmount: number;
  106622. /**
  106623. * How much sharpness should be applied (default: 0.3)
  106624. */
  106625. edgeAmount: number;
  106626. /**
  106627. * Creates a new instance ConvolutionPostProcess
  106628. * @param name The name of the effect.
  106629. * @param options The required width/height ratio to downsize to before computing the render pass.
  106630. * @param camera The camera to apply the render pass to.
  106631. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106632. * @param engine The engine which the post process will be applied. (default: current engine)
  106633. * @param reusable If the post process can be reused on the same frame. (default: false)
  106634. * @param textureType Type of textures used when performing the post process. (default: 0)
  106635. * @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)
  106636. */
  106637. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106638. }
  106639. }
  106640. declare module BABYLON {
  106641. /**
  106642. * PostProcessRenderPipeline
  106643. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  106644. */
  106645. export class PostProcessRenderPipeline {
  106646. private engine;
  106647. private _renderEffects;
  106648. private _renderEffectsForIsolatedPass;
  106649. /**
  106650. * @hidden
  106651. */
  106652. protected _cameras: Camera[];
  106653. /** @hidden */
  106654. _name: string;
  106655. /**
  106656. * Initializes a PostProcessRenderPipeline
  106657. * @param engine engine to add the pipeline to
  106658. * @param name name of the pipeline
  106659. */
  106660. constructor(engine: Engine, name: string);
  106661. /**
  106662. * "PostProcessRenderPipeline"
  106663. * @returns "PostProcessRenderPipeline"
  106664. */
  106665. getClassName(): string;
  106666. /**
  106667. * If all the render effects in the pipeline are support
  106668. */
  106669. readonly isSupported: boolean;
  106670. /**
  106671. * Adds an effect to the pipeline
  106672. * @param renderEffect the effect to add
  106673. */
  106674. addEffect(renderEffect: PostProcessRenderEffect): void;
  106675. /** @hidden */
  106676. _rebuild(): void;
  106677. /** @hidden */
  106678. _enableEffect(renderEffectName: string, cameras: Camera): void;
  106679. /** @hidden */
  106680. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  106681. /** @hidden */
  106682. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  106683. /** @hidden */
  106684. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  106685. /** @hidden */
  106686. _attachCameras(cameras: Camera, unique: boolean): void;
  106687. /** @hidden */
  106688. _attachCameras(cameras: Camera[], unique: boolean): void;
  106689. /** @hidden */
  106690. _detachCameras(cameras: Camera): void;
  106691. /** @hidden */
  106692. _detachCameras(cameras: Nullable<Camera[]>): void;
  106693. /** @hidden */
  106694. _update(): void;
  106695. /** @hidden */
  106696. _reset(): void;
  106697. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  106698. /**
  106699. * Disposes of the pipeline
  106700. */
  106701. dispose(): void;
  106702. }
  106703. }
  106704. declare module BABYLON {
  106705. /**
  106706. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  106707. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  106708. */
  106709. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  106710. private _scene;
  106711. private _camerasToBeAttached;
  106712. /**
  106713. * ID of the sharpen post process,
  106714. */
  106715. private readonly SharpenPostProcessId;
  106716. /**
  106717. * @ignore
  106718. * ID of the image processing post process;
  106719. */
  106720. readonly ImageProcessingPostProcessId: string;
  106721. /**
  106722. * @ignore
  106723. * ID of the Fast Approximate Anti-Aliasing post process;
  106724. */
  106725. readonly FxaaPostProcessId: string;
  106726. /**
  106727. * ID of the chromatic aberration post process,
  106728. */
  106729. private readonly ChromaticAberrationPostProcessId;
  106730. /**
  106731. * ID of the grain post process
  106732. */
  106733. private readonly GrainPostProcessId;
  106734. /**
  106735. * Sharpen post process which will apply a sharpen convolution to enhance edges
  106736. */
  106737. sharpen: SharpenPostProcess;
  106738. private _sharpenEffect;
  106739. private bloom;
  106740. /**
  106741. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  106742. */
  106743. depthOfField: DepthOfFieldEffect;
  106744. /**
  106745. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  106746. */
  106747. fxaa: FxaaPostProcess;
  106748. /**
  106749. * Image post processing pass used to perform operations such as tone mapping or color grading.
  106750. */
  106751. imageProcessing: ImageProcessingPostProcess;
  106752. /**
  106753. * Chromatic aberration post process which will shift rgb colors in the image
  106754. */
  106755. chromaticAberration: ChromaticAberrationPostProcess;
  106756. private _chromaticAberrationEffect;
  106757. /**
  106758. * Grain post process which add noise to the image
  106759. */
  106760. grain: GrainPostProcess;
  106761. private _grainEffect;
  106762. /**
  106763. * Glow post process which adds a glow to emmisive areas of the image
  106764. */
  106765. private _glowLayer;
  106766. /**
  106767. * Animations which can be used to tweak settings over a period of time
  106768. */
  106769. animations: Animation[];
  106770. private _imageProcessingConfigurationObserver;
  106771. private _sharpenEnabled;
  106772. private _bloomEnabled;
  106773. private _depthOfFieldEnabled;
  106774. private _depthOfFieldBlurLevel;
  106775. private _fxaaEnabled;
  106776. private _imageProcessingEnabled;
  106777. private _defaultPipelineTextureType;
  106778. private _bloomScale;
  106779. private _chromaticAberrationEnabled;
  106780. private _grainEnabled;
  106781. private _buildAllowed;
  106782. /**
  106783. * Enable or disable the sharpen process from the pipeline
  106784. */
  106785. sharpenEnabled: boolean;
  106786. private _resizeObserver;
  106787. private _hardwareScaleLevel;
  106788. private _bloomKernel;
  106789. /**
  106790. * Specifies the size of the bloom blur kernel, relative to the final output size
  106791. */
  106792. bloomKernel: number;
  106793. /**
  106794. * Specifies the weight of the bloom in the final rendering
  106795. */
  106796. private _bloomWeight;
  106797. /**
  106798. * Specifies the luma threshold for the area that will be blurred by the bloom
  106799. */
  106800. private _bloomThreshold;
  106801. private _hdr;
  106802. /**
  106803. * The strength of the bloom.
  106804. */
  106805. bloomWeight: number;
  106806. /**
  106807. * The strength of the bloom.
  106808. */
  106809. bloomThreshold: number;
  106810. /**
  106811. * The scale of the bloom, lower value will provide better performance.
  106812. */
  106813. bloomScale: number;
  106814. /**
  106815. * Enable or disable the bloom from the pipeline
  106816. */
  106817. bloomEnabled: boolean;
  106818. private _rebuildBloom;
  106819. /**
  106820. * If the depth of field is enabled.
  106821. */
  106822. depthOfFieldEnabled: boolean;
  106823. /**
  106824. * Blur level of the depth of field effect. (Higher blur will effect performance)
  106825. */
  106826. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  106827. /**
  106828. * If the anti aliasing is enabled.
  106829. */
  106830. fxaaEnabled: boolean;
  106831. private _samples;
  106832. /**
  106833. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  106834. */
  106835. samples: number;
  106836. /**
  106837. * If image processing is enabled.
  106838. */
  106839. imageProcessingEnabled: boolean;
  106840. /**
  106841. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  106842. */
  106843. glowLayerEnabled: boolean;
  106844. /**
  106845. * Enable or disable the chromaticAberration process from the pipeline
  106846. */
  106847. chromaticAberrationEnabled: boolean;
  106848. /**
  106849. * Enable or disable the grain process from the pipeline
  106850. */
  106851. grainEnabled: boolean;
  106852. /**
  106853. * @constructor
  106854. * @param name - The rendering pipeline name (default: "")
  106855. * @param hdr - If high dynamic range textures should be used (default: true)
  106856. * @param scene - The scene linked to this pipeline (default: the last created scene)
  106857. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  106858. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  106859. */
  106860. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  106861. /**
  106862. * Force the compilation of the entire pipeline.
  106863. */
  106864. prepare(): void;
  106865. private _hasCleared;
  106866. private _prevPostProcess;
  106867. private _prevPrevPostProcess;
  106868. private _setAutoClearAndTextureSharing;
  106869. private _depthOfFieldSceneObserver;
  106870. private _buildPipeline;
  106871. private _disposePostProcesses;
  106872. /**
  106873. * Adds a camera to the pipeline
  106874. * @param camera the camera to be added
  106875. */
  106876. addCamera(camera: Camera): void;
  106877. /**
  106878. * Removes a camera from the pipeline
  106879. * @param camera the camera to remove
  106880. */
  106881. removeCamera(camera: Camera): void;
  106882. /**
  106883. * Dispose of the pipeline and stop all post processes
  106884. */
  106885. dispose(): void;
  106886. /**
  106887. * Serialize the rendering pipeline (Used when exporting)
  106888. * @returns the serialized object
  106889. */
  106890. serialize(): any;
  106891. /**
  106892. * Parse the serialized pipeline
  106893. * @param source Source pipeline.
  106894. * @param scene The scene to load the pipeline to.
  106895. * @param rootUrl The URL of the serialized pipeline.
  106896. * @returns An instantiated pipeline from the serialized object.
  106897. */
  106898. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  106899. }
  106900. }
  106901. declare module BABYLON {
  106902. /** @hidden */
  106903. export var lensHighlightsPixelShader: {
  106904. name: string;
  106905. shader: string;
  106906. };
  106907. }
  106908. declare module BABYLON {
  106909. /** @hidden */
  106910. export var depthOfFieldPixelShader: {
  106911. name: string;
  106912. shader: string;
  106913. };
  106914. }
  106915. declare module BABYLON {
  106916. /**
  106917. * BABYLON.JS Chromatic Aberration GLSL Shader
  106918. * Author: Olivier Guyot
  106919. * Separates very slightly R, G and B colors on the edges of the screen
  106920. * Inspired by Francois Tarlier & Martins Upitis
  106921. */
  106922. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  106923. /**
  106924. * @ignore
  106925. * The chromatic aberration PostProcess id in the pipeline
  106926. */
  106927. LensChromaticAberrationEffect: string;
  106928. /**
  106929. * @ignore
  106930. * The highlights enhancing PostProcess id in the pipeline
  106931. */
  106932. HighlightsEnhancingEffect: string;
  106933. /**
  106934. * @ignore
  106935. * The depth-of-field PostProcess id in the pipeline
  106936. */
  106937. LensDepthOfFieldEffect: string;
  106938. private _scene;
  106939. private _depthTexture;
  106940. private _grainTexture;
  106941. private _chromaticAberrationPostProcess;
  106942. private _highlightsPostProcess;
  106943. private _depthOfFieldPostProcess;
  106944. private _edgeBlur;
  106945. private _grainAmount;
  106946. private _chromaticAberration;
  106947. private _distortion;
  106948. private _highlightsGain;
  106949. private _highlightsThreshold;
  106950. private _dofDistance;
  106951. private _dofAperture;
  106952. private _dofDarken;
  106953. private _dofPentagon;
  106954. private _blurNoise;
  106955. /**
  106956. * @constructor
  106957. *
  106958. * Effect parameters are as follow:
  106959. * {
  106960. * chromatic_aberration: number; // from 0 to x (1 for realism)
  106961. * edge_blur: number; // from 0 to x (1 for realism)
  106962. * distortion: number; // from 0 to x (1 for realism)
  106963. * grain_amount: number; // from 0 to 1
  106964. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  106965. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  106966. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  106967. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  106968. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  106969. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  106970. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  106971. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  106972. * }
  106973. * Note: if an effect parameter is unset, effect is disabled
  106974. *
  106975. * @param name The rendering pipeline name
  106976. * @param parameters - An object containing all parameters (see above)
  106977. * @param scene The scene linked to this pipeline
  106978. * @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)
  106979. * @param cameras The array of cameras that the rendering pipeline will be attached to
  106980. */
  106981. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  106982. /**
  106983. * Sets the amount of blur at the edges
  106984. * @param amount blur amount
  106985. */
  106986. setEdgeBlur(amount: number): void;
  106987. /**
  106988. * Sets edge blur to 0
  106989. */
  106990. disableEdgeBlur(): void;
  106991. /**
  106992. * Sets the amout of grain
  106993. * @param amount Amount of grain
  106994. */
  106995. setGrainAmount(amount: number): void;
  106996. /**
  106997. * Set grain amount to 0
  106998. */
  106999. disableGrain(): void;
  107000. /**
  107001. * Sets the chromatic aberration amount
  107002. * @param amount amount of chromatic aberration
  107003. */
  107004. setChromaticAberration(amount: number): void;
  107005. /**
  107006. * Sets chromatic aberration amount to 0
  107007. */
  107008. disableChromaticAberration(): void;
  107009. /**
  107010. * Sets the EdgeDistortion amount
  107011. * @param amount amount of EdgeDistortion
  107012. */
  107013. setEdgeDistortion(amount: number): void;
  107014. /**
  107015. * Sets edge distortion to 0
  107016. */
  107017. disableEdgeDistortion(): void;
  107018. /**
  107019. * Sets the FocusDistance amount
  107020. * @param amount amount of FocusDistance
  107021. */
  107022. setFocusDistance(amount: number): void;
  107023. /**
  107024. * Disables depth of field
  107025. */
  107026. disableDepthOfField(): void;
  107027. /**
  107028. * Sets the Aperture amount
  107029. * @param amount amount of Aperture
  107030. */
  107031. setAperture(amount: number): void;
  107032. /**
  107033. * Sets the DarkenOutOfFocus amount
  107034. * @param amount amount of DarkenOutOfFocus
  107035. */
  107036. setDarkenOutOfFocus(amount: number): void;
  107037. /**
  107038. * Creates a pentagon bokeh effect
  107039. */
  107040. enablePentagonBokeh(): void;
  107041. /**
  107042. * Disables the pentagon bokeh effect
  107043. */
  107044. disablePentagonBokeh(): void;
  107045. /**
  107046. * Enables noise blur
  107047. */
  107048. enableNoiseBlur(): void;
  107049. /**
  107050. * Disables noise blur
  107051. */
  107052. disableNoiseBlur(): void;
  107053. /**
  107054. * Sets the HighlightsGain amount
  107055. * @param amount amount of HighlightsGain
  107056. */
  107057. setHighlightsGain(amount: number): void;
  107058. /**
  107059. * Sets the HighlightsThreshold amount
  107060. * @param amount amount of HighlightsThreshold
  107061. */
  107062. setHighlightsThreshold(amount: number): void;
  107063. /**
  107064. * Disables highlights
  107065. */
  107066. disableHighlights(): void;
  107067. /**
  107068. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  107069. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  107070. */
  107071. dispose(disableDepthRender?: boolean): void;
  107072. private _createChromaticAberrationPostProcess;
  107073. private _createHighlightsPostProcess;
  107074. private _createDepthOfFieldPostProcess;
  107075. private _createGrainTexture;
  107076. }
  107077. }
  107078. declare module BABYLON {
  107079. /** @hidden */
  107080. export var ssao2PixelShader: {
  107081. name: string;
  107082. shader: string;
  107083. };
  107084. }
  107085. declare module BABYLON {
  107086. /** @hidden */
  107087. export var ssaoCombinePixelShader: {
  107088. name: string;
  107089. shader: string;
  107090. };
  107091. }
  107092. declare module BABYLON {
  107093. /**
  107094. * Render pipeline to produce ssao effect
  107095. */
  107096. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  107097. /**
  107098. * @ignore
  107099. * The PassPostProcess id in the pipeline that contains the original scene color
  107100. */
  107101. SSAOOriginalSceneColorEffect: string;
  107102. /**
  107103. * @ignore
  107104. * The SSAO PostProcess id in the pipeline
  107105. */
  107106. SSAORenderEffect: string;
  107107. /**
  107108. * @ignore
  107109. * The horizontal blur PostProcess id in the pipeline
  107110. */
  107111. SSAOBlurHRenderEffect: string;
  107112. /**
  107113. * @ignore
  107114. * The vertical blur PostProcess id in the pipeline
  107115. */
  107116. SSAOBlurVRenderEffect: string;
  107117. /**
  107118. * @ignore
  107119. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  107120. */
  107121. SSAOCombineRenderEffect: string;
  107122. /**
  107123. * The output strength of the SSAO post-process. Default value is 1.0.
  107124. */
  107125. totalStrength: number;
  107126. /**
  107127. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  107128. */
  107129. maxZ: number;
  107130. /**
  107131. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  107132. */
  107133. minZAspect: number;
  107134. private _samples;
  107135. /**
  107136. * Number of samples used for the SSAO calculations. Default value is 8
  107137. */
  107138. samples: number;
  107139. private _textureSamples;
  107140. /**
  107141. * Number of samples to use for antialiasing
  107142. */
  107143. textureSamples: number;
  107144. /**
  107145. * Ratio object used for SSAO ratio and blur ratio
  107146. */
  107147. private _ratio;
  107148. /**
  107149. * Dynamically generated sphere sampler.
  107150. */
  107151. private _sampleSphere;
  107152. /**
  107153. * Blur filter offsets
  107154. */
  107155. private _samplerOffsets;
  107156. private _expensiveBlur;
  107157. /**
  107158. * If bilateral blur should be used
  107159. */
  107160. expensiveBlur: boolean;
  107161. /**
  107162. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  107163. */
  107164. radius: number;
  107165. /**
  107166. * The base color of the SSAO post-process
  107167. * The final result is "base + ssao" between [0, 1]
  107168. */
  107169. base: number;
  107170. /**
  107171. * Support test.
  107172. */
  107173. static readonly IsSupported: boolean;
  107174. private _scene;
  107175. private _depthTexture;
  107176. private _normalTexture;
  107177. private _randomTexture;
  107178. private _originalColorPostProcess;
  107179. private _ssaoPostProcess;
  107180. private _blurHPostProcess;
  107181. private _blurVPostProcess;
  107182. private _ssaoCombinePostProcess;
  107183. private _firstUpdate;
  107184. /**
  107185. * @constructor
  107186. * @param name The rendering pipeline name
  107187. * @param scene The scene linked to this pipeline
  107188. * @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 }
  107189. * @param cameras The array of cameras that the rendering pipeline will be attached to
  107190. */
  107191. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  107192. /**
  107193. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  107194. */
  107195. dispose(disableGeometryBufferRenderer?: boolean): void;
  107196. private _createBlurPostProcess;
  107197. /** @hidden */
  107198. _rebuild(): void;
  107199. private _bits;
  107200. private _radicalInverse_VdC;
  107201. private _hammersley;
  107202. private _hemisphereSample_uniform;
  107203. private _generateHemisphere;
  107204. private _createSSAOPostProcess;
  107205. private _createSSAOCombinePostProcess;
  107206. private _createRandomTexture;
  107207. /**
  107208. * Serialize the rendering pipeline (Used when exporting)
  107209. * @returns the serialized object
  107210. */
  107211. serialize(): any;
  107212. /**
  107213. * Parse the serialized pipeline
  107214. * @param source Source pipeline.
  107215. * @param scene The scene to load the pipeline to.
  107216. * @param rootUrl The URL of the serialized pipeline.
  107217. * @returns An instantiated pipeline from the serialized object.
  107218. */
  107219. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  107220. }
  107221. }
  107222. declare module BABYLON {
  107223. /** @hidden */
  107224. export var ssaoPixelShader: {
  107225. name: string;
  107226. shader: string;
  107227. };
  107228. }
  107229. declare module BABYLON {
  107230. /**
  107231. * Render pipeline to produce ssao effect
  107232. */
  107233. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  107234. /**
  107235. * @ignore
  107236. * The PassPostProcess id in the pipeline that contains the original scene color
  107237. */
  107238. SSAOOriginalSceneColorEffect: string;
  107239. /**
  107240. * @ignore
  107241. * The SSAO PostProcess id in the pipeline
  107242. */
  107243. SSAORenderEffect: string;
  107244. /**
  107245. * @ignore
  107246. * The horizontal blur PostProcess id in the pipeline
  107247. */
  107248. SSAOBlurHRenderEffect: string;
  107249. /**
  107250. * @ignore
  107251. * The vertical blur PostProcess id in the pipeline
  107252. */
  107253. SSAOBlurVRenderEffect: string;
  107254. /**
  107255. * @ignore
  107256. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  107257. */
  107258. SSAOCombineRenderEffect: string;
  107259. /**
  107260. * The output strength of the SSAO post-process. Default value is 1.0.
  107261. */
  107262. totalStrength: number;
  107263. /**
  107264. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  107265. */
  107266. radius: number;
  107267. /**
  107268. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  107269. * Must not be equal to fallOff and superior to fallOff.
  107270. * Default value is 0.975
  107271. */
  107272. area: number;
  107273. /**
  107274. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  107275. * Must not be equal to area and inferior to area.
  107276. * Default value is 0.0
  107277. */
  107278. fallOff: number;
  107279. /**
  107280. * The base color of the SSAO post-process
  107281. * The final result is "base + ssao" between [0, 1]
  107282. */
  107283. base: number;
  107284. private _scene;
  107285. private _depthTexture;
  107286. private _randomTexture;
  107287. private _originalColorPostProcess;
  107288. private _ssaoPostProcess;
  107289. private _blurHPostProcess;
  107290. private _blurVPostProcess;
  107291. private _ssaoCombinePostProcess;
  107292. private _firstUpdate;
  107293. /**
  107294. * @constructor
  107295. * @param name - The rendering pipeline name
  107296. * @param scene - The scene linked to this pipeline
  107297. * @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 }
  107298. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  107299. */
  107300. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  107301. /**
  107302. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  107303. */
  107304. dispose(disableDepthRender?: boolean): void;
  107305. private _createBlurPostProcess;
  107306. /** @hidden */
  107307. _rebuild(): void;
  107308. private _createSSAOPostProcess;
  107309. private _createSSAOCombinePostProcess;
  107310. private _createRandomTexture;
  107311. }
  107312. }
  107313. declare module BABYLON {
  107314. /** @hidden */
  107315. export var standardPixelShader: {
  107316. name: string;
  107317. shader: string;
  107318. };
  107319. }
  107320. declare module BABYLON {
  107321. /**
  107322. * Standard rendering pipeline
  107323. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  107324. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  107325. */
  107326. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  107327. /**
  107328. * Public members
  107329. */
  107330. /**
  107331. * Post-process which contains the original scene color before the pipeline applies all the effects
  107332. */
  107333. originalPostProcess: Nullable<PostProcess>;
  107334. /**
  107335. * Post-process used to down scale an image x4
  107336. */
  107337. downSampleX4PostProcess: Nullable<PostProcess>;
  107338. /**
  107339. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  107340. */
  107341. brightPassPostProcess: Nullable<PostProcess>;
  107342. /**
  107343. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  107344. */
  107345. blurHPostProcesses: PostProcess[];
  107346. /**
  107347. * Post-process array storing all the vertical blur post-processes used by the pipeline
  107348. */
  107349. blurVPostProcesses: PostProcess[];
  107350. /**
  107351. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  107352. */
  107353. textureAdderPostProcess: Nullable<PostProcess>;
  107354. /**
  107355. * Post-process used to create volumetric lighting effect
  107356. */
  107357. volumetricLightPostProcess: Nullable<PostProcess>;
  107358. /**
  107359. * Post-process used to smooth the previous volumetric light post-process on the X axis
  107360. */
  107361. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  107362. /**
  107363. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  107364. */
  107365. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  107366. /**
  107367. * Post-process used to merge the volumetric light effect and the real scene color
  107368. */
  107369. volumetricLightMergePostProces: Nullable<PostProcess>;
  107370. /**
  107371. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  107372. */
  107373. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  107374. /**
  107375. * Base post-process used to calculate the average luminance of the final image for HDR
  107376. */
  107377. luminancePostProcess: Nullable<PostProcess>;
  107378. /**
  107379. * Post-processes used to create down sample post-processes in order to get
  107380. * the average luminance of the final image for HDR
  107381. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  107382. */
  107383. luminanceDownSamplePostProcesses: PostProcess[];
  107384. /**
  107385. * Post-process used to create a HDR effect (light adaptation)
  107386. */
  107387. hdrPostProcess: Nullable<PostProcess>;
  107388. /**
  107389. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  107390. */
  107391. textureAdderFinalPostProcess: Nullable<PostProcess>;
  107392. /**
  107393. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  107394. */
  107395. lensFlareFinalPostProcess: Nullable<PostProcess>;
  107396. /**
  107397. * Post-process used to merge the final HDR post-process and the real scene color
  107398. */
  107399. hdrFinalPostProcess: Nullable<PostProcess>;
  107400. /**
  107401. * Post-process used to create a lens flare effect
  107402. */
  107403. lensFlarePostProcess: Nullable<PostProcess>;
  107404. /**
  107405. * Post-process that merges the result of the lens flare post-process and the real scene color
  107406. */
  107407. lensFlareComposePostProcess: Nullable<PostProcess>;
  107408. /**
  107409. * Post-process used to create a motion blur effect
  107410. */
  107411. motionBlurPostProcess: Nullable<PostProcess>;
  107412. /**
  107413. * Post-process used to create a depth of field effect
  107414. */
  107415. depthOfFieldPostProcess: Nullable<PostProcess>;
  107416. /**
  107417. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  107418. */
  107419. fxaaPostProcess: Nullable<FxaaPostProcess>;
  107420. /**
  107421. * Represents the brightness threshold in order to configure the illuminated surfaces
  107422. */
  107423. brightThreshold: number;
  107424. /**
  107425. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  107426. */
  107427. blurWidth: number;
  107428. /**
  107429. * Sets if the blur for highlighted surfaces must be only horizontal
  107430. */
  107431. horizontalBlur: boolean;
  107432. /**
  107433. * Sets the overall exposure used by the pipeline
  107434. */
  107435. exposure: number;
  107436. /**
  107437. * Texture used typically to simulate "dirty" on camera lens
  107438. */
  107439. lensTexture: Nullable<Texture>;
  107440. /**
  107441. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  107442. */
  107443. volumetricLightCoefficient: number;
  107444. /**
  107445. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  107446. */
  107447. volumetricLightPower: number;
  107448. /**
  107449. * Used the set the blur intensity to smooth the volumetric lights
  107450. */
  107451. volumetricLightBlurScale: number;
  107452. /**
  107453. * Light (spot or directional) used to generate the volumetric lights rays
  107454. * The source light must have a shadow generate so the pipeline can get its
  107455. * depth map
  107456. */
  107457. sourceLight: Nullable<SpotLight | DirectionalLight>;
  107458. /**
  107459. * For eye adaptation, represents the minimum luminance the eye can see
  107460. */
  107461. hdrMinimumLuminance: number;
  107462. /**
  107463. * For eye adaptation, represents the decrease luminance speed
  107464. */
  107465. hdrDecreaseRate: number;
  107466. /**
  107467. * For eye adaptation, represents the increase luminance speed
  107468. */
  107469. hdrIncreaseRate: number;
  107470. /**
  107471. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  107472. */
  107473. lensColorTexture: Nullable<Texture>;
  107474. /**
  107475. * The overall strengh for the lens flare effect
  107476. */
  107477. lensFlareStrength: number;
  107478. /**
  107479. * Dispersion coefficient for lens flare ghosts
  107480. */
  107481. lensFlareGhostDispersal: number;
  107482. /**
  107483. * Main lens flare halo width
  107484. */
  107485. lensFlareHaloWidth: number;
  107486. /**
  107487. * Based on the lens distortion effect, defines how much the lens flare result
  107488. * is distorted
  107489. */
  107490. lensFlareDistortionStrength: number;
  107491. /**
  107492. * Lens star texture must be used to simulate rays on the flares and is available
  107493. * in the documentation
  107494. */
  107495. lensStarTexture: Nullable<Texture>;
  107496. /**
  107497. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  107498. * flare effect by taking account of the dirt texture
  107499. */
  107500. lensFlareDirtTexture: Nullable<Texture>;
  107501. /**
  107502. * Represents the focal length for the depth of field effect
  107503. */
  107504. depthOfFieldDistance: number;
  107505. /**
  107506. * Represents the blur intensity for the blurred part of the depth of field effect
  107507. */
  107508. depthOfFieldBlurWidth: number;
  107509. /**
  107510. * For motion blur, defines how much the image is blurred by the movement
  107511. */
  107512. motionStrength: number;
  107513. /**
  107514. * List of animations for the pipeline (IAnimatable implementation)
  107515. */
  107516. animations: Animation[];
  107517. /**
  107518. * Private members
  107519. */
  107520. private _scene;
  107521. private _currentDepthOfFieldSource;
  107522. private _basePostProcess;
  107523. private _hdrCurrentLuminance;
  107524. private _floatTextureType;
  107525. private _ratio;
  107526. private _bloomEnabled;
  107527. private _depthOfFieldEnabled;
  107528. private _vlsEnabled;
  107529. private _lensFlareEnabled;
  107530. private _hdrEnabled;
  107531. private _motionBlurEnabled;
  107532. private _fxaaEnabled;
  107533. private _motionBlurSamples;
  107534. private _volumetricLightStepsCount;
  107535. private _samples;
  107536. /**
  107537. * @ignore
  107538. * Specifies if the bloom pipeline is enabled
  107539. */
  107540. BloomEnabled: boolean;
  107541. /**
  107542. * @ignore
  107543. * Specifies if the depth of field pipeline is enabed
  107544. */
  107545. DepthOfFieldEnabled: boolean;
  107546. /**
  107547. * @ignore
  107548. * Specifies if the lens flare pipeline is enabed
  107549. */
  107550. LensFlareEnabled: boolean;
  107551. /**
  107552. * @ignore
  107553. * Specifies if the HDR pipeline is enabled
  107554. */
  107555. HDREnabled: boolean;
  107556. /**
  107557. * @ignore
  107558. * Specifies if the volumetric lights scattering effect is enabled
  107559. */
  107560. VLSEnabled: boolean;
  107561. /**
  107562. * @ignore
  107563. * Specifies if the motion blur effect is enabled
  107564. */
  107565. MotionBlurEnabled: boolean;
  107566. /**
  107567. * Specifies if anti-aliasing is enabled
  107568. */
  107569. fxaaEnabled: boolean;
  107570. /**
  107571. * Specifies the number of steps used to calculate the volumetric lights
  107572. * Typically in interval [50, 200]
  107573. */
  107574. volumetricLightStepsCount: number;
  107575. /**
  107576. * Specifies the number of samples used for the motion blur effect
  107577. * Typically in interval [16, 64]
  107578. */
  107579. motionBlurSamples: number;
  107580. /**
  107581. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  107582. */
  107583. samples: number;
  107584. /**
  107585. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  107586. * @constructor
  107587. * @param name The rendering pipeline name
  107588. * @param scene The scene linked to this pipeline
  107589. * @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)
  107590. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  107591. * @param cameras The array of cameras that the rendering pipeline will be attached to
  107592. */
  107593. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  107594. private _buildPipeline;
  107595. private _createDownSampleX4PostProcess;
  107596. private _createBrightPassPostProcess;
  107597. private _createBlurPostProcesses;
  107598. private _createTextureAdderPostProcess;
  107599. private _createVolumetricLightPostProcess;
  107600. private _createLuminancePostProcesses;
  107601. private _createHdrPostProcess;
  107602. private _createLensFlarePostProcess;
  107603. private _createDepthOfFieldPostProcess;
  107604. private _createMotionBlurPostProcess;
  107605. private _getDepthTexture;
  107606. private _disposePostProcesses;
  107607. /**
  107608. * Dispose of the pipeline and stop all post processes
  107609. */
  107610. dispose(): void;
  107611. /**
  107612. * Serialize the rendering pipeline (Used when exporting)
  107613. * @returns the serialized object
  107614. */
  107615. serialize(): any;
  107616. /**
  107617. * Parse the serialized pipeline
  107618. * @param source Source pipeline.
  107619. * @param scene The scene to load the pipeline to.
  107620. * @param rootUrl The URL of the serialized pipeline.
  107621. * @returns An instantiated pipeline from the serialized object.
  107622. */
  107623. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  107624. /**
  107625. * Luminance steps
  107626. */
  107627. static LuminanceSteps: number;
  107628. }
  107629. }
  107630. declare module BABYLON {
  107631. /**
  107632. * PostProcessRenderPipelineManager class
  107633. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107634. */
  107635. export class PostProcessRenderPipelineManager {
  107636. private _renderPipelines;
  107637. /**
  107638. * Initializes a PostProcessRenderPipelineManager
  107639. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107640. */
  107641. constructor();
  107642. /**
  107643. * Adds a pipeline to the manager
  107644. * @param renderPipeline The pipeline to add
  107645. */
  107646. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  107647. /**
  107648. * Attaches a camera to the pipeline
  107649. * @param renderPipelineName The name of the pipeline to attach to
  107650. * @param cameras the camera to attach
  107651. * @param unique if the camera can be attached multiple times to the pipeline
  107652. */
  107653. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  107654. /**
  107655. * Detaches a camera from the pipeline
  107656. * @param renderPipelineName The name of the pipeline to detach from
  107657. * @param cameras the camera to detach
  107658. */
  107659. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  107660. /**
  107661. * Enables an effect by name on a pipeline
  107662. * @param renderPipelineName the name of the pipeline to enable the effect in
  107663. * @param renderEffectName the name of the effect to enable
  107664. * @param cameras the cameras that the effect should be enabled on
  107665. */
  107666. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  107667. /**
  107668. * Disables an effect by name on a pipeline
  107669. * @param renderPipelineName the name of the pipeline to disable the effect in
  107670. * @param renderEffectName the name of the effect to disable
  107671. * @param cameras the cameras that the effect should be disabled on
  107672. */
  107673. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  107674. /**
  107675. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  107676. */
  107677. update(): void;
  107678. /** @hidden */
  107679. _rebuild(): void;
  107680. /**
  107681. * Disposes of the manager and pipelines
  107682. */
  107683. dispose(): void;
  107684. }
  107685. }
  107686. declare module BABYLON {
  107687. interface Scene {
  107688. /** @hidden (Backing field) */
  107689. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  107690. /**
  107691. * Gets the postprocess render pipeline manager
  107692. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107693. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  107694. */
  107695. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  107696. }
  107697. /**
  107698. * Defines the Render Pipeline scene component responsible to rendering pipelines
  107699. */
  107700. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  107701. /**
  107702. * The component name helpfull to identify the component in the list of scene components.
  107703. */
  107704. readonly name: string;
  107705. /**
  107706. * The scene the component belongs to.
  107707. */
  107708. scene: Scene;
  107709. /**
  107710. * Creates a new instance of the component for the given scene
  107711. * @param scene Defines the scene to register the component in
  107712. */
  107713. constructor(scene: Scene);
  107714. /**
  107715. * Registers the component in a given scene
  107716. */
  107717. register(): void;
  107718. /**
  107719. * Rebuilds the elements related to this component in case of
  107720. * context lost for instance.
  107721. */
  107722. rebuild(): void;
  107723. /**
  107724. * Disposes the component and the associated ressources
  107725. */
  107726. dispose(): void;
  107727. private _gatherRenderTargets;
  107728. }
  107729. }
  107730. declare module BABYLON {
  107731. /** @hidden */
  107732. export var tonemapPixelShader: {
  107733. name: string;
  107734. shader: string;
  107735. };
  107736. }
  107737. declare module BABYLON {
  107738. /** Defines operator used for tonemapping */
  107739. export enum TonemappingOperator {
  107740. /** Hable */
  107741. Hable = 0,
  107742. /** Reinhard */
  107743. Reinhard = 1,
  107744. /** HejiDawson */
  107745. HejiDawson = 2,
  107746. /** Photographic */
  107747. Photographic = 3
  107748. }
  107749. /**
  107750. * Defines a post process to apply tone mapping
  107751. */
  107752. export class TonemapPostProcess extends PostProcess {
  107753. private _operator;
  107754. /** Defines the required exposure adjustement */
  107755. exposureAdjustment: number;
  107756. /**
  107757. * Creates a new TonemapPostProcess
  107758. * @param name defines the name of the postprocess
  107759. * @param _operator defines the operator to use
  107760. * @param exposureAdjustment defines the required exposure adjustement
  107761. * @param camera defines the camera to use (can be null)
  107762. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  107763. * @param engine defines the hosting engine (can be ignore if camera is set)
  107764. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  107765. */
  107766. constructor(name: string, _operator: TonemappingOperator,
  107767. /** Defines the required exposure adjustement */
  107768. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  107769. }
  107770. }
  107771. declare module BABYLON {
  107772. /** @hidden */
  107773. export var depthVertexShader: {
  107774. name: string;
  107775. shader: string;
  107776. };
  107777. }
  107778. declare module BABYLON {
  107779. /** @hidden */
  107780. export var volumetricLightScatteringPixelShader: {
  107781. name: string;
  107782. shader: string;
  107783. };
  107784. }
  107785. declare module BABYLON {
  107786. /** @hidden */
  107787. export var volumetricLightScatteringPassPixelShader: {
  107788. name: string;
  107789. shader: string;
  107790. };
  107791. }
  107792. declare module BABYLON {
  107793. /**
  107794. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  107795. */
  107796. export class VolumetricLightScatteringPostProcess extends PostProcess {
  107797. private _volumetricLightScatteringPass;
  107798. private _volumetricLightScatteringRTT;
  107799. private _viewPort;
  107800. private _screenCoordinates;
  107801. private _cachedDefines;
  107802. /**
  107803. * If not undefined, the mesh position is computed from the attached node position
  107804. */
  107805. attachedNode: {
  107806. position: Vector3;
  107807. };
  107808. /**
  107809. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  107810. */
  107811. customMeshPosition: Vector3;
  107812. /**
  107813. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  107814. */
  107815. useCustomMeshPosition: boolean;
  107816. /**
  107817. * If the post-process should inverse the light scattering direction
  107818. */
  107819. invert: boolean;
  107820. /**
  107821. * The internal mesh used by the post-process
  107822. */
  107823. mesh: Mesh;
  107824. /**
  107825. * @hidden
  107826. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  107827. */
  107828. useDiffuseColor: boolean;
  107829. /**
  107830. * Array containing the excluded meshes not rendered in the internal pass
  107831. */
  107832. excludedMeshes: AbstractMesh[];
  107833. /**
  107834. * Controls the overall intensity of the post-process
  107835. */
  107836. exposure: number;
  107837. /**
  107838. * Dissipates each sample's contribution in range [0, 1]
  107839. */
  107840. decay: number;
  107841. /**
  107842. * Controls the overall intensity of each sample
  107843. */
  107844. weight: number;
  107845. /**
  107846. * Controls the density of each sample
  107847. */
  107848. density: number;
  107849. /**
  107850. * @constructor
  107851. * @param name The post-process name
  107852. * @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)
  107853. * @param camera The camera that the post-process will be attached to
  107854. * @param mesh The mesh used to create the light scattering
  107855. * @param samples The post-process quality, default 100
  107856. * @param samplingModeThe post-process filtering mode
  107857. * @param engine The babylon engine
  107858. * @param reusable If the post-process is reusable
  107859. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  107860. */
  107861. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  107862. /**
  107863. * Returns the string "VolumetricLightScatteringPostProcess"
  107864. * @returns "VolumetricLightScatteringPostProcess"
  107865. */
  107866. getClassName(): string;
  107867. private _isReady;
  107868. /**
  107869. * Sets the new light position for light scattering effect
  107870. * @param position The new custom light position
  107871. */
  107872. setCustomMeshPosition(position: Vector3): void;
  107873. /**
  107874. * Returns the light position for light scattering effect
  107875. * @return Vector3 The custom light position
  107876. */
  107877. getCustomMeshPosition(): Vector3;
  107878. /**
  107879. * Disposes the internal assets and detaches the post-process from the camera
  107880. */
  107881. dispose(camera: Camera): void;
  107882. /**
  107883. * Returns the render target texture used by the post-process
  107884. * @return the render target texture used by the post-process
  107885. */
  107886. getPass(): RenderTargetTexture;
  107887. private _meshExcluded;
  107888. private _createPass;
  107889. private _updateMeshScreenCoordinates;
  107890. /**
  107891. * Creates a default mesh for the Volumeric Light Scattering post-process
  107892. * @param name The mesh name
  107893. * @param scene The scene where to create the mesh
  107894. * @return the default mesh
  107895. */
  107896. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  107897. }
  107898. }
  107899. declare module BABYLON {
  107900. interface Scene {
  107901. /** @hidden (Backing field) */
  107902. _boundingBoxRenderer: BoundingBoxRenderer;
  107903. /** @hidden (Backing field) */
  107904. _forceShowBoundingBoxes: boolean;
  107905. /**
  107906. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  107907. */
  107908. forceShowBoundingBoxes: boolean;
  107909. /**
  107910. * Gets the bounding box renderer associated with the scene
  107911. * @returns a BoundingBoxRenderer
  107912. */
  107913. getBoundingBoxRenderer(): BoundingBoxRenderer;
  107914. }
  107915. interface AbstractMesh {
  107916. /** @hidden (Backing field) */
  107917. _showBoundingBox: boolean;
  107918. /**
  107919. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  107920. */
  107921. showBoundingBox: boolean;
  107922. }
  107923. /**
  107924. * Component responsible of rendering the bounding box of the meshes in a scene.
  107925. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  107926. */
  107927. export class BoundingBoxRenderer implements ISceneComponent {
  107928. /**
  107929. * The component name helpfull to identify the component in the list of scene components.
  107930. */
  107931. readonly name: string;
  107932. /**
  107933. * The scene the component belongs to.
  107934. */
  107935. scene: Scene;
  107936. /**
  107937. * Color of the bounding box lines placed in front of an object
  107938. */
  107939. frontColor: Color3;
  107940. /**
  107941. * Color of the bounding box lines placed behind an object
  107942. */
  107943. backColor: Color3;
  107944. /**
  107945. * Defines if the renderer should show the back lines or not
  107946. */
  107947. showBackLines: boolean;
  107948. /**
  107949. * @hidden
  107950. */
  107951. renderList: SmartArray<BoundingBox>;
  107952. private _colorShader;
  107953. private _vertexBuffers;
  107954. private _indexBuffer;
  107955. /**
  107956. * Instantiates a new bounding box renderer in a scene.
  107957. * @param scene the scene the renderer renders in
  107958. */
  107959. constructor(scene: Scene);
  107960. /**
  107961. * Registers the component in a given scene
  107962. */
  107963. register(): void;
  107964. private _evaluateSubMesh;
  107965. private _activeMesh;
  107966. private _prepareRessources;
  107967. private _createIndexBuffer;
  107968. /**
  107969. * Rebuilds the elements related to this component in case of
  107970. * context lost for instance.
  107971. */
  107972. rebuild(): void;
  107973. /**
  107974. * @hidden
  107975. */
  107976. reset(): void;
  107977. /**
  107978. * Render the bounding boxes of a specific rendering group
  107979. * @param renderingGroupId defines the rendering group to render
  107980. */
  107981. render(renderingGroupId: number): void;
  107982. /**
  107983. * In case of occlusion queries, we can render the occlusion bounding box through this method
  107984. * @param mesh Define the mesh to render the occlusion bounding box for
  107985. */
  107986. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  107987. /**
  107988. * Dispose and release the resources attached to this renderer.
  107989. */
  107990. dispose(): void;
  107991. }
  107992. }
  107993. declare module BABYLON {
  107994. /** @hidden */
  107995. export var depthPixelShader: {
  107996. name: string;
  107997. shader: string;
  107998. };
  107999. }
  108000. declare module BABYLON {
  108001. /**
  108002. * This represents a depth renderer in Babylon.
  108003. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  108004. */
  108005. export class DepthRenderer {
  108006. private _scene;
  108007. private _depthMap;
  108008. private _effect;
  108009. private _cachedDefines;
  108010. private _camera;
  108011. /**
  108012. * Specifiess that the depth renderer will only be used within
  108013. * the camera it is created for.
  108014. * This can help forcing its rendering during the camera processing.
  108015. */
  108016. useOnlyInActiveCamera: boolean;
  108017. /** @hidden */
  108018. static _SceneComponentInitialization: (scene: Scene) => void;
  108019. /**
  108020. * Instantiates a depth renderer
  108021. * @param scene The scene the renderer belongs to
  108022. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  108023. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  108024. */
  108025. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  108026. /**
  108027. * Creates the depth rendering effect and checks if the effect is ready.
  108028. * @param subMesh The submesh to be used to render the depth map of
  108029. * @param useInstances If multiple world instances should be used
  108030. * @returns if the depth renderer is ready to render the depth map
  108031. */
  108032. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108033. /**
  108034. * Gets the texture which the depth map will be written to.
  108035. * @returns The depth map texture
  108036. */
  108037. getDepthMap(): RenderTargetTexture;
  108038. /**
  108039. * Disposes of the depth renderer.
  108040. */
  108041. dispose(): void;
  108042. }
  108043. }
  108044. declare module BABYLON {
  108045. interface Scene {
  108046. /** @hidden (Backing field) */
  108047. _depthRenderer: {
  108048. [id: string]: DepthRenderer;
  108049. };
  108050. /**
  108051. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  108052. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  108053. * @returns the created depth renderer
  108054. */
  108055. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  108056. /**
  108057. * Disables a depth renderer for a given camera
  108058. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  108059. */
  108060. disableDepthRenderer(camera?: Nullable<Camera>): void;
  108061. }
  108062. /**
  108063. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  108064. * in several rendering techniques.
  108065. */
  108066. export class DepthRendererSceneComponent implements ISceneComponent {
  108067. /**
  108068. * The component name helpfull to identify the component in the list of scene components.
  108069. */
  108070. readonly name: string;
  108071. /**
  108072. * The scene the component belongs to.
  108073. */
  108074. scene: Scene;
  108075. /**
  108076. * Creates a new instance of the component for the given scene
  108077. * @param scene Defines the scene to register the component in
  108078. */
  108079. constructor(scene: Scene);
  108080. /**
  108081. * Registers the component in a given scene
  108082. */
  108083. register(): void;
  108084. /**
  108085. * Rebuilds the elements related to this component in case of
  108086. * context lost for instance.
  108087. */
  108088. rebuild(): void;
  108089. /**
  108090. * Disposes the component and the associated ressources
  108091. */
  108092. dispose(): void;
  108093. private _gatherRenderTargets;
  108094. private _gatherActiveCameraRenderTargets;
  108095. }
  108096. }
  108097. declare module BABYLON {
  108098. interface Scene {
  108099. /** @hidden (Backing field) */
  108100. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108101. /**
  108102. * Gets or Sets the current geometry buffer associated to the scene.
  108103. */
  108104. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108105. /**
  108106. * Enables a GeometryBufferRender and associates it with the scene
  108107. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  108108. * @returns the GeometryBufferRenderer
  108109. */
  108110. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  108111. /**
  108112. * Disables the GeometryBufferRender associated with the scene
  108113. */
  108114. disableGeometryBufferRenderer(): void;
  108115. }
  108116. /**
  108117. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  108118. * in several rendering techniques.
  108119. */
  108120. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  108121. /**
  108122. * The component name helpful to identify the component in the list of scene components.
  108123. */
  108124. readonly name: string;
  108125. /**
  108126. * The scene the component belongs to.
  108127. */
  108128. scene: Scene;
  108129. /**
  108130. * Creates a new instance of the component for the given scene
  108131. * @param scene Defines the scene to register the component in
  108132. */
  108133. constructor(scene: Scene);
  108134. /**
  108135. * Registers the component in a given scene
  108136. */
  108137. register(): void;
  108138. /**
  108139. * Rebuilds the elements related to this component in case of
  108140. * context lost for instance.
  108141. */
  108142. rebuild(): void;
  108143. /**
  108144. * Disposes the component and the associated ressources
  108145. */
  108146. dispose(): void;
  108147. private _gatherRenderTargets;
  108148. }
  108149. }
  108150. declare module BABYLON {
  108151. /** @hidden */
  108152. export var outlinePixelShader: {
  108153. name: string;
  108154. shader: string;
  108155. };
  108156. }
  108157. declare module BABYLON {
  108158. /** @hidden */
  108159. export var outlineVertexShader: {
  108160. name: string;
  108161. shader: string;
  108162. };
  108163. }
  108164. declare module BABYLON {
  108165. interface Scene {
  108166. /** @hidden */
  108167. _outlineRenderer: OutlineRenderer;
  108168. /**
  108169. * Gets the outline renderer associated with the scene
  108170. * @returns a OutlineRenderer
  108171. */
  108172. getOutlineRenderer(): OutlineRenderer;
  108173. }
  108174. interface AbstractMesh {
  108175. /** @hidden (Backing field) */
  108176. _renderOutline: boolean;
  108177. /**
  108178. * Gets or sets a boolean indicating if the outline must be rendered as well
  108179. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  108180. */
  108181. renderOutline: boolean;
  108182. /** @hidden (Backing field) */
  108183. _renderOverlay: boolean;
  108184. /**
  108185. * Gets or sets a boolean indicating if the overlay must be rendered as well
  108186. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  108187. */
  108188. renderOverlay: boolean;
  108189. }
  108190. /**
  108191. * This class is responsible to draw bothe outline/overlay of meshes.
  108192. * It should not be used directly but through the available method on mesh.
  108193. */
  108194. export class OutlineRenderer implements ISceneComponent {
  108195. /**
  108196. * The name of the component. Each component must have a unique name.
  108197. */
  108198. name: string;
  108199. /**
  108200. * The scene the component belongs to.
  108201. */
  108202. scene: Scene;
  108203. /**
  108204. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  108205. */
  108206. zOffset: number;
  108207. private _engine;
  108208. private _effect;
  108209. private _cachedDefines;
  108210. private _savedDepthWrite;
  108211. /**
  108212. * Instantiates a new outline renderer. (There could be only one per scene).
  108213. * @param scene Defines the scene it belongs to
  108214. */
  108215. constructor(scene: Scene);
  108216. /**
  108217. * Register the component to one instance of a scene.
  108218. */
  108219. register(): void;
  108220. /**
  108221. * Rebuilds the elements related to this component in case of
  108222. * context lost for instance.
  108223. */
  108224. rebuild(): void;
  108225. /**
  108226. * Disposes the component and the associated ressources.
  108227. */
  108228. dispose(): void;
  108229. /**
  108230. * Renders the outline in the canvas.
  108231. * @param subMesh Defines the sumesh to render
  108232. * @param batch Defines the batch of meshes in case of instances
  108233. * @param useOverlay Defines if the rendering is for the overlay or the outline
  108234. */
  108235. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  108236. /**
  108237. * Returns whether or not the outline renderer is ready for a given submesh.
  108238. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  108239. * @param subMesh Defines the submesh to check readyness for
  108240. * @param useInstances Defines wheter wee are trying to render instances or not
  108241. * @returns true if ready otherwise false
  108242. */
  108243. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108244. private _beforeRenderingMesh;
  108245. private _afterRenderingMesh;
  108246. }
  108247. }
  108248. declare module BABYLON {
  108249. /**
  108250. * Defines the list of states available for a task inside a AssetsManager
  108251. */
  108252. export enum AssetTaskState {
  108253. /**
  108254. * Initialization
  108255. */
  108256. INIT = 0,
  108257. /**
  108258. * Running
  108259. */
  108260. RUNNING = 1,
  108261. /**
  108262. * Done
  108263. */
  108264. DONE = 2,
  108265. /**
  108266. * Error
  108267. */
  108268. ERROR = 3
  108269. }
  108270. /**
  108271. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  108272. */
  108273. export abstract class AbstractAssetTask {
  108274. /**
  108275. * Task name
  108276. */ name: string;
  108277. /**
  108278. * Callback called when the task is successful
  108279. */
  108280. onSuccess: (task: any) => void;
  108281. /**
  108282. * Callback called when the task is not successful
  108283. */
  108284. onError: (task: any, message?: string, exception?: any) => void;
  108285. /**
  108286. * Creates a new AssetsManager
  108287. * @param name defines the name of the task
  108288. */
  108289. constructor(
  108290. /**
  108291. * Task name
  108292. */ name: string);
  108293. private _isCompleted;
  108294. private _taskState;
  108295. private _errorObject;
  108296. /**
  108297. * Get if the task is completed
  108298. */
  108299. readonly isCompleted: boolean;
  108300. /**
  108301. * Gets the current state of the task
  108302. */
  108303. readonly taskState: AssetTaskState;
  108304. /**
  108305. * Gets the current error object (if task is in error)
  108306. */
  108307. readonly errorObject: {
  108308. message?: string;
  108309. exception?: any;
  108310. };
  108311. /**
  108312. * Internal only
  108313. * @hidden
  108314. */
  108315. _setErrorObject(message?: string, exception?: any): void;
  108316. /**
  108317. * Execute the current task
  108318. * @param scene defines the scene where you want your assets to be loaded
  108319. * @param onSuccess is a callback called when the task is successfully executed
  108320. * @param onError is a callback called if an error occurs
  108321. */
  108322. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108323. /**
  108324. * Execute the current task
  108325. * @param scene defines the scene where you want your assets to be loaded
  108326. * @param onSuccess is a callback called when the task is successfully executed
  108327. * @param onError is a callback called if an error occurs
  108328. */
  108329. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108330. /**
  108331. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  108332. * This can be used with failed tasks that have the reason for failure fixed.
  108333. */
  108334. reset(): void;
  108335. private onErrorCallback;
  108336. private onDoneCallback;
  108337. }
  108338. /**
  108339. * Define the interface used by progress events raised during assets loading
  108340. */
  108341. export interface IAssetsProgressEvent {
  108342. /**
  108343. * Defines the number of remaining tasks to process
  108344. */
  108345. remainingCount: number;
  108346. /**
  108347. * Defines the total number of tasks
  108348. */
  108349. totalCount: number;
  108350. /**
  108351. * Defines the task that was just processed
  108352. */
  108353. task: AbstractAssetTask;
  108354. }
  108355. /**
  108356. * Class used to share progress information about assets loading
  108357. */
  108358. export class AssetsProgressEvent implements IAssetsProgressEvent {
  108359. /**
  108360. * Defines the number of remaining tasks to process
  108361. */
  108362. remainingCount: number;
  108363. /**
  108364. * Defines the total number of tasks
  108365. */
  108366. totalCount: number;
  108367. /**
  108368. * Defines the task that was just processed
  108369. */
  108370. task: AbstractAssetTask;
  108371. /**
  108372. * Creates a AssetsProgressEvent
  108373. * @param remainingCount defines the number of remaining tasks to process
  108374. * @param totalCount defines the total number of tasks
  108375. * @param task defines the task that was just processed
  108376. */
  108377. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  108378. }
  108379. /**
  108380. * Define a task used by AssetsManager to load meshes
  108381. */
  108382. export class MeshAssetTask extends AbstractAssetTask {
  108383. /**
  108384. * Defines the name of the task
  108385. */
  108386. name: string;
  108387. /**
  108388. * Defines the list of mesh's names you want to load
  108389. */
  108390. meshesNames: any;
  108391. /**
  108392. * Defines the root url to use as a base to load your meshes and associated resources
  108393. */
  108394. rootUrl: string;
  108395. /**
  108396. * Defines the filename of the scene to load from
  108397. */
  108398. sceneFilename: string;
  108399. /**
  108400. * Gets the list of loaded meshes
  108401. */
  108402. loadedMeshes: Array<AbstractMesh>;
  108403. /**
  108404. * Gets the list of loaded particle systems
  108405. */
  108406. loadedParticleSystems: Array<IParticleSystem>;
  108407. /**
  108408. * Gets the list of loaded skeletons
  108409. */
  108410. loadedSkeletons: Array<Skeleton>;
  108411. /**
  108412. * Gets the list of loaded animation groups
  108413. */
  108414. loadedAnimationGroups: Array<AnimationGroup>;
  108415. /**
  108416. * Callback called when the task is successful
  108417. */
  108418. onSuccess: (task: MeshAssetTask) => void;
  108419. /**
  108420. * Callback called when the task is successful
  108421. */
  108422. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  108423. /**
  108424. * Creates a new MeshAssetTask
  108425. * @param name defines the name of the task
  108426. * @param meshesNames defines the list of mesh's names you want to load
  108427. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  108428. * @param sceneFilename defines the filename of the scene to load from
  108429. */
  108430. constructor(
  108431. /**
  108432. * Defines the name of the task
  108433. */
  108434. name: string,
  108435. /**
  108436. * Defines the list of mesh's names you want to load
  108437. */
  108438. meshesNames: any,
  108439. /**
  108440. * Defines the root url to use as a base to load your meshes and associated resources
  108441. */
  108442. rootUrl: string,
  108443. /**
  108444. * Defines the filename of the scene to load from
  108445. */
  108446. sceneFilename: string);
  108447. /**
  108448. * Execute the current task
  108449. * @param scene defines the scene where you want your assets to be loaded
  108450. * @param onSuccess is a callback called when the task is successfully executed
  108451. * @param onError is a callback called if an error occurs
  108452. */
  108453. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108454. }
  108455. /**
  108456. * Define a task used by AssetsManager to load text content
  108457. */
  108458. export class TextFileAssetTask extends AbstractAssetTask {
  108459. /**
  108460. * Defines the name of the task
  108461. */
  108462. name: string;
  108463. /**
  108464. * Defines the location of the file to load
  108465. */
  108466. url: string;
  108467. /**
  108468. * Gets the loaded text string
  108469. */
  108470. text: string;
  108471. /**
  108472. * Callback called when the task is successful
  108473. */
  108474. onSuccess: (task: TextFileAssetTask) => void;
  108475. /**
  108476. * Callback called when the task is successful
  108477. */
  108478. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  108479. /**
  108480. * Creates a new TextFileAssetTask object
  108481. * @param name defines the name of the task
  108482. * @param url defines the location of the file to load
  108483. */
  108484. constructor(
  108485. /**
  108486. * Defines the name of the task
  108487. */
  108488. name: string,
  108489. /**
  108490. * Defines the location of the file to load
  108491. */
  108492. url: string);
  108493. /**
  108494. * Execute the current task
  108495. * @param scene defines the scene where you want your assets to be loaded
  108496. * @param onSuccess is a callback called when the task is successfully executed
  108497. * @param onError is a callback called if an error occurs
  108498. */
  108499. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108500. }
  108501. /**
  108502. * Define a task used by AssetsManager to load binary data
  108503. */
  108504. export class BinaryFileAssetTask extends AbstractAssetTask {
  108505. /**
  108506. * Defines the name of the task
  108507. */
  108508. name: string;
  108509. /**
  108510. * Defines the location of the file to load
  108511. */
  108512. url: string;
  108513. /**
  108514. * Gets the lodaded data (as an array buffer)
  108515. */
  108516. data: ArrayBuffer;
  108517. /**
  108518. * Callback called when the task is successful
  108519. */
  108520. onSuccess: (task: BinaryFileAssetTask) => void;
  108521. /**
  108522. * Callback called when the task is successful
  108523. */
  108524. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  108525. /**
  108526. * Creates a new BinaryFileAssetTask object
  108527. * @param name defines the name of the new task
  108528. * @param url defines the location of the file to load
  108529. */
  108530. constructor(
  108531. /**
  108532. * Defines the name of the task
  108533. */
  108534. name: string,
  108535. /**
  108536. * Defines the location of the file to load
  108537. */
  108538. url: string);
  108539. /**
  108540. * Execute the current task
  108541. * @param scene defines the scene where you want your assets to be loaded
  108542. * @param onSuccess is a callback called when the task is successfully executed
  108543. * @param onError is a callback called if an error occurs
  108544. */
  108545. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108546. }
  108547. /**
  108548. * Define a task used by AssetsManager to load images
  108549. */
  108550. export class ImageAssetTask extends AbstractAssetTask {
  108551. /**
  108552. * Defines the name of the task
  108553. */
  108554. name: string;
  108555. /**
  108556. * Defines the location of the image to load
  108557. */
  108558. url: string;
  108559. /**
  108560. * Gets the loaded images
  108561. */
  108562. image: HTMLImageElement;
  108563. /**
  108564. * Callback called when the task is successful
  108565. */
  108566. onSuccess: (task: ImageAssetTask) => void;
  108567. /**
  108568. * Callback called when the task is successful
  108569. */
  108570. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  108571. /**
  108572. * Creates a new ImageAssetTask
  108573. * @param name defines the name of the task
  108574. * @param url defines the location of the image to load
  108575. */
  108576. constructor(
  108577. /**
  108578. * Defines the name of the task
  108579. */
  108580. name: string,
  108581. /**
  108582. * Defines the location of the image to load
  108583. */
  108584. url: string);
  108585. /**
  108586. * Execute the current task
  108587. * @param scene defines the scene where you want your assets to be loaded
  108588. * @param onSuccess is a callback called when the task is successfully executed
  108589. * @param onError is a callback called if an error occurs
  108590. */
  108591. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108592. }
  108593. /**
  108594. * Defines the interface used by texture loading tasks
  108595. */
  108596. export interface ITextureAssetTask<TEX extends BaseTexture> {
  108597. /**
  108598. * Gets the loaded texture
  108599. */
  108600. texture: TEX;
  108601. }
  108602. /**
  108603. * Define a task used by AssetsManager to load 2D textures
  108604. */
  108605. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  108606. /**
  108607. * Defines the name of the task
  108608. */
  108609. name: string;
  108610. /**
  108611. * Defines the location of the file to load
  108612. */
  108613. url: string;
  108614. /**
  108615. * Defines if mipmap should not be generated (default is false)
  108616. */
  108617. noMipmap?: boolean | undefined;
  108618. /**
  108619. * Defines if texture must be inverted on Y axis (default is false)
  108620. */
  108621. invertY?: boolean | undefined;
  108622. /**
  108623. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  108624. */
  108625. samplingMode: number;
  108626. /**
  108627. * Gets the loaded texture
  108628. */
  108629. texture: Texture;
  108630. /**
  108631. * Callback called when the task is successful
  108632. */
  108633. onSuccess: (task: TextureAssetTask) => void;
  108634. /**
  108635. * Callback called when the task is successful
  108636. */
  108637. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  108638. /**
  108639. * Creates a new TextureAssetTask object
  108640. * @param name defines the name of the task
  108641. * @param url defines the location of the file to load
  108642. * @param noMipmap defines if mipmap should not be generated (default is false)
  108643. * @param invertY defines if texture must be inverted on Y axis (default is false)
  108644. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  108645. */
  108646. constructor(
  108647. /**
  108648. * Defines the name of the task
  108649. */
  108650. name: string,
  108651. /**
  108652. * Defines the location of the file to load
  108653. */
  108654. url: string,
  108655. /**
  108656. * Defines if mipmap should not be generated (default is false)
  108657. */
  108658. noMipmap?: boolean | undefined,
  108659. /**
  108660. * Defines if texture must be inverted on Y axis (default is false)
  108661. */
  108662. invertY?: boolean | undefined,
  108663. /**
  108664. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  108665. */
  108666. samplingMode?: number);
  108667. /**
  108668. * Execute the current task
  108669. * @param scene defines the scene where you want your assets to be loaded
  108670. * @param onSuccess is a callback called when the task is successfully executed
  108671. * @param onError is a callback called if an error occurs
  108672. */
  108673. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108674. }
  108675. /**
  108676. * Define a task used by AssetsManager to load cube textures
  108677. */
  108678. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  108679. /**
  108680. * Defines the name of the task
  108681. */
  108682. name: string;
  108683. /**
  108684. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  108685. */
  108686. url: string;
  108687. /**
  108688. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  108689. */
  108690. extensions?: string[] | undefined;
  108691. /**
  108692. * Defines if mipmaps should not be generated (default is false)
  108693. */
  108694. noMipmap?: boolean | undefined;
  108695. /**
  108696. * Defines the explicit list of files (undefined by default)
  108697. */
  108698. files?: string[] | undefined;
  108699. /**
  108700. * Gets the loaded texture
  108701. */
  108702. texture: CubeTexture;
  108703. /**
  108704. * Callback called when the task is successful
  108705. */
  108706. onSuccess: (task: CubeTextureAssetTask) => void;
  108707. /**
  108708. * Callback called when the task is successful
  108709. */
  108710. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  108711. /**
  108712. * Creates a new CubeTextureAssetTask
  108713. * @param name defines the name of the task
  108714. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  108715. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  108716. * @param noMipmap defines if mipmaps should not be generated (default is false)
  108717. * @param files defines the explicit list of files (undefined by default)
  108718. */
  108719. constructor(
  108720. /**
  108721. * Defines the name of the task
  108722. */
  108723. name: string,
  108724. /**
  108725. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  108726. */
  108727. url: string,
  108728. /**
  108729. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  108730. */
  108731. extensions?: string[] | undefined,
  108732. /**
  108733. * Defines if mipmaps should not be generated (default is false)
  108734. */
  108735. noMipmap?: boolean | undefined,
  108736. /**
  108737. * Defines the explicit list of files (undefined by default)
  108738. */
  108739. files?: string[] | undefined);
  108740. /**
  108741. * Execute the current task
  108742. * @param scene defines the scene where you want your assets to be loaded
  108743. * @param onSuccess is a callback called when the task is successfully executed
  108744. * @param onError is a callback called if an error occurs
  108745. */
  108746. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108747. }
  108748. /**
  108749. * Define a task used by AssetsManager to load HDR cube textures
  108750. */
  108751. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  108752. /**
  108753. * Defines the name of the task
  108754. */
  108755. name: string;
  108756. /**
  108757. * Defines the location of the file to load
  108758. */
  108759. url: string;
  108760. /**
  108761. * Defines the desired size (the more it increases the longer the generation will be)
  108762. */
  108763. size: number;
  108764. /**
  108765. * Defines if mipmaps should not be generated (default is false)
  108766. */
  108767. noMipmap: boolean;
  108768. /**
  108769. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  108770. */
  108771. generateHarmonics: boolean;
  108772. /**
  108773. * 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)
  108774. */
  108775. gammaSpace: boolean;
  108776. /**
  108777. * Internal Use Only
  108778. */
  108779. reserved: boolean;
  108780. /**
  108781. * Gets the loaded texture
  108782. */
  108783. texture: HDRCubeTexture;
  108784. /**
  108785. * Callback called when the task is successful
  108786. */
  108787. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  108788. /**
  108789. * Callback called when the task is successful
  108790. */
  108791. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  108792. /**
  108793. * Creates a new HDRCubeTextureAssetTask object
  108794. * @param name defines the name of the task
  108795. * @param url defines the location of the file to load
  108796. * @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.
  108797. * @param noMipmap defines if mipmaps should not be generated (default is false)
  108798. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  108799. * @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)
  108800. * @param reserved Internal use only
  108801. */
  108802. constructor(
  108803. /**
  108804. * Defines the name of the task
  108805. */
  108806. name: string,
  108807. /**
  108808. * Defines the location of the file to load
  108809. */
  108810. url: string,
  108811. /**
  108812. * Defines the desired size (the more it increases the longer the generation will be)
  108813. */
  108814. size: number,
  108815. /**
  108816. * Defines if mipmaps should not be generated (default is false)
  108817. */
  108818. noMipmap?: boolean,
  108819. /**
  108820. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  108821. */
  108822. generateHarmonics?: boolean,
  108823. /**
  108824. * 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)
  108825. */
  108826. gammaSpace?: boolean,
  108827. /**
  108828. * Internal Use Only
  108829. */
  108830. reserved?: boolean);
  108831. /**
  108832. * Execute the current task
  108833. * @param scene defines the scene where you want your assets to be loaded
  108834. * @param onSuccess is a callback called when the task is successfully executed
  108835. * @param onError is a callback called if an error occurs
  108836. */
  108837. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108838. }
  108839. /**
  108840. * This class can be used to easily import assets into a scene
  108841. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  108842. */
  108843. export class AssetsManager {
  108844. private _scene;
  108845. private _isLoading;
  108846. protected _tasks: AbstractAssetTask[];
  108847. protected _waitingTasksCount: number;
  108848. protected _totalTasksCount: number;
  108849. /**
  108850. * Callback called when all tasks are processed
  108851. */
  108852. onFinish: (tasks: AbstractAssetTask[]) => void;
  108853. /**
  108854. * Callback called when a task is successful
  108855. */
  108856. onTaskSuccess: (task: AbstractAssetTask) => void;
  108857. /**
  108858. * Callback called when a task had an error
  108859. */
  108860. onTaskError: (task: AbstractAssetTask) => void;
  108861. /**
  108862. * Callback called when a task is done (whatever the result is)
  108863. */
  108864. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  108865. /**
  108866. * Observable called when all tasks are processed
  108867. */
  108868. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  108869. /**
  108870. * Observable called when a task had an error
  108871. */
  108872. onTaskErrorObservable: Observable<AbstractAssetTask>;
  108873. /**
  108874. * Observable called when a task is successful
  108875. */
  108876. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  108877. /**
  108878. * Observable called when a task is done (whatever the result is)
  108879. */
  108880. onProgressObservable: Observable<IAssetsProgressEvent>;
  108881. /**
  108882. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  108883. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108884. */
  108885. useDefaultLoadingScreen: boolean;
  108886. /**
  108887. * Creates a new AssetsManager
  108888. * @param scene defines the scene to work on
  108889. */
  108890. constructor(scene: Scene);
  108891. /**
  108892. * Add a MeshAssetTask to the list of active tasks
  108893. * @param taskName defines the name of the new task
  108894. * @param meshesNames defines the name of meshes to load
  108895. * @param rootUrl defines the root url to use to locate files
  108896. * @param sceneFilename defines the filename of the scene file
  108897. * @returns a new MeshAssetTask object
  108898. */
  108899. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  108900. /**
  108901. * Add a TextFileAssetTask to the list of active tasks
  108902. * @param taskName defines the name of the new task
  108903. * @param url defines the url of the file to load
  108904. * @returns a new TextFileAssetTask object
  108905. */
  108906. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  108907. /**
  108908. * Add a BinaryFileAssetTask to the list of active tasks
  108909. * @param taskName defines the name of the new task
  108910. * @param url defines the url of the file to load
  108911. * @returns a new BinaryFileAssetTask object
  108912. */
  108913. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  108914. /**
  108915. * Add a ImageAssetTask to the list of active tasks
  108916. * @param taskName defines the name of the new task
  108917. * @param url defines the url of the file to load
  108918. * @returns a new ImageAssetTask object
  108919. */
  108920. addImageTask(taskName: string, url: string): ImageAssetTask;
  108921. /**
  108922. * Add a TextureAssetTask to the list of active tasks
  108923. * @param taskName defines the name of the new task
  108924. * @param url defines the url of the file to load
  108925. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  108926. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  108927. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  108928. * @returns a new TextureAssetTask object
  108929. */
  108930. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  108931. /**
  108932. * Add a CubeTextureAssetTask to the list of active tasks
  108933. * @param taskName defines the name of the new task
  108934. * @param url defines the url of the file to load
  108935. * @param extensions defines the extension to use to load the cube map (can be null)
  108936. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  108937. * @param files defines the list of files to load (can be null)
  108938. * @returns a new CubeTextureAssetTask object
  108939. */
  108940. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  108941. /**
  108942. *
  108943. * Add a HDRCubeTextureAssetTask to the list of active tasks
  108944. * @param taskName defines the name of the new task
  108945. * @param url defines the url of the file to load
  108946. * @param size defines the size you want for the cubemap (can be null)
  108947. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  108948. * @param generateHarmonics defines if you want to automatically generate (true by default)
  108949. * @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)
  108950. * @param reserved Internal use only
  108951. * @returns a new HDRCubeTextureAssetTask object
  108952. */
  108953. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  108954. /**
  108955. * Remove a task from the assets manager.
  108956. * @param task the task to remove
  108957. */
  108958. removeTask(task: AbstractAssetTask): void;
  108959. private _decreaseWaitingTasksCount;
  108960. private _runTask;
  108961. /**
  108962. * Reset the AssetsManager and remove all tasks
  108963. * @return the current instance of the AssetsManager
  108964. */
  108965. reset(): AssetsManager;
  108966. /**
  108967. * Start the loading process
  108968. * @return the current instance of the AssetsManager
  108969. */
  108970. load(): AssetsManager;
  108971. }
  108972. }
  108973. declare module BABYLON {
  108974. /**
  108975. * Wrapper class for promise with external resolve and reject.
  108976. */
  108977. export class Deferred<T> {
  108978. /**
  108979. * The promise associated with this deferred object.
  108980. */
  108981. readonly promise: Promise<T>;
  108982. private _resolve;
  108983. private _reject;
  108984. /**
  108985. * The resolve method of the promise associated with this deferred object.
  108986. */
  108987. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  108988. /**
  108989. * The reject method of the promise associated with this deferred object.
  108990. */
  108991. readonly reject: (reason?: any) => void;
  108992. /**
  108993. * Constructor for this deferred object.
  108994. */
  108995. constructor();
  108996. }
  108997. }
  108998. declare module BABYLON {
  108999. /**
  109000. * Class used to help managing file picking and drag'n'drop
  109001. */
  109002. export class FilesInput {
  109003. /**
  109004. * List of files ready to be loaded
  109005. */
  109006. static readonly FilesToLoad: {
  109007. [key: string]: File;
  109008. };
  109009. /**
  109010. * Callback called when a file is processed
  109011. */
  109012. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  109013. private _engine;
  109014. private _currentScene;
  109015. private _sceneLoadedCallback;
  109016. private _progressCallback;
  109017. private _additionalRenderLoopLogicCallback;
  109018. private _textureLoadingCallback;
  109019. private _startingProcessingFilesCallback;
  109020. private _onReloadCallback;
  109021. private _errorCallback;
  109022. private _elementToMonitor;
  109023. private _sceneFileToLoad;
  109024. private _filesToLoad;
  109025. /**
  109026. * Creates a new FilesInput
  109027. * @param engine defines the rendering engine
  109028. * @param scene defines the hosting scene
  109029. * @param sceneLoadedCallback callback called when scene is loaded
  109030. * @param progressCallback callback called to track progress
  109031. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  109032. * @param textureLoadingCallback callback called when a texture is loading
  109033. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  109034. * @param onReloadCallback callback called when a reload is requested
  109035. * @param errorCallback callback call if an error occurs
  109036. */
  109037. 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);
  109038. private _dragEnterHandler;
  109039. private _dragOverHandler;
  109040. private _dropHandler;
  109041. /**
  109042. * Calls this function to listen to drag'n'drop events on a specific DOM element
  109043. * @param elementToMonitor defines the DOM element to track
  109044. */
  109045. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  109046. /**
  109047. * Release all associated resources
  109048. */
  109049. dispose(): void;
  109050. private renderFunction;
  109051. private drag;
  109052. private drop;
  109053. private _traverseFolder;
  109054. private _processFiles;
  109055. /**
  109056. * Load files from a drop event
  109057. * @param event defines the drop event to use as source
  109058. */
  109059. loadFiles(event: any): void;
  109060. private _processReload;
  109061. /**
  109062. * Reload the current scene from the loaded files
  109063. */
  109064. reload(): void;
  109065. }
  109066. }
  109067. declare module BABYLON {
  109068. /**
  109069. * Defines the root class used to create scene optimization to use with SceneOptimizer
  109070. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109071. */
  109072. export class SceneOptimization {
  109073. /**
  109074. * Defines the priority of this optimization (0 by default which means first in the list)
  109075. */
  109076. priority: number;
  109077. /**
  109078. * Gets a string describing the action executed by the current optimization
  109079. * @returns description string
  109080. */
  109081. getDescription(): string;
  109082. /**
  109083. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109084. * @param scene defines the current scene where to apply this optimization
  109085. * @param optimizer defines the current optimizer
  109086. * @returns true if everything that can be done was applied
  109087. */
  109088. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109089. /**
  109090. * Creates the SceneOptimization object
  109091. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109092. * @param desc defines the description associated with the optimization
  109093. */
  109094. constructor(
  109095. /**
  109096. * Defines the priority of this optimization (0 by default which means first in the list)
  109097. */
  109098. priority?: number);
  109099. }
  109100. /**
  109101. * Defines an optimization used to reduce the size of render target textures
  109102. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109103. */
  109104. export class TextureOptimization extends SceneOptimization {
  109105. /**
  109106. * Defines the priority of this optimization (0 by default which means first in the list)
  109107. */
  109108. priority: number;
  109109. /**
  109110. * 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
  109111. */
  109112. maximumSize: number;
  109113. /**
  109114. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  109115. */
  109116. step: number;
  109117. /**
  109118. * Gets a string describing the action executed by the current optimization
  109119. * @returns description string
  109120. */
  109121. getDescription(): string;
  109122. /**
  109123. * Creates the TextureOptimization object
  109124. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109125. * @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
  109126. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  109127. */
  109128. constructor(
  109129. /**
  109130. * Defines the priority of this optimization (0 by default which means first in the list)
  109131. */
  109132. priority?: number,
  109133. /**
  109134. * 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
  109135. */
  109136. maximumSize?: number,
  109137. /**
  109138. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  109139. */
  109140. step?: number);
  109141. /**
  109142. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109143. * @param scene defines the current scene where to apply this optimization
  109144. * @param optimizer defines the current optimizer
  109145. * @returns true if everything that can be done was applied
  109146. */
  109147. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109148. }
  109149. /**
  109150. * Defines an optimization used to increase or decrease the rendering resolution
  109151. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109152. */
  109153. export class HardwareScalingOptimization extends SceneOptimization {
  109154. /**
  109155. * Defines the priority of this optimization (0 by default which means first in the list)
  109156. */
  109157. priority: number;
  109158. /**
  109159. * Defines the maximum scale to use (2 by default)
  109160. */
  109161. maximumScale: number;
  109162. /**
  109163. * Defines the step to use between two passes (0.5 by default)
  109164. */
  109165. step: number;
  109166. private _currentScale;
  109167. private _directionOffset;
  109168. /**
  109169. * Gets a string describing the action executed by the current optimization
  109170. * @return description string
  109171. */
  109172. getDescription(): string;
  109173. /**
  109174. * Creates the HardwareScalingOptimization object
  109175. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109176. * @param maximumScale defines the maximum scale to use (2 by default)
  109177. * @param step defines the step to use between two passes (0.5 by default)
  109178. */
  109179. constructor(
  109180. /**
  109181. * Defines the priority of this optimization (0 by default which means first in the list)
  109182. */
  109183. priority?: number,
  109184. /**
  109185. * Defines the maximum scale to use (2 by default)
  109186. */
  109187. maximumScale?: number,
  109188. /**
  109189. * Defines the step to use between two passes (0.5 by default)
  109190. */
  109191. step?: number);
  109192. /**
  109193. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109194. * @param scene defines the current scene where to apply this optimization
  109195. * @param optimizer defines the current optimizer
  109196. * @returns true if everything that can be done was applied
  109197. */
  109198. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109199. }
  109200. /**
  109201. * Defines an optimization used to remove shadows
  109202. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109203. */
  109204. export class ShadowsOptimization extends SceneOptimization {
  109205. /**
  109206. * Gets a string describing the action executed by the current optimization
  109207. * @return description string
  109208. */
  109209. getDescription(): string;
  109210. /**
  109211. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109212. * @param scene defines the current scene where to apply this optimization
  109213. * @param optimizer defines the current optimizer
  109214. * @returns true if everything that can be done was applied
  109215. */
  109216. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109217. }
  109218. /**
  109219. * Defines an optimization used to turn post-processes off
  109220. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109221. */
  109222. export class PostProcessesOptimization extends SceneOptimization {
  109223. /**
  109224. * Gets a string describing the action executed by the current optimization
  109225. * @return description string
  109226. */
  109227. getDescription(): string;
  109228. /**
  109229. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109230. * @param scene defines the current scene where to apply this optimization
  109231. * @param optimizer defines the current optimizer
  109232. * @returns true if everything that can be done was applied
  109233. */
  109234. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109235. }
  109236. /**
  109237. * Defines an optimization used to turn lens flares off
  109238. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109239. */
  109240. export class LensFlaresOptimization extends SceneOptimization {
  109241. /**
  109242. * Gets a string describing the action executed by the current optimization
  109243. * @return description string
  109244. */
  109245. getDescription(): string;
  109246. /**
  109247. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109248. * @param scene defines the current scene where to apply this optimization
  109249. * @param optimizer defines the current optimizer
  109250. * @returns true if everything that can be done was applied
  109251. */
  109252. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109253. }
  109254. /**
  109255. * Defines an optimization based on user defined callback.
  109256. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109257. */
  109258. export class CustomOptimization extends SceneOptimization {
  109259. /**
  109260. * Callback called to apply the custom optimization.
  109261. */
  109262. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  109263. /**
  109264. * Callback called to get custom description
  109265. */
  109266. onGetDescription: () => string;
  109267. /**
  109268. * Gets a string describing the action executed by the current optimization
  109269. * @returns description string
  109270. */
  109271. getDescription(): string;
  109272. /**
  109273. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109274. * @param scene defines the current scene where to apply this optimization
  109275. * @param optimizer defines the current optimizer
  109276. * @returns true if everything that can be done was applied
  109277. */
  109278. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109279. }
  109280. /**
  109281. * Defines an optimization used to turn particles off
  109282. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109283. */
  109284. export class ParticlesOptimization extends SceneOptimization {
  109285. /**
  109286. * Gets a string describing the action executed by the current optimization
  109287. * @return description string
  109288. */
  109289. getDescription(): string;
  109290. /**
  109291. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109292. * @param scene defines the current scene where to apply this optimization
  109293. * @param optimizer defines the current optimizer
  109294. * @returns true if everything that can be done was applied
  109295. */
  109296. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109297. }
  109298. /**
  109299. * Defines an optimization used to turn render targets off
  109300. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109301. */
  109302. export class RenderTargetsOptimization extends SceneOptimization {
  109303. /**
  109304. * Gets a string describing the action executed by the current optimization
  109305. * @return description string
  109306. */
  109307. getDescription(): string;
  109308. /**
  109309. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109310. * @param scene defines the current scene where to apply this optimization
  109311. * @param optimizer defines the current optimizer
  109312. * @returns true if everything that can be done was applied
  109313. */
  109314. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109315. }
  109316. /**
  109317. * Defines an optimization used to merge meshes with compatible materials
  109318. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109319. */
  109320. export class MergeMeshesOptimization extends SceneOptimization {
  109321. private static _UpdateSelectionTree;
  109322. /**
  109323. * Gets or sets a boolean which defines if optimization octree has to be updated
  109324. */
  109325. /**
  109326. * Gets or sets a boolean which defines if optimization octree has to be updated
  109327. */
  109328. static UpdateSelectionTree: boolean;
  109329. /**
  109330. * Gets a string describing the action executed by the current optimization
  109331. * @return description string
  109332. */
  109333. getDescription(): string;
  109334. private _canBeMerged;
  109335. /**
  109336. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109337. * @param scene defines the current scene where to apply this optimization
  109338. * @param optimizer defines the current optimizer
  109339. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  109340. * @returns true if everything that can be done was applied
  109341. */
  109342. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  109343. }
  109344. /**
  109345. * Defines a list of options used by SceneOptimizer
  109346. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109347. */
  109348. export class SceneOptimizerOptions {
  109349. /**
  109350. * Defines the target frame rate to reach (60 by default)
  109351. */
  109352. targetFrameRate: number;
  109353. /**
  109354. * Defines the interval between two checkes (2000ms by default)
  109355. */
  109356. trackerDuration: number;
  109357. /**
  109358. * Gets the list of optimizations to apply
  109359. */
  109360. optimizations: SceneOptimization[];
  109361. /**
  109362. * Creates a new list of options used by SceneOptimizer
  109363. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  109364. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  109365. */
  109366. constructor(
  109367. /**
  109368. * Defines the target frame rate to reach (60 by default)
  109369. */
  109370. targetFrameRate?: number,
  109371. /**
  109372. * Defines the interval between two checkes (2000ms by default)
  109373. */
  109374. trackerDuration?: number);
  109375. /**
  109376. * Add a new optimization
  109377. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  109378. * @returns the current SceneOptimizerOptions
  109379. */
  109380. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  109381. /**
  109382. * Add a new custom optimization
  109383. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  109384. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  109385. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109386. * @returns the current SceneOptimizerOptions
  109387. */
  109388. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  109389. /**
  109390. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  109391. * @param targetFrameRate defines the target frame rate (60 by default)
  109392. * @returns a SceneOptimizerOptions object
  109393. */
  109394. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  109395. /**
  109396. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  109397. * @param targetFrameRate defines the target frame rate (60 by default)
  109398. * @returns a SceneOptimizerOptions object
  109399. */
  109400. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  109401. /**
  109402. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  109403. * @param targetFrameRate defines the target frame rate (60 by default)
  109404. * @returns a SceneOptimizerOptions object
  109405. */
  109406. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  109407. }
  109408. /**
  109409. * Class used to run optimizations in order to reach a target frame rate
  109410. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109411. */
  109412. export class SceneOptimizer implements IDisposable {
  109413. private _isRunning;
  109414. private _options;
  109415. private _scene;
  109416. private _currentPriorityLevel;
  109417. private _targetFrameRate;
  109418. private _trackerDuration;
  109419. private _currentFrameRate;
  109420. private _sceneDisposeObserver;
  109421. private _improvementMode;
  109422. /**
  109423. * Defines an observable called when the optimizer reaches the target frame rate
  109424. */
  109425. onSuccessObservable: Observable<SceneOptimizer>;
  109426. /**
  109427. * Defines an observable called when the optimizer enables an optimization
  109428. */
  109429. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  109430. /**
  109431. * Defines an observable called when the optimizer is not able to reach the target frame rate
  109432. */
  109433. onFailureObservable: Observable<SceneOptimizer>;
  109434. /**
  109435. * Gets a boolean indicating if the optimizer is in improvement mode
  109436. */
  109437. readonly isInImprovementMode: boolean;
  109438. /**
  109439. * Gets the current priority level (0 at start)
  109440. */
  109441. readonly currentPriorityLevel: number;
  109442. /**
  109443. * Gets the current frame rate checked by the SceneOptimizer
  109444. */
  109445. readonly currentFrameRate: number;
  109446. /**
  109447. * Gets or sets the current target frame rate (60 by default)
  109448. */
  109449. /**
  109450. * Gets or sets the current target frame rate (60 by default)
  109451. */
  109452. targetFrameRate: number;
  109453. /**
  109454. * Gets or sets the current interval between two checks (every 2000ms by default)
  109455. */
  109456. /**
  109457. * Gets or sets the current interval between two checks (every 2000ms by default)
  109458. */
  109459. trackerDuration: number;
  109460. /**
  109461. * Gets the list of active optimizations
  109462. */
  109463. readonly optimizations: SceneOptimization[];
  109464. /**
  109465. * Creates a new SceneOptimizer
  109466. * @param scene defines the scene to work on
  109467. * @param options defines the options to use with the SceneOptimizer
  109468. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  109469. * @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)
  109470. */
  109471. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  109472. /**
  109473. * Stops the current optimizer
  109474. */
  109475. stop(): void;
  109476. /**
  109477. * Reset the optimizer to initial step (current priority level = 0)
  109478. */
  109479. reset(): void;
  109480. /**
  109481. * Start the optimizer. By default it will try to reach a specific framerate
  109482. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  109483. */
  109484. start(): void;
  109485. private _checkCurrentState;
  109486. /**
  109487. * Release all resources
  109488. */
  109489. dispose(): void;
  109490. /**
  109491. * Helper function to create a SceneOptimizer with one single line of code
  109492. * @param scene defines the scene to work on
  109493. * @param options defines the options to use with the SceneOptimizer
  109494. * @param onSuccess defines a callback to call on success
  109495. * @param onFailure defines a callback to call on failure
  109496. * @returns the new SceneOptimizer object
  109497. */
  109498. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  109499. }
  109500. }
  109501. declare module BABYLON {
  109502. /**
  109503. * Class used to serialize a scene into a string
  109504. */
  109505. export class SceneSerializer {
  109506. /**
  109507. * Clear cache used by a previous serialization
  109508. */
  109509. static ClearCache(): void;
  109510. /**
  109511. * Serialize a scene into a JSON compatible object
  109512. * @param scene defines the scene to serialize
  109513. * @returns a JSON compatible object
  109514. */
  109515. static Serialize(scene: Scene): any;
  109516. /**
  109517. * Serialize a mesh into a JSON compatible object
  109518. * @param toSerialize defines the mesh to serialize
  109519. * @param withParents defines if parents must be serialized as well
  109520. * @param withChildren defines if children must be serialized as well
  109521. * @returns a JSON compatible object
  109522. */
  109523. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  109524. }
  109525. }
  109526. declare module BABYLON {
  109527. /**
  109528. * This represents the different options avilable for the video capture.
  109529. */
  109530. export interface VideoRecorderOptions {
  109531. /** Defines the mime type of the video */
  109532. mimeType: string;
  109533. /** Defines the video the video should be recorded at */
  109534. fps: number;
  109535. /** Defines the chunk size for the recording data */
  109536. recordChunckSize: number;
  109537. }
  109538. /**
  109539. * This can helps recording videos from BabylonJS.
  109540. * This is based on the available WebRTC functionalities of the browser.
  109541. *
  109542. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  109543. */
  109544. export class VideoRecorder {
  109545. private static readonly _defaultOptions;
  109546. /**
  109547. * Returns wehther or not the VideoRecorder is available in your browser.
  109548. * @param engine Defines the Babylon Engine to check the support for
  109549. * @returns true if supported otherwise false
  109550. */
  109551. static IsSupported(engine: Engine): boolean;
  109552. private readonly _options;
  109553. private _canvas;
  109554. private _mediaRecorder;
  109555. private _recordedChunks;
  109556. private _fileName;
  109557. private _resolve;
  109558. private _reject;
  109559. /**
  109560. * True wether a recording is already in progress.
  109561. */
  109562. readonly isRecording: boolean;
  109563. /**
  109564. * Create a new VideoCapture object which can help converting what you see in Babylon to
  109565. * a video file.
  109566. * @param engine Defines the BabylonJS Engine you wish to record
  109567. * @param options Defines options that can be used to customized the capture
  109568. */
  109569. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  109570. /**
  109571. * Stops the current recording before the default capture timeout passed in the startRecording
  109572. * functions.
  109573. */
  109574. stopRecording(): void;
  109575. /**
  109576. * Starts recording the canvas for a max duration specified in parameters.
  109577. * @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.
  109578. * @param maxDuration Defines the maximum recording time in seconds.
  109579. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  109580. * @return a promise callback at the end of the recording with the video data in Blob.
  109581. */
  109582. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  109583. /**
  109584. * Releases internal resources used during the recording.
  109585. */
  109586. dispose(): void;
  109587. private _handleDataAvailable;
  109588. private _handleError;
  109589. private _handleStop;
  109590. }
  109591. }
  109592. declare module BABYLON {
  109593. /**
  109594. * Helper class to push actions to a pool of workers.
  109595. */
  109596. export class WorkerPool implements IDisposable {
  109597. private _workerInfos;
  109598. private _pendingActions;
  109599. /**
  109600. * Constructor
  109601. * @param workers Array of workers to use for actions
  109602. */
  109603. constructor(workers: Array<Worker>);
  109604. /**
  109605. * Terminates all workers and clears any pending actions.
  109606. */
  109607. dispose(): void;
  109608. /**
  109609. * Pushes an action to the worker pool. If all the workers are active, the action will be
  109610. * pended until a worker has completed its action.
  109611. * @param action The action to perform. Call onComplete when the action is complete.
  109612. */
  109613. push(action: (worker: Worker, onComplete: () => void) => void): void;
  109614. private _execute;
  109615. }
  109616. }
  109617. declare module BABYLON {
  109618. /**
  109619. * Class containing a set of static utilities functions for screenshots
  109620. */
  109621. export class ScreenshotTools {
  109622. /**
  109623. * Captures a screenshot of the current rendering
  109624. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  109625. * @param engine defines the rendering engine
  109626. * @param camera defines the source camera
  109627. * @param size This parameter can be set to a single number or to an object with the
  109628. * following (optional) properties: precision, width, height. If a single number is passed,
  109629. * it will be used for both width and height. If an object is passed, the screenshot size
  109630. * will be derived from the parameters. The precision property is a multiplier allowing
  109631. * rendering at a higher or lower resolution
  109632. * @param successCallback defines the callback receives a single parameter which contains the
  109633. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  109634. * src parameter of an <img> to display it
  109635. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  109636. * Check your browser for supported MIME types
  109637. */
  109638. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  109639. /**
  109640. * Generates an image screenshot from the specified camera.
  109641. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  109642. * @param engine The engine to use for rendering
  109643. * @param camera The camera to use for rendering
  109644. * @param size This parameter can be set to a single number or to an object with the
  109645. * following (optional) properties: precision, width, height. If a single number is passed,
  109646. * it will be used for both width and height. If an object is passed, the screenshot size
  109647. * will be derived from the parameters. The precision property is a multiplier allowing
  109648. * rendering at a higher or lower resolution
  109649. * @param successCallback The callback receives a single parameter which contains the
  109650. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  109651. * src parameter of an <img> to display it
  109652. * @param mimeType The MIME type of the screenshot image (default: image/png).
  109653. * Check your browser for supported MIME types
  109654. * @param samples Texture samples (default: 1)
  109655. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  109656. * @param fileName A name for for the downloaded file.
  109657. */
  109658. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  109659. }
  109660. }
  109661. declare module BABYLON {
  109662. /**
  109663. * A cursor which tracks a point on a path
  109664. */
  109665. export class PathCursor {
  109666. private path;
  109667. /**
  109668. * Stores path cursor callbacks for when an onchange event is triggered
  109669. */
  109670. private _onchange;
  109671. /**
  109672. * The value of the path cursor
  109673. */
  109674. value: number;
  109675. /**
  109676. * The animation array of the path cursor
  109677. */
  109678. animations: Animation[];
  109679. /**
  109680. * Initializes the path cursor
  109681. * @param path The path to track
  109682. */
  109683. constructor(path: Path2);
  109684. /**
  109685. * Gets the cursor point on the path
  109686. * @returns A point on the path cursor at the cursor location
  109687. */
  109688. getPoint(): Vector3;
  109689. /**
  109690. * Moves the cursor ahead by the step amount
  109691. * @param step The amount to move the cursor forward
  109692. * @returns This path cursor
  109693. */
  109694. moveAhead(step?: number): PathCursor;
  109695. /**
  109696. * Moves the cursor behind by the step amount
  109697. * @param step The amount to move the cursor back
  109698. * @returns This path cursor
  109699. */
  109700. moveBack(step?: number): PathCursor;
  109701. /**
  109702. * Moves the cursor by the step amount
  109703. * If the step amount is greater than one, an exception is thrown
  109704. * @param step The amount to move the cursor
  109705. * @returns This path cursor
  109706. */
  109707. move(step: number): PathCursor;
  109708. /**
  109709. * Ensures that the value is limited between zero and one
  109710. * @returns This path cursor
  109711. */
  109712. private ensureLimits;
  109713. /**
  109714. * Runs onchange callbacks on change (used by the animation engine)
  109715. * @returns This path cursor
  109716. */
  109717. private raiseOnChange;
  109718. /**
  109719. * Executes a function on change
  109720. * @param f A path cursor onchange callback
  109721. * @returns This path cursor
  109722. */
  109723. onchange(f: (cursor: PathCursor) => void): PathCursor;
  109724. }
  109725. }
  109726. declare module BABYLON {
  109727. /** @hidden */
  109728. export var blurPixelShader: {
  109729. name: string;
  109730. shader: string;
  109731. };
  109732. }
  109733. declare module BABYLON {
  109734. /** @hidden */
  109735. export var bones300Declaration: {
  109736. name: string;
  109737. shader: string;
  109738. };
  109739. }
  109740. declare module BABYLON {
  109741. /** @hidden */
  109742. export var instances300Declaration: {
  109743. name: string;
  109744. shader: string;
  109745. };
  109746. }
  109747. declare module BABYLON {
  109748. /** @hidden */
  109749. export var pointCloudVertexDeclaration: {
  109750. name: string;
  109751. shader: string;
  109752. };
  109753. }
  109754. // Mixins
  109755. interface Window {
  109756. mozIndexedDB: IDBFactory;
  109757. webkitIndexedDB: IDBFactory;
  109758. msIndexedDB: IDBFactory;
  109759. webkitURL: typeof URL;
  109760. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  109761. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  109762. WebGLRenderingContext: WebGLRenderingContext;
  109763. MSGesture: MSGesture;
  109764. CANNON: any;
  109765. AudioContext: AudioContext;
  109766. webkitAudioContext: AudioContext;
  109767. PointerEvent: any;
  109768. Math: Math;
  109769. Uint8Array: Uint8ArrayConstructor;
  109770. Float32Array: Float32ArrayConstructor;
  109771. mozURL: typeof URL;
  109772. msURL: typeof URL;
  109773. VRFrameData: any; // WebVR, from specs 1.1
  109774. DracoDecoderModule: any;
  109775. setImmediate(handler: (...args: any[]) => void): number;
  109776. }
  109777. interface Document {
  109778. mozCancelFullScreen(): void;
  109779. msCancelFullScreen(): void;
  109780. webkitCancelFullScreen(): void;
  109781. requestPointerLock(): void;
  109782. exitPointerLock(): void;
  109783. mozFullScreen: boolean;
  109784. msIsFullScreen: boolean;
  109785. readonly webkitIsFullScreen: boolean;
  109786. readonly pointerLockElement: Element;
  109787. mozPointerLockElement: HTMLElement;
  109788. msPointerLockElement: HTMLElement;
  109789. webkitPointerLockElement: HTMLElement;
  109790. }
  109791. interface HTMLCanvasElement {
  109792. requestPointerLock(): void;
  109793. msRequestPointerLock?(): void;
  109794. mozRequestPointerLock?(): void;
  109795. webkitRequestPointerLock?(): void;
  109796. /** Track wether a record is in progress */
  109797. isRecording: boolean;
  109798. /** Capture Stream method defined by some browsers */
  109799. captureStream(fps?: number): MediaStream;
  109800. }
  109801. interface CanvasRenderingContext2D {
  109802. msImageSmoothingEnabled: boolean;
  109803. }
  109804. interface MouseEvent {
  109805. mozMovementX: number;
  109806. mozMovementY: number;
  109807. webkitMovementX: number;
  109808. webkitMovementY: number;
  109809. msMovementX: number;
  109810. msMovementY: number;
  109811. }
  109812. interface Navigator {
  109813. mozGetVRDevices: (any: any) => any;
  109814. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  109815. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  109816. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  109817. webkitGetGamepads(): Gamepad[];
  109818. msGetGamepads(): Gamepad[];
  109819. webkitGamepads(): Gamepad[];
  109820. }
  109821. interface HTMLVideoElement {
  109822. mozSrcObject: any;
  109823. }
  109824. interface Math {
  109825. fround(x: number): number;
  109826. imul(a: number, b: number): number;
  109827. }
  109828. interface WebGLProgram {
  109829. context?: WebGLRenderingContext;
  109830. vertexShader?: WebGLShader;
  109831. fragmentShader?: WebGLShader;
  109832. isParallelCompiled: boolean;
  109833. onCompiled?: () => void;
  109834. }
  109835. interface WebGLRenderingContext {
  109836. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  109837. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  109838. vertexAttribDivisor(index: number, divisor: number): void;
  109839. createVertexArray(): any;
  109840. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  109841. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  109842. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  109843. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  109844. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  109845. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  109846. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  109847. // Queries
  109848. createQuery(): WebGLQuery;
  109849. deleteQuery(query: WebGLQuery): void;
  109850. beginQuery(target: number, query: WebGLQuery): void;
  109851. endQuery(target: number): void;
  109852. getQueryParameter(query: WebGLQuery, pname: number): any;
  109853. getQuery(target: number, pname: number): any;
  109854. MAX_SAMPLES: number;
  109855. RGBA8: number;
  109856. READ_FRAMEBUFFER: number;
  109857. DRAW_FRAMEBUFFER: number;
  109858. UNIFORM_BUFFER: number;
  109859. HALF_FLOAT_OES: number;
  109860. RGBA16F: number;
  109861. RGBA32F: number;
  109862. R32F: number;
  109863. RG32F: number;
  109864. RGB32F: number;
  109865. R16F: number;
  109866. RG16F: number;
  109867. RGB16F: number;
  109868. RED: number;
  109869. RG: number;
  109870. R8: number;
  109871. RG8: number;
  109872. UNSIGNED_INT_24_8: number;
  109873. DEPTH24_STENCIL8: number;
  109874. /* Multiple Render Targets */
  109875. drawBuffers(buffers: number[]): void;
  109876. readBuffer(src: number): void;
  109877. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  109878. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  109879. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  109880. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  109881. // Occlusion Query
  109882. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  109883. ANY_SAMPLES_PASSED: number;
  109884. QUERY_RESULT_AVAILABLE: number;
  109885. QUERY_RESULT: number;
  109886. }
  109887. interface WebGLBuffer {
  109888. references: number;
  109889. capacity: number;
  109890. is32Bits: boolean;
  109891. }
  109892. interface WebGLProgram {
  109893. transformFeedback?: WebGLTransformFeedback | null;
  109894. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  109895. }
  109896. interface EXT_disjoint_timer_query {
  109897. QUERY_COUNTER_BITS_EXT: number;
  109898. TIME_ELAPSED_EXT: number;
  109899. TIMESTAMP_EXT: number;
  109900. GPU_DISJOINT_EXT: number;
  109901. QUERY_RESULT_EXT: number;
  109902. QUERY_RESULT_AVAILABLE_EXT: number;
  109903. queryCounterEXT(query: WebGLQuery, target: number): void;
  109904. createQueryEXT(): WebGLQuery;
  109905. beginQueryEXT(target: number, query: WebGLQuery): void;
  109906. endQueryEXT(target: number): void;
  109907. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  109908. deleteQueryEXT(query: WebGLQuery): void;
  109909. }
  109910. interface WebGLUniformLocation {
  109911. _currentState: any;
  109912. }
  109913. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  109914. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  109915. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  109916. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  109917. interface WebGLRenderingContext {
  109918. readonly RASTERIZER_DISCARD: number;
  109919. readonly DEPTH_COMPONENT24: number;
  109920. readonly TEXTURE_3D: number;
  109921. readonly TEXTURE_2D_ARRAY: number;
  109922. readonly TEXTURE_COMPARE_FUNC: number;
  109923. readonly TEXTURE_COMPARE_MODE: number;
  109924. readonly COMPARE_REF_TO_TEXTURE: number;
  109925. readonly TEXTURE_WRAP_R: number;
  109926. readonly HALF_FLOAT: number;
  109927. readonly RGB8: number;
  109928. readonly RED_INTEGER: number;
  109929. readonly RG_INTEGER: number;
  109930. readonly RGB_INTEGER: number;
  109931. readonly RGBA_INTEGER: number;
  109932. readonly R8_SNORM: number;
  109933. readonly RG8_SNORM: number;
  109934. readonly RGB8_SNORM: number;
  109935. readonly RGBA8_SNORM: number;
  109936. readonly R8I: number;
  109937. readonly RG8I: number;
  109938. readonly RGB8I: number;
  109939. readonly RGBA8I: number;
  109940. readonly R8UI: number;
  109941. readonly RG8UI: number;
  109942. readonly RGB8UI: number;
  109943. readonly RGBA8UI: number;
  109944. readonly R16I: number;
  109945. readonly RG16I: number;
  109946. readonly RGB16I: number;
  109947. readonly RGBA16I: number;
  109948. readonly R16UI: number;
  109949. readonly RG16UI: number;
  109950. readonly RGB16UI: number;
  109951. readonly RGBA16UI: number;
  109952. readonly R32I: number;
  109953. readonly RG32I: number;
  109954. readonly RGB32I: number;
  109955. readonly RGBA32I: number;
  109956. readonly R32UI: number;
  109957. readonly RG32UI: number;
  109958. readonly RGB32UI: number;
  109959. readonly RGBA32UI: number;
  109960. readonly RGB10_A2UI: number;
  109961. readonly R11F_G11F_B10F: number;
  109962. readonly RGB9_E5: number;
  109963. readonly RGB10_A2: number;
  109964. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  109965. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  109966. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  109967. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  109968. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  109969. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  109970. 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;
  109971. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  109972. readonly TRANSFORM_FEEDBACK: number;
  109973. readonly INTERLEAVED_ATTRIBS: number;
  109974. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  109975. createTransformFeedback(): WebGLTransformFeedback;
  109976. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  109977. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  109978. beginTransformFeedback(primitiveMode: number): void;
  109979. endTransformFeedback(): void;
  109980. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  109981. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  109982. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  109983. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  109984. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  109985. }
  109986. interface ImageBitmap {
  109987. readonly width: number;
  109988. readonly height: number;
  109989. close(): void;
  109990. }
  109991. interface WebGLQuery extends WebGLObject {
  109992. }
  109993. declare var WebGLQuery: {
  109994. prototype: WebGLQuery;
  109995. new(): WebGLQuery;
  109996. };
  109997. interface WebGLSampler extends WebGLObject {
  109998. }
  109999. declare var WebGLSampler: {
  110000. prototype: WebGLSampler;
  110001. new(): WebGLSampler;
  110002. };
  110003. interface WebGLSync extends WebGLObject {
  110004. }
  110005. declare var WebGLSync: {
  110006. prototype: WebGLSync;
  110007. new(): WebGLSync;
  110008. };
  110009. interface WebGLTransformFeedback extends WebGLObject {
  110010. }
  110011. declare var WebGLTransformFeedback: {
  110012. prototype: WebGLTransformFeedback;
  110013. new(): WebGLTransformFeedback;
  110014. };
  110015. interface WebGLVertexArrayObject extends WebGLObject {
  110016. }
  110017. declare var WebGLVertexArrayObject: {
  110018. prototype: WebGLVertexArrayObject;
  110019. new(): WebGLVertexArrayObject;
  110020. };
  110021. // Type definitions for WebVR API
  110022. // Project: https://w3c.github.io/webvr/
  110023. // Definitions by: six a <https://github.com/lostfictions>
  110024. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  110025. interface VRDisplay extends EventTarget {
  110026. /**
  110027. * Dictionary of capabilities describing the VRDisplay.
  110028. */
  110029. readonly capabilities: VRDisplayCapabilities;
  110030. /**
  110031. * z-depth defining the far plane of the eye view frustum
  110032. * enables mapping of values in the render target depth
  110033. * attachment to scene coordinates. Initially set to 10000.0.
  110034. */
  110035. depthFar: number;
  110036. /**
  110037. * z-depth defining the near plane of the eye view frustum
  110038. * enables mapping of values in the render target depth
  110039. * attachment to scene coordinates. Initially set to 0.01.
  110040. */
  110041. depthNear: number;
  110042. /**
  110043. * An identifier for this distinct VRDisplay. Used as an
  110044. * association point in the Gamepad API.
  110045. */
  110046. readonly displayId: number;
  110047. /**
  110048. * A display name, a user-readable name identifying it.
  110049. */
  110050. readonly displayName: string;
  110051. readonly isConnected: boolean;
  110052. readonly isPresenting: boolean;
  110053. /**
  110054. * If this VRDisplay supports room-scale experiences, the optional
  110055. * stage attribute contains details on the room-scale parameters.
  110056. */
  110057. readonly stageParameters: VRStageParameters | null;
  110058. /**
  110059. * Passing the value returned by `requestAnimationFrame` to
  110060. * `cancelAnimationFrame` will unregister the callback.
  110061. * @param handle Define the hanle of the request to cancel
  110062. */
  110063. cancelAnimationFrame(handle: number): void;
  110064. /**
  110065. * Stops presenting to the VRDisplay.
  110066. * @returns a promise to know when it stopped
  110067. */
  110068. exitPresent(): Promise<void>;
  110069. /**
  110070. * Return the current VREyeParameters for the given eye.
  110071. * @param whichEye Define the eye we want the parameter for
  110072. * @returns the eye parameters
  110073. */
  110074. getEyeParameters(whichEye: string): VREyeParameters;
  110075. /**
  110076. * Populates the passed VRFrameData with the information required to render
  110077. * the current frame.
  110078. * @param frameData Define the data structure to populate
  110079. * @returns true if ok otherwise false
  110080. */
  110081. getFrameData(frameData: VRFrameData): boolean;
  110082. /**
  110083. * Get the layers currently being presented.
  110084. * @returns the list of VR layers
  110085. */
  110086. getLayers(): VRLayer[];
  110087. /**
  110088. * Return a VRPose containing the future predicted pose of the VRDisplay
  110089. * when the current frame will be presented. The value returned will not
  110090. * change until JavaScript has returned control to the browser.
  110091. *
  110092. * The VRPose will contain the position, orientation, velocity,
  110093. * and acceleration of each of these properties.
  110094. * @returns the pose object
  110095. */
  110096. getPose(): VRPose;
  110097. /**
  110098. * Return the current instantaneous pose of the VRDisplay, with no
  110099. * prediction applied.
  110100. * @returns the current instantaneous pose
  110101. */
  110102. getImmediatePose(): VRPose;
  110103. /**
  110104. * The callback passed to `requestAnimationFrame` will be called
  110105. * any time a new frame should be rendered. When the VRDisplay is
  110106. * presenting the callback will be called at the native refresh
  110107. * rate of the HMD. When not presenting this function acts
  110108. * identically to how window.requestAnimationFrame acts. Content should
  110109. * make no assumptions of frame rate or vsync behavior as the HMD runs
  110110. * asynchronously from other displays and at differing refresh rates.
  110111. * @param callback Define the eaction to run next frame
  110112. * @returns the request handle it
  110113. */
  110114. requestAnimationFrame(callback: FrameRequestCallback): number;
  110115. /**
  110116. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  110117. * Repeat calls while already presenting will update the VRLayers being displayed.
  110118. * @param layers Define the list of layer to present
  110119. * @returns a promise to know when the request has been fulfilled
  110120. */
  110121. requestPresent(layers: VRLayer[]): Promise<void>;
  110122. /**
  110123. * Reset the pose for this display, treating its current position and
  110124. * orientation as the "origin/zero" values. VRPose.position,
  110125. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  110126. * updated when calling resetPose(). This should be called in only
  110127. * sitting-space experiences.
  110128. */
  110129. resetPose(): void;
  110130. /**
  110131. * The VRLayer provided to the VRDisplay will be captured and presented
  110132. * in the HMD. Calling this function has the same effect on the source
  110133. * canvas as any other operation that uses its source image, and canvases
  110134. * created without preserveDrawingBuffer set to true will be cleared.
  110135. * @param pose Define the pose to submit
  110136. */
  110137. submitFrame(pose?: VRPose): void;
  110138. }
  110139. declare var VRDisplay: {
  110140. prototype: VRDisplay;
  110141. new(): VRDisplay;
  110142. };
  110143. interface VRLayer {
  110144. leftBounds?: number[] | Float32Array | null;
  110145. rightBounds?: number[] | Float32Array | null;
  110146. source?: HTMLCanvasElement | null;
  110147. }
  110148. interface VRDisplayCapabilities {
  110149. readonly canPresent: boolean;
  110150. readonly hasExternalDisplay: boolean;
  110151. readonly hasOrientation: boolean;
  110152. readonly hasPosition: boolean;
  110153. readonly maxLayers: number;
  110154. }
  110155. interface VREyeParameters {
  110156. /** @deprecated */
  110157. readonly fieldOfView: VRFieldOfView;
  110158. readonly offset: Float32Array;
  110159. readonly renderHeight: number;
  110160. readonly renderWidth: number;
  110161. }
  110162. interface VRFieldOfView {
  110163. readonly downDegrees: number;
  110164. readonly leftDegrees: number;
  110165. readonly rightDegrees: number;
  110166. readonly upDegrees: number;
  110167. }
  110168. interface VRFrameData {
  110169. readonly leftProjectionMatrix: Float32Array;
  110170. readonly leftViewMatrix: Float32Array;
  110171. readonly pose: VRPose;
  110172. readonly rightProjectionMatrix: Float32Array;
  110173. readonly rightViewMatrix: Float32Array;
  110174. readonly timestamp: number;
  110175. }
  110176. interface VRPose {
  110177. readonly angularAcceleration: Float32Array | null;
  110178. readonly angularVelocity: Float32Array | null;
  110179. readonly linearAcceleration: Float32Array | null;
  110180. readonly linearVelocity: Float32Array | null;
  110181. readonly orientation: Float32Array | null;
  110182. readonly position: Float32Array | null;
  110183. readonly timestamp: number;
  110184. }
  110185. interface VRStageParameters {
  110186. sittingToStandingTransform?: Float32Array;
  110187. sizeX?: number;
  110188. sizeY?: number;
  110189. }
  110190. interface Navigator {
  110191. getVRDisplays(): Promise<VRDisplay[]>;
  110192. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  110193. }
  110194. interface Window {
  110195. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  110196. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  110197. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  110198. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  110199. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  110200. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  110201. }
  110202. interface Gamepad {
  110203. readonly displayId: number;
  110204. }
  110205. interface XRDevice {
  110206. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  110207. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  110208. }
  110209. interface XRSession {
  110210. getInputSources(): Array<any>;
  110211. baseLayer: XRWebGLLayer;
  110212. requestFrameOfReference(type: string): Promise<void>;
  110213. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  110214. end(): Promise<void>;
  110215. requestAnimationFrame: Function;
  110216. addEventListener: Function;
  110217. }
  110218. interface XRSessionCreationOptions {
  110219. outputContext?: WebGLRenderingContext | null;
  110220. immersive?: boolean;
  110221. environmentIntegration?: boolean;
  110222. }
  110223. interface XRLayer {
  110224. getViewport: Function;
  110225. framebufferWidth: number;
  110226. framebufferHeight: number;
  110227. }
  110228. interface XRView {
  110229. projectionMatrix: Float32Array;
  110230. }
  110231. interface XRFrame {
  110232. getDevicePose: Function;
  110233. getInputPose: Function;
  110234. views: Array<XRView>;
  110235. baseLayer: XRLayer;
  110236. }
  110237. interface XRFrameOfReference {
  110238. }
  110239. interface XRWebGLLayer extends XRLayer {
  110240. framebuffer: WebGLFramebuffer;
  110241. }
  110242. declare var XRWebGLLayer: {
  110243. prototype: XRWebGLLayer;
  110244. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  110245. };